janhoy commented on code in PR #3240:
URL: https://github.com/apache/solr/pull/3240#discussion_r1982990193
##########
solr/core/src/java/org/apache/solr/cli/CLIUtils.java:
##########
@@ -216,12 +216,29 @@ public static String normalizeSolrUrl(CommandLine cli)
throws Exception {
}
/**
- * Get the ZooKeeper connection string from either the zk-host command-line
option or by looking
- * it up from a running Solr instance based on the solr-url option.
+ * Get the ZooKeeper connection string from either the zk-host command-line
option or if not
+ * configured, from the 'zkHost' system property aka the 'ZK_HOST'
environment variable.
+ *
+ * @param cli the command line
+ * @return the ZooKeeper connection string or null if not configured
+ */
+ public static String getZkHostFromCliOrEnv(CommandLine cli) {
Review Comment:
I had another look at the CommonCLIOptions. You are correct that the
[SOLR_URL_OPTION](https://github.com/apache/solr/blob/main/solr/core/src/java/org/apache/solr/cli/CommonCLIOptions.java#L43)
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](https://github.com/apache/solr/blob/main/solr/core/src/java/org/apache/solr/cli/CommonCLIOptions.java#L32-L41)
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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]