From c003315a7f3961ba7e7d54fa69173087f02d618a Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Fri, 13 Dec 2024 12:08:49 -0500 Subject: [PATCH] fix bash syntax for security bootstrap --- controllers/solrcloud_controller_basic_auth_test.go | 4 ++-- controllers/util/solr_security_util.go | 4 ++-- tests/e2e/solrcloud_security_json_test.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/controllers/solrcloud_controller_basic_auth_test.go b/controllers/solrcloud_controller_basic_auth_test.go index c327991d..c271393d 100644 --- a/controllers/solrcloud_controller_basic_auth_test.go +++ b/controllers/solrcloud_controller_basic_auth_test.go @@ -352,9 +352,9 @@ func expectBasicAuthConfigOnPodTemplateWithGomega(g Gomega, solrCloud *solrv1bet 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 >/dev/null 2>&1; " + - "GET_CURRENT_SECURITY_JSON_EXIT_CODE=$?if [ ${GET_CURRENT_SECURITY_JSON_EXIT_CODE} -eq 0 ]; then " + + "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 >/dev/null 2>&1; " + + "echo $SECURITY_JSON > /tmp/security.json; solr zk cp /tmp/security.json zk:/security.json >/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 >/dev/null 2>&1; " + " echo 'No security.json found. Put new security.json in ZK'; fi" diff --git a/controllers/util/solr_security_util.go b/controllers/util/solr_security_util.go index 991ce0be..2eb8679c 100644 --- a/controllers/util/solr_security_util.go +++ b/controllers/util/solr_security_util.go @@ -238,10 +238,10 @@ func addHostHeaderToProbe(httpGet *corev1.HTTPGetAction, host string) { func cmdToPutSecurityJsonInZk() string { cmd := " solr zk cp zk:/security.json /tmp/current_security.json >/dev/null 2>&1; " + - " GET_CURRENT_SECURITY_JSON_EXIT_CODE=$?" + + " 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; " + + " echo $SECURITY_JSON > /tmp/security.json;" + " solr zk cp /tmp/security.json zk:/security.json >/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 diff --git a/tests/e2e/solrcloud_security_json_test.go b/tests/e2e/solrcloud_security_json_test.go index 10cc40d8..1ceef5e7 100644 --- a/tests/e2e/solrcloud_security_json_test.go +++ b/tests/e2e/solrcloud_security_json_test.go @@ -35,7 +35,7 @@ var _ = FDescribe("E2E - SolrCloud - Security JSON", func() { }) JustBeforeEach(func(ctx context.Context) { - By("generating the security.json secret") + By("generating the security.json secret and basic auth secret") generateSolrSecuritySecret(ctx, solrCloud) generateSolrBasicAuthSecret(ctx, solrCloud)