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 with this change consults 
ZK_HOST first, which is really not documented in help docs.
   
   In my mind, this change 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 since we actually try to look it up from Solr.



-- 
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: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to