-
Notifications
You must be signed in to change notification settings - Fork 501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
services/horizon: Relax requirement on Core URL flags #2780
Conversation
They shouldn't be required when captive core is used
if config.StellarCoreDatabaseURL == "" { | ||
log.Fatalf("flag --%s cannot be empty", stellarCoreDBURLFlagName) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with the current solution is that duplicates code. Another possibility would be to move this check inside initRootConfig
and add a param that explains the config context (normal run, reingestion, verify-range, ...).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should worry too much about duplicated code since the Core dependency is going away medium-term.
Also, as I understand, the solution you propose needs to consider what command is being run, which is prone to error and handles command options far away from the command itself (I would rather do the check where the flag is used, for readibility).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the old database backend will be removed right after we move captive out of experimental mode. There are many Horizon deployments out there and they will definitely need time to migrate.
As for duplication, actually we don't need to add params. Checking StellarCoreDatabaseURL
depends on EnableCaptiveCoreIngestion
which is already present in initRootConfig
. The only thing we need to check is StellarCoreDatabaseURL
and we can actually do it in root command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As for duplication, actually we don't need to add params. Checking
StellarCoreDatabaseURL
depends onEnableCaptiveCoreIngestion
which is already present ininitRootConfig
. The only thing we need to check isStellarCoreDatabaseURL
and we can actually do it in root command.
That's not really the case, because right now the root command (and serve) need to use the Core URLs when ingestion is enabled regardless of the value of EnableCaptiveCoreIngestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the old database backend will be removed right after we move captive out of experimental mode.
I didn't assume that, I said it will be removed medium-term.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't assume that, I said it will be removed medium-term.
I mean, the duplication wouldn't be a problem if we were to remove it in the next or following release but it's likely it will stay in the codebase for at least a couple months.
That's not really the case, because right now the root command (and serve) need to use the Core URLs when ingestion is enabled regardless of the value of EnableCaptiveCoreIngestion
There's a mistake in my comment I meant:
The only thing we need to check is StellarCoreURL and we can actually do it in root command.
Sorry! So to be more clear:
- We move all the duplicated
StellarCoreDatabaseURL
checks toinitRootCommand
because we needEnableCaptiveCoreIngestion
andIngest
values for proper validation and they are already there.StellarCoreDatabaseURL
right now is only used in ingestion (ledger backend). - We only check for
StellarCoreURL
in webserver and ingestion (but not when reingesting because we don't update the cursor). So we just validate it in serve because this is when it's really needed.
Sorry if I'm missing something but doing this will remove 4 x if config.StellarCoreDatabaseURL == "" { ... }
so I guess it's worth a try.
Giving 👍 because I'm leaving soon and don't want to block this if there's really a mistake in my thinking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1. We move all the duplicated `StellarCoreDatabaseURL` checks to `initRootCommand` because we need `EnableCaptiveCoreIngestion` and `Ingest` values for proper validation and they are already there. `StellarCoreDatabaseURL` right now is only used in ingestion (ledger backend).
But ... isn't StellarCoreDatabaseURL
required for online ingestion even if EnableCaptiveCoreIngestion
isn't defined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. That is solvable by enforcing StellarCoreDatabaseURL
in the serve
command.
But then ... horizon db reingest range
and horizon expingest {stress-test, verify-range}
need to check that StellarCoreDatabaseURL
or CaptiveCore
are enabled regardless of the value of Ingest
(because isn't checked), which isn't the case for the rest of the commands.
I don't see a way to to generalize it in the root initialization without checking what command is invoked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I think I will merge as is. If you think you can generalize it in an elegant way without breaking existing behavior, I will be more than happy to change it.
NetworkPassphrase: config.NetworkPassphrase, | ||
HistorySession: horizonSession, | ||
HistoryArchiveURL: config.HistoryArchiveURLs[0], | ||
} | ||
if config.EnableCaptiveCoreIngestion { | ||
ingestConfig.StellarCorePath = config.StellarCoreBinaryPath | ||
} else { | ||
if config.StellarCoreDatabaseURL == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@2opremio is there maybe a way to specify conditional requirements in cobra? Like, this is only required if EnableCaptiveCoreIngestion is empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@abuiles something like this is done in initRootConfig
, we already have a similar code there:
if config.EnableCaptiveCoreIngestion && config.StellarCoreBinaryPath == "" {
stdLog.Fatalf("--stellar-core-binary-path must be set when --enable-captive-core-ingestion is set")
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 but please check my last comment about duplication and #2780 (comment).
Only require --stellar-core-db-url and --stellar-core-url explicitly when they are really needed. An external Core instance is not required when using Captive Core, imposing artificial restrictions |
They shouldn't be required when captive core is used
PR Checklist
PR Structure
otherwise).
services/friendbot
, orall
ordoc
if the changes are broad or impact manypackages.
Thoroughness
.md
files, etc... affected by this change). Take a look in the
docs
folder for a given service,like this one.
Release planning
needed with deprecations, added features, breaking changes, and DB schema changes.
semver, or if it's mainly a patch change. The PR is targeted at the next
release branch if it's not a patch change.
What
Only require
--stellar-core-db-url
and--stellar-core-url
explicitly when they are really needed.Fixes #2779
Why
An external Core instance is not required when using Captive Core, imposing artificial restrictions
Known limitations
The message printed out won't be identical to the one printed by Cobra.