Skip to content

Commit 99363aa

Browse files
authored
Ensure initContainer sets SOLR_TOOL_OPTS based on SOLR_OPTS value (#804)
1 parent 04f02c1 commit 99363aa

4 files changed

Lines changed: 22 additions & 13 deletions

File tree

controllers/solrcloud_controller_basic_auth_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,10 +324,11 @@ func expectBasicAuthConfigOnPodTemplateWithGomega(g Gomega, solrCloud *solrv1bet
324324
// if the zookeeperRef has ACLs set, verify the env vars were set correctly for this initContainer
325325
allACL, _ := solrCloud.Spec.ZookeeperRef.GetACLs()
326326
if allACL != nil {
327-
g.Expect(expInitContainer.Env).To(HaveLen(10), "Wrong number of env vars using ACLs and Basic Auth")
328-
g.Expect(expInitContainer.Env[len(expInitContainer.Env)-2].Name).To(Equal("SOLR_OPTS"), "Env var SOLR_OPTS is misplaced the Solr Pod env vars")
329-
g.Expect(expInitContainer.Env[len(expInitContainer.Env)-1].Name).To(Equal("SECURITY_JSON"), "Env var SECURITY_JSON is misplaced the Solr Pod env vars")
330-
testACLEnvVarsWithGomega(g, expInitContainer.Env[3:len(expInitContainer.Env)-2], true)
327+
g.Expect(expInitContainer.Env).To(HaveLen(11), "Wrong number of env vars using ACLs and Basic Auth")
328+
g.Expect(expInitContainer.Env[len(expInitContainer.Env)-3].Name).To(Equal("SOLR_OPTS"), "Env var SOLR_OPTS is misplaced among the initContainer env vars")
329+
g.Expect(expInitContainer.Env[len(expInitContainer.Env)-2].Name).To(Equal("SOLR_TOOL_OPTS"), "Env var SOLR_TOOL_OPTS is misplaced among the initContainer env vars")
330+
g.Expect(expInitContainer.Env[len(expInitContainer.Env)-1].Name).To(Equal("SECURITY_JSON"), "Env var SECURITY_JSON is misplaced among the initContainer env vars")
331+
testACLEnvVarsWithGomega(g, expInitContainer.Env[3:len(expInitContainer.Env)-3], true)
331332
} // else this ref not using ACLs
332333

333334
expectPutSecurityJsonInZkCmd(g, expInitContainer)

controllers/solrcloud_controller_zk_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -583,9 +583,9 @@ var _ = FDescribe("SolrCloud controller - Zookeeper", func() {
583583
testPodEnvVariables(expectedEnvVars, statefulSet.Spec.Template.Spec.Containers[0].Env)
584584

585585
expectedInitContainerEnvVars := map[string]string{
586-
"SOLR_ZK_OPTS": testSolrZKOpts,
587-
"SOLR_OPTS": "$(SOLR_ZK_OPTS) " + testSolrOpts,
588-
"ZKCLI_JVM_FLAGS": "-Dsolr.zk.opts=this",
586+
"SOLR_ZK_OPTS": testSolrZKOpts,
587+
"SOLR_OPTS": "$(SOLR_ZK_OPTS) " + testSolrOpts,
588+
"SOLR_TOOL_OPTS": "$(SOLR_ZK_OPTS) " + testSolrOpts,
589589
}
590590
testPodEnvVariables(expectedInitContainerEnvVars, statefulSet.Spec.Template.Spec.InitContainers[1].Env)
591591
})

controllers/util/solr_util.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ package util
1919

2020
import (
2121
"fmt"
22+
"sort"
23+
"strconv"
24+
"strings"
25+
2226
solr "github.com/apache/solr-operator/api/v1beta1"
2327
appsv1 "k8s.io/api/apps/v1"
2428
corev1 "k8s.io/api/core/v1"
@@ -28,9 +32,6 @@ import (
2832
"k8s.io/apimachinery/pkg/util/intstr"
2933
"k8s.io/utils/pointer"
3034
"k8s.io/utils/ptr"
31-
"sort"
32-
"strconv"
33-
"strings"
3435
)
3536

3637
const (
@@ -1236,6 +1237,9 @@ func generateZKInteractionInitContainer(solrCloud *solr.SolrCloud, solrCloudStat
12361237
envVars = append(envVars, corev1.EnvVar{
12371238
Name: "SOLR_OPTS",
12381239
Value: strings.Join(allSolrOpts, " "),
1240+
}, corev1.EnvVar{
1241+
Name: "SOLR_TOOL_OPTS",
1242+
Value: strings.Join(allSolrOpts, " "),
12391243
})
12401244
}
12411245

@@ -1251,9 +1255,6 @@ func generateZKInteractionInitContainer(solrCloud *solr.SolrCloud, solrCloudStat
12511255

12521256
if security != nil && security.SecurityJson != "" {
12531257
envVars = append(envVars, corev1.EnvVar{Name: "SECURITY_JSON", ValueFrom: security.SecurityJsonSrc})
1254-
if solrCloud.Spec.SolrZkOpts != "" {
1255-
envVars = append(envVars, corev1.EnvVar{Name: "ZKCLI_JVM_FLAGS", Value: solrCloud.Spec.SolrZkOpts})
1256-
}
12571258
cmd += cmdToPutSecurityJsonInZk()
12581259
}
12591260

helm/solr-operator/Chart.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ annotations:
7272
url: https://github.com/apache/solr-operator/issues/778
7373
- name: Github PR
7474
url: https://github.com/apache/solr-operator/pull/779
75+
- kind: fixed
76+
description: SOLR_TOOL_OPTS is now set, allowing 'setup-zk' initContainer to obey ZK connection settings
77+
links:
78+
- name: Github Issue
79+
url: https://github.com/apache/solr-operator/issues/717
80+
- name: Github PR
81+
url: https://github.com/apache/solr-operator/pull/804
7582
artifacthub.io/images: |
7683
- name: solr-operator
7784
image: apache/solr-operator:v0.10.0-prerelease

0 commit comments

Comments
 (0)