Repository: apache/solr-operator

Issue:
Zk-setup error
https://github.com/apache/solr-operator/blob/0ffddb6a4be25ffb3fdad6cb3ffe759d89c5fcf2/controllers/util/solr_security_util.go#L243

Zk setup container produce this error ```grep: ]: No such file or directory``` when authentication is activated.
I face this error after upgrading from 0.8.1 to 0.9.0 operator version.

Discussion:
@gerlowskija: Thanks for reporting @idjemaoune !  We've fixed this, and it will be available in an 0.9.1 release we're working on shortly!

Solution patch:
diff --git a/controllers/util/common.go b/controllers/util/common.go
index 7b2e5c9..0f7fdaa 100644
--- a/controllers/util/common.go
+++ b/controllers/util/common.go
@@ -516,6 +516,12 @@ func CopyPodTemplates(from, to *corev1.PodTemplateSpec, basePath string, logger
 		to.Spec.TopologySpreadConstraints = from.Spec.TopologySpreadConstraints
 	}
 
+	if !DeepEqualWithNils(to.Spec.ReadinessGates, from.Spec.ReadinessGates) {
+		requireUpdate = true
+		logger.Info("Update required because field changed", "field", basePath+"Spec.ReadinessGates", "from", to.Spec.ReadinessGates, "to", from.Spec.ReadinessGates)
+		to.Spec.ReadinessGates = from.Spec.ReadinessGates
+	}
+
 	return requireUpdate
 }
 
diff --git a/controllers/util/solr_security_util.go b/controllers/util/solr_security_util.go
index c11e98c..eab99d2 100644
--- a/controllers/util/solr_security_util.go
+++ b/controllers/util/solr_security_util.go
@@ -240,7 +240,7 @@ 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 '{}'
+		"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;" +
 		" 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'; " +



Test patch:
diff --git a/controllers/solrcloud_controller_basic_auth_test.go b/controllers/solrcloud_controller_basic_auth_test.go
index 90eeef2..54b309e 100644
--- a/controllers/solrcloud_controller_basic_auth_test.go
+++ b/controllers/solrcloud_controller_basic_auth_test.go
@@ -353,7 +353,7 @@ 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  " +
+		"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; " +
 		" 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; " +