You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ho...@apache.org on 2023/10/12 14:35:27 UTC

[solr] branch main updated: SOLR-17019: ZkCli should create chroot if necessary

This is an automated email from the ASF dual-hosted git repository.

houston pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/main by this push:
     new 241d6f9acc5 SOLR-17019: ZkCli should create chroot if necessary
241d6f9acc5 is described below

commit 241d6f9acc5e953c45cc1109ba0cbd3b04ebe4e6
Author: Houston Putman <ho...@apache.org>
AuthorDate: Thu Oct 12 10:30:44 2023 -0400

    SOLR-17019: ZkCli should create chroot if necessary
---
 solr/CHANGES.txt                                    |  2 ++
 solr/core/src/java/org/apache/solr/cloud/ZkCLI.java | 12 ++++++++++++
 2 files changed, 14 insertions(+)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 8d2a4d342e4..7a1f980fc72 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -75,6 +75,8 @@ Improvements
 * SOLR-16924: RESTORECORE now sets the UpdateLog to ACTIVE state instead of requiring a separate
   REQUESTAPPLYUPDATES call in Collection restore.  (Julia Lamoine, David Smiley)
 
+* SOLR-17019: ZkCli should create chroot when necessary (Houston Putman)
+
 Optimizations
 ---------------------
 (No changes)
diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkCLI.java b/solr/core/src/java/org/apache/solr/cloud/ZkCLI.java
index 8e058a32a9a..c224e7e5c57 100644
--- a/solr/core/src/java/org/apache/solr/cloud/ZkCLI.java
+++ b/solr/core/src/java/org/apache/solr/cloud/ZkCLI.java
@@ -398,6 +398,10 @@ public class ZkCLI implements CLIO {
             stdout.println("-" + MAKEPATH + " requires one arg - the path to make");
             System.exit(1);
           }
+          if (!ZkController.checkChrootPath(zkServerAddress, true)) {
+            stdout.println("A chroot was specified in zkHost but the znode doesn't exist. ");
+            System.exit(1);
+          }
           zkClient.makePath(arglist.get(0), true);
         } else if (line.getOptionValue(CMD).equalsIgnoreCase(PUT)) {
           List<String> arglist = line.getArgList();
@@ -436,6 +440,10 @@ public class ZkCLI implements CLIO {
           if (zkClient.exists(path, true)) {
             zkClient.setData(path, data, true);
           } else {
+            if (!ZkController.checkChrootPath(zkServerAddress, true)) {
+              stdout.println("A chroot was specified in zkHost but the znode doesn't exist. ");
+              System.exit(1);
+            }
             zkClient.makePath(path, data, CreateMode.PERSISTENT, true);
           }
         } else if (line.getOptionValue(CMD).equalsIgnoreCase(GET)) {
@@ -466,6 +474,10 @@ public class ZkCLI implements CLIO {
           if (!line.hasOption(NAME)) {
             stdout.println("-" + NAME + " is required for " + CLUSTERPROP);
           }
+          if (!ZkController.checkChrootPath(zkServerAddress, true)) {
+            stdout.println("A chroot was specified in zkHost but the znode doesn't exist. ");
+            System.exit(1);
+          }
           String propertyName = line.getOptionValue(NAME);
           // If -val option is missing, we will use the null value. This is required to maintain
           // compatibility with Collections API.