From 6afcba364a7843999a8b1f2f3975217e22431d1c Mon Sep 17 00:00:00 2001 From: Jason Gerlowski Date: Tue, 2 Apr 2024 12:14:24 -0400 Subject: [PATCH] SOLR-17216: Cleanup command-based Solr probe output Removes some extraneous output from liveness/readiness/startup probes that use the 'bin/solr auth' command. --- controllers/solrcloud_controller_basic_auth_test.go | 4 ++-- controllers/util/solr_security_util.go | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/controllers/solrcloud_controller_basic_auth_test.go b/controllers/solrcloud_controller_basic_auth_test.go index a91846f2..00182005 100644 --- a/controllers/solrcloud_controller_basic_auth_test.go +++ b/controllers/solrcloud_controller_basic_auth_test.go @@ -289,10 +289,10 @@ func expectBasicAuthConfigOnPodTemplateWithGomega(g Gomega, solrCloud *solrv1bet g.Expect(basicAuthSecretVolMount.MountPath).To(Equal("/etc/secrets/"+secretName), "Wrong path used to mount Basic Auth volume") expLivenessProbeCmd := fmt.Sprintf("JAVA_TOOL_OPTIONS=\"-Dbasicauth=$(cat /etc/secrets/%s-solrcloud-basic-auth/username):$(cat /etc/secrets/%s-solrcloud-basic-auth/password) -Dsolr.httpclient.builder.factory=org.apache.solr.client.solrj.impl.PreemptiveBasicAuthClientBuilderFactory\" "+ - "solr api -get \"http://${SOLR_HOST}:8983%s\"", + "solr api -get \"http://${SOLR_HOST}:8983%s\" 2>&1 | grep -v JAVA_TOOL_OPTIONS", solrCloud.Name, solrCloud.Name, expLivenessProbePath) expReadinessProbeCmd := fmt.Sprintf("JAVA_TOOL_OPTIONS=\"-Dbasicauth=$(cat /etc/secrets/%s-solrcloud-basic-auth/username):$(cat /etc/secrets/%s-solrcloud-basic-auth/password) -Dsolr.httpclient.builder.factory=org.apache.solr.client.solrj.impl.PreemptiveBasicAuthClientBuilderFactory\" "+ - "solr api -get \"http://${SOLR_HOST}:8983%s\"", + "solr api -get \"http://${SOLR_HOST}:8983%s\" 2>&1 | grep -v JAVA_TOOL_OPTIONS", solrCloud.Name, solrCloud.Name, expReadinessProbePath) g.Expect(mainContainer.LivenessProbe).To(Not(BeNil()), "main container should have a liveness probe defined") diff --git a/controllers/util/solr_security_util.go b/controllers/util/solr_security_util.go index 51caa313..d67dfe15 100644 --- a/controllers/util/solr_security_util.go +++ b/controllers/util/solr_security_util.go @@ -496,13 +496,16 @@ func useSecureProbe(solrCloud *solr.SolrCloud, probe *corev1.Probe, mountPath st // Future work - SOLR_TOOL_OPTIONS is only in 9.4.0, use JAVA_TOOL_OPTIONS until that is the minimum supported version var javaToolOptionsStr string + var javaToolOptionsOutputFilter string if len(javaToolOptions) > 0 { javaToolOptionsStr = fmt.Sprintf("JAVA_TOOL_OPTIONS=%q ", strings.Join(javaToolOptions, " ")) + javaToolOptionsOutputFilter = " 2>&1 | grep -v JAVA_TOOL_OPTIONS" } else { javaToolOptionsStr = "" + javaToolOptionsOutputFilter = "" } - probeCommand := fmt.Sprintf("%ssolr api -get \"%s://${SOLR_HOST}:%d%s\"", javaToolOptionsStr, solrCloud.UrlScheme(false), probe.HTTPGet.Port.IntVal, probe.HTTPGet.Path) + probeCommand := fmt.Sprintf("%ssolr api -get \"%s://${SOLR_HOST}:%d%s\"%s", javaToolOptionsStr, solrCloud.UrlScheme(false), probe.HTTPGet.Port.IntVal, probe.HTTPGet.Path, javaToolOptionsOutputFilter) probeCommand = regexp.MustCompile(`\s+`).ReplaceAllString(strings.TrimSpace(probeCommand), " ") // use an Exec instead of an HTTP GET