-
Notifications
You must be signed in to change notification settings - Fork 700
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
SOLR-17690 Make solr zk tools read ZK_HOST environment #3240
base: main
Are you sure you want to change the base?
Conversation
Refactored a bit, to be able to use the Activated the fix since the Crave tests don't run anyway to show the failing test. I'll run all the tests locally. |
I ran crave locally since it does not work in gh-actions:
|
Hmm, there's no Here is suggested changes text:
|
So add it to the changelog for 9.9, and then in branch_9_8, add it to 9.8.1. As a part of the release, I remove the duplicates from 9.9 on branch_9x and main. |
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.
There's lots of other usages of cli.getOptionValue(CommonCLIOptions.ZK_HOST_OPTION)
so I might go through and see what else needs to be switched to this method.
Otherwise I like how it works.
* @param cli the command line | ||
* @return the ZooKeeper connection string or null if not configured | ||
*/ | ||
public static String getZkHostFromCliOrEnv(CommandLine cli) { |
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.
Could we look more closely at how CLIUtils. getDefaultSolrUrl works? It feels like we need to make the looking up of ZK and Solr URL more aligned. Use similiar names for the methods and similar patterns for the look ups.
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 had another look at the CommonCLIOptions. You are correct that the SOLR_URL_OPTION documents that it defaults to an URL defined by a set of sysProps. But not all tools do fallback in the same way, e.g. CreateTool looks up a live node in zk instead.
The ZK_HOST_OPTION main help text says it defaults to localhost:9983
but many tools uses getZkHost()
which queries solr to find zkHost, but that is really not documented in help docs.
This PR brings tools in line with ZK_HOST_OPTION help docs
"Zookeeper connection string; unnecessary if ZK_HOST is defined in solr.in.sh;
But the last part
"otherwise, defaults to localhost:9983"
is still largely wrong for many tools, since we actually try to look it up via Solr APIs. We could change that help text to align with reality but I have not surveyed every single use, have not seen what refGuide says etc, so let it be for a followup PR.
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 posted an email to dev@ on why in general I think the use of environment variables in our scripts is a bad idea.
So this review isn't about if this is a good or bad idea, but only about how we are actually supporting the ZK_HOST variable.
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'm fine with the changes. I feel that the users may be overwhelmed with the amount of options we give them for defining a property (CLI option, env vars and file), which makes our code more complex as well, as we have to cover each one individually and have a prioritization behind the scenes, covered in both Java classes and scripts. But that's another story.
Perhaps the alternative, "simplified" way to address this is to pass EnvUtils.getProperty("zkHost")
in
cli.getOptionValue(CommonCLIOptions.ZK_HOST_OPTION, EnvUtils.getProperty("zkHost")
, so no new methods are needed. But both ways should be fine if they adress the issue and the method is a bit more flexible in these scenarios. :)
I was also not aware that the operator would be affected by changes in the CLI, would be nice to have those covered as well during our refactoring. 😅
So I think there is good discussion to be had here about the use of EnvVars in the SolrCLI logic (which currently we do use for default Solr URLs). But in the meantime, I do believe that there is a fix for apache/solr-operator#762 that will support 9.8.0 and 9.8.1 even if this PR isn't included. I think that's probably the way to go, so we can spend the time and come up with the best strategy for CLI EnvVars. |
Adding So you can set Perhaps we could do a better job in SolrCLI of wrapping such common behavior in more generic utils like CLIUtils#getOptionOrPropValue(CommandLine cli, Option option, String sysprop, String default) e.g. CLIUtils.getOptionOrPropValue(cli, CommonCLIOptions.ZK_HOST_OPTION, "zkHost", null) |
https://issues.apache.org/jira/browse/SOLR-17690
Fix for apache/solr-operator#762