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

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


The following commit(s) were added to refs/heads/main by this push:
     new aa8e41e  #798 use builtin test syntax instead of bash  [[ conditional 
construct (#800)
aa8e41e is described below

commit aa8e41eaf011e08a14a5b37175575f62d97fdb28
Author: Daniel Raap <[email protected]>
AuthorDate: Fri Mar 6 00:26:29 2026 +0100

    #798 use builtin test syntax instead of bash  [[ conditional construct 
(#800)
---
 controllers/solrcloud_controller_basic_auth_test.go | 6 +++---
 controllers/util/solr_security_util.go              | 6 +++---
 helm/solr-operator/Chart.yaml                       | 7 +++++++
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/controllers/solrcloud_controller_basic_auth_test.go 
b/controllers/solrcloud_controller_basic_auth_test.go
index f01fe91..1129560 100644
--- a/controllers/solrcloud_controller_basic_auth_test.go
+++ b/controllers/solrcloud_controller_basic_auth_test.go
@@ -354,10 +354,10 @@ func expectPutSecurityJsonInZkCmd(g Gomega, 
expInitContainer *corev1.Container)
        g.Expect(expInitContainer).To(Not(BeNil()), "Didn't find the setup-zk 
InitContainer in the sts!")
        expCmd := "solr zk cp zk:/security.json /tmp/current_security.json -z 
$ZK_HOST >/dev/null 2>&1;  " +
                "GET_CURRENT_SECURITY_JSON_EXIT_CODE=$?; if [ 
${GET_CURRENT_SECURITY_JSON_EXIT_CODE} -eq 0 ]; then " +
-               "if [[ ! -s /tmp/current_security.json ]] || grep -q '^{}$' 
/tmp/current_security.json ; then  " +
-               "echo $SECURITY_JSON > /tmp/security.json; solr zk cp 
/tmp/security.json zk:/security.json -z $ZK_HOST >/dev/null 2>&1; " +
+               "if [ ! -s /tmp/current_security.json ] || grep -q '^{}$' 
/tmp/current_security.json ; then  " +
+               "printf '%s' \"$SECURITY_JSON\" > /tmp/security.json; solr zk 
cp /tmp/security.json zk:/security.json -z $ZK_HOST >/dev/null 2>&1; " +
                " echo 'Blank security.json found. Put new security.json in 
ZK'; fi; elif [ ${GET_CURRENT_SECURITY_JSON_EXIT_CODE} -eq 1 ]; then " +
-               " echo $SECURITY_JSON > /tmp/security.json; solr zk cp 
/tmp/security.json zk:/security.json -z $ZK_HOST >/dev/null 2>&1; " +
+               " printf '%s' \"$SECURITY_JSON\" > /tmp/security.json; solr zk 
cp /tmp/security.json zk:/security.json -z $ZK_HOST >/dev/null 2>&1; " +
                " echo 'No security.json found. Put new security.json in ZK'; 
fi"
        g.Expect(expInitContainer.Command[2]).To(ContainSubstring(expCmd), 
"setup-zk initContainer not configured to bootstrap security.json!")
 }
diff --git a/controllers/util/solr_security_util.go 
b/controllers/util/solr_security_util.go
index 417d6b9..816d852 100644
--- a/controllers/util/solr_security_util.go
+++ b/controllers/util/solr_security_util.go
@@ -243,13 +243,13 @@ func cmdToPutSecurityJsonInZk() string {
        cmd := " solr zk cp zk:/security.json /tmp/current_security.json -z 
$ZK_HOST >/dev/null 2>&1; " +
                " GET_CURRENT_SECURITY_JSON_EXIT_CODE=$?; " +
                "if [ ${GET_CURRENT_SECURITY_JSON_EXIT_CODE} -eq 0 ]; then " + 
// JSON already exists
-               "if [[ ! -s /tmp/current_security.json ]] || grep -q '^{}$' 
/tmp/current_security.json ; then " + // File doesn't exist, is empty, or is 
just '{}'
-               " echo $SECURITY_JSON > /tmp/security.json;" +
+               "if [ ! -s /tmp/current_security.json ] || grep -q '^{}$' 
/tmp/current_security.json ; then " + // File doesn't exist, is empty, or is 
just '{}'
+               " printf '%s' \"$SECURITY_JSON\" > /tmp/security.json;" +
                " solr zk cp /tmp/security.json zk:/security.json -z $ZK_HOST 
>/dev/null 2>&1; " +
                " echo 'Blank security.json found. Put new security.json in 
ZK'; " +
                "fi; " + // TODO: Consider checking a diff and still applying 
over the top
                "elif [ ${GET_CURRENT_SECURITY_JSON_EXIT_CODE} -eq 1 ]; then " 
+ // JSON doesn't exist, but not other error types
-               " echo $SECURITY_JSON > /tmp/security.json;" +
+               " printf '%s' \"$SECURITY_JSON\" > /tmp/security.json;" +
                " solr zk cp /tmp/security.json zk:/security.json -z $ZK_HOST 
>/dev/null 2>&1; " +
                " echo 'No security.json found. Put new security.json in ZK'; " 
+
                "fi"
diff --git a/helm/solr-operator/Chart.yaml b/helm/solr-operator/Chart.yaml
index 1e174e1..81138d0 100644
--- a/helm/solr-operator/Chart.yaml
+++ b/helm/solr-operator/Chart.yaml
@@ -72,6 +72,13 @@ annotations:
           url: https://github.com/apache/solr-operator/issues/778
         - name: Github PR
           url: https://github.com/apache/solr-operator/pull/779
+    - kind: fixed
+      description: Fixed initContainer script that imports security.json
+      links:
+        - name: Github Issue
+          url: https://github.com/apache/solr-operator/issues/798
+        - name: Github PR
+          url: https://github.com/apache/solr-operator/pull/800
     - kind: fixed
       description: SOLR_TOOL_OPTS is now set, allowing 'setup-zk' 
initContainer to obey ZK connection settings
       links:

Reply via email to