This is an automated email from the ASF dual-hosted git repository.
gerlowskija 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 cb2ddfa Provide explicit '-z' option to 'solr zk' (#756)
cb2ddfa is described below
commit cb2ddfac75f528acb81bec70dd5851fc9c6844a0
Author: Samuel Verstraete <[email protected]>
AuthorDate: Tue Mar 11 15:11:09 2025 +0100
Provide explicit '-z' option to 'solr zk' (#756)
This works around a bug (SOLR-17690) in Solr 9.8 where the "solr zk"
tool wasn't reading the ZK_HOST env-var as in previous versions.
Providing the ZK hostname via an explicit CLI option allows our
initContainer logic to work for all Solr versions in the supported range.
(When 9.8.x falls out of the supported Solr version range, this code can
likely be simplified.)
---------
Co-authored-by: samuel <[email protected]>
---
controllers/solrcloud_controller_basic_auth_test.go | 6 +++---
controllers/util/solr_security_util.go | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/controllers/solrcloud_controller_basic_auth_test.go
b/controllers/solrcloud_controller_basic_auth_test.go
index c271393..90eeef2 100644
--- a/controllers/solrcloud_controller_basic_auth_test.go
+++ b/controllers/solrcloud_controller_basic_auth_test.go
@@ -351,12 +351,12 @@ 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; " +
+ 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 >/dev/null 2>&1; " +
+ "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 >/dev/null 2>&1; " +
+ " echo $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 2eb8679..c11e98c 100644
--- a/controllers/util/solr_security_util.go
+++ b/controllers/util/solr_security_util.go
@@ -237,17 +237,17 @@ 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; " +
+ 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;" +
- " solr zk cp /tmp/security.json zk:/security.json >/dev/null
2>&1; " +
+ " 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;" +
- " solr zk cp /tmp/security.json zk:/security.json >/dev/null
2>&1; " +
+ " 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"
return cmd