This is an automated email from the ASF dual-hosted git repository.
houston 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 c1984dd Fix issue with internal-updating of ZK Ephemeral fields.
(#305)
c1984dd is described below
commit c1984dd34290836124d9c9c9b4c623a146f8afc4
Author: Houston Putman <[email protected]>
AuthorDate: Thu Aug 12 14:55:50 2021 -0400
Fix issue with internal-updating of ZK Ephemeral fields. (#305)
---
Makefile | 1 +
.../solrcloud_controller_externaldns_test.go | 1 +
controllers/solrcloud_controller_tls_test.go | 8 +-
controllers/solrcloud_controller_zk_test.go | 2 +
controllers/util/zk_util.go | 129 ++++++++++++++-------
helm/solr/templates/solrcloud.yaml | 4 +
6 files changed, 98 insertions(+), 47 deletions(-)
diff --git a/Makefile b/Makefile
index 43fc207..6cef885 100644
--- a/Makefile
+++ b/Makefile
@@ -90,6 +90,7 @@ run: generate fmt manifests
# Install CRDs into a cluster
install: manifests
kubectl replace -k config/crd || kubectl create -k config/crd
+ kubectl replace -f config/dependencies || kubectl create -f
config/dependencies
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
deploy: manifests install
diff --git a/controllers/solrcloud_controller_externaldns_test.go
b/controllers/solrcloud_controller_externaldns_test.go
index dfc881a..3a68cd4 100644
--- a/controllers/solrcloud_controller_externaldns_test.go
+++ b/controllers/solrcloud_controller_externaldns_test.go
@@ -690,6 +690,7 @@ func TestEDSKubeDomainCloudReconcile(t *testing.T) {
g.Expect(err).NotTo(gomega.HaveOccurred())
defer testClient.Delete(context.TODO(), instance)
g.Eventually(requests,
timeout).Should(gomega.Receive(gomega.Equal(expectedCloudRequest)))
+ g.Eventually(requests,
timeout).Should(gomega.Receive(gomega.Equal(expectedCloudRequest)))
// Check the statefulSet
statefulSet := expectStatefulSet(t, g, requests, expectedCloudRequest,
cloudSsKey)
diff --git a/controllers/solrcloud_controller_tls_test.go
b/controllers/solrcloud_controller_tls_test.go
index 44f3ac7..27fd378 100644
--- a/controllers/solrcloud_controller_tls_test.go
+++ b/controllers/solrcloud_controller_tls_test.go
@@ -286,6 +286,7 @@ func verifyReconcileMountedTLSDir(t *testing.T, instance
*solr.SolrCloud) {
g.Eventually(requests,
timeout).Should(gomega.Receive(gomega.Equal(expectedCloudWithTLSRequest)))
g.Eventually(requests,
timeout).Should(gomega.Receive(gomega.Equal(expectedCloudWithTLSRequest)))
+ g.Eventually(requests,
timeout).Should(gomega.Receive(gomega.Equal(expectedCloudWithTLSRequest)))
expectStatefulSetMountedTLSDirConfig(t, g, instance)
}
@@ -350,6 +351,7 @@ func verifyReconcileUserSuppliedTLS(t *testing.T, instance
*solr.SolrCloud, need
g.Eventually(requests,
timeout).Should(gomega.Receive(gomega.Equal(expectedCloudWithTLSRequest)))
g.Eventually(requests,
timeout).Should(gomega.Receive(gomega.Equal(expectedCloudWithTLSRequest)))
+ g.Eventually(requests,
timeout).Should(gomega.Receive(gomega.Equal(expectedCloudWithTLSRequest)))
sts := expectStatefulSetTLSConfig(t, g, instance,
needsPkcs12InitContainer)
@@ -410,7 +412,7 @@ func TestTLSCommonIngressTermination(t *testing.T) {
}()
ctx := context.TODO()
- helper.ReconcileSolrCloud(ctx, instance, 1)
+ helper.ReconcileSolrCloud(ctx, instance, 2)
expectTerminateIngressTLSConfig(t, g, tlsSecretName, false)
@@ -422,10 +424,6 @@ func TestTLSCommonIngressTermination(t *testing.T) {
if assert.NotNil(t, instance.Status.ExternalCommonAddress, "External
common address in Status should not be nil.") {
assert.EqualValues(t,
"https://"+instance.Namespace+"-"+instance.Name+"-solrcloud."+testDomain,
*instance.Status.ExternalCommonAddress, "Wrong external common address in
status")
}
- assert.Equal(t,
"http://"+instance.Name+"-solrcloud-common."+instance.Namespace,
instance.Status.InternalCommonAddress, "Wrong internal common address in
status")
- if assert.NotNil(t, instance.Status.ExternalCommonAddress, "External
common address in Status should not be nil.") {
- assert.EqualValues(t,
"https://"+instance.Namespace+"-"+instance.Name+"-solrcloud."+testDomain,
*instance.Status.ExternalCommonAddress, "Wrong external common address in
status")
- }
defer testClient.Delete(ctx, instance)
}
diff --git a/controllers/solrcloud_controller_zk_test.go
b/controllers/solrcloud_controller_zk_test.go
index 3174196..7041f4e 100644
--- a/controllers/solrcloud_controller_zk_test.go
+++ b/controllers/solrcloud_controller_zk_test.go
@@ -191,6 +191,7 @@ func TestCloudWithProvidedPersistentZookeeperReconcile(t
*testing.T) {
},
Persistence: &zkv1beta1.Persistence{
VolumeReclaimPolicy:
zkv1beta1.VolumeReclaimPolicyRetain,
+ Annotations:
testDeploymentAnnotations,
},
},
},
@@ -273,6 +274,7 @@ func TestCloudWithProvidedPersistentZookeeperReconcile(t
*testing.T) {
assert.EqualValues(t, "persistence", zkCluster.Spec.StorageType,
"Incorrect zkCluster storage type")
assert.NotNil(t, zkCluster.Spec.Persistence,
"ZkCluster.spec.persistence should not be nil")
assert.EqualValues(t, zkv1beta1.VolumeReclaimPolicyRetain,
zkCluster.Spec.Persistence.VolumeReclaimPolicy, "Incorrect VolumeReclaimPolicy
for ZK Cluster persistent storage")
+ assert.EqualValues(t, testDeploymentAnnotations,
zkCluster.Spec.Persistence.Annotations, "Incorrect Annotations for ZK Cluster
persistent storage")
// Check ZK Pod Options
assert.EqualValues(t, "test-repo", zkCluster.Spec.Image.Repository,
"Incorrect zkCluster image repo")
diff --git a/controllers/util/zk_util.go b/controllers/util/zk_util.go
index 1024bb3..169165f 100644
--- a/controllers/util/zk_util.go
+++ b/controllers/util/zk_util.go
@@ -157,55 +157,94 @@ func CopyZookeeperClusterFields(from, to
*zk.ZookeeperCluster, logger logr.Logge
}
to.Spec.Image.PullPolicy = from.Spec.Image.PullPolicy
- if from.Spec.Persistence != nil {
- if to.Spec.Persistence == nil {
- logger.Info("Update required because field changed",
"field", "Spec.Persistence", "from", to.Spec.Persistence, "to",
from.Spec.Persistence)
+ if !DeepEqualWithNils(to.Spec.StorageType, from.Spec.StorageType) {
+ logger.Info("Update required because field changed", "field",
"Spec.StorageType", "from", to.Spec.StorageType, "to", from.Spec.StorageType)
+ requireUpdate = true
+ to.Spec.StorageType = from.Spec.StorageType
+ }
+ if to.Spec.StorageType == "persistence" {
+ if to.Spec.Ephemeral != nil {
+ logger.Info("Update required because field changed",
"field", "Spec.Ephemeral", "from", to.Spec.Ephemeral, "to", nil)
requireUpdate = true
- to.Spec.Persistence = from.Spec.Persistence
- } else {
- if
!DeepEqualWithNils(to.Spec.Persistence.PersistentVolumeClaimSpec.Resources.Requests,
from.Spec.Persistence.PersistentVolumeClaimSpec.Resources.Requests) {
- logger.Info("Update required because field
changed", "field",
"Spec.Persistence.PersistentVolumeClaimSpec.Resources.Requests", "from",
to.Spec.Persistence.PersistentVolumeClaimSpec.Resources.Requests, "to",
from.Spec.Persistence.PersistentVolumeClaimSpec.Resources.Requests)
- requireUpdate = true
-
to.Spec.Persistence.PersistentVolumeClaimSpec.Resources.Requests =
from.Spec.Persistence.PersistentVolumeClaimSpec.Resources.Requests
- }
-
- if
!DeepEqualWithNils(to.Spec.Persistence.PersistentVolumeClaimSpec.Resources.Limits,
from.Spec.Persistence.PersistentVolumeClaimSpec.Resources.Limits) {
- logger.Info("Update required because field
changed", "field",
"Spec.Persistence.PersistentVolumeClaimSpec.Resources.Limits", "from",
to.Spec.Persistence.PersistentVolumeClaimSpec.Resources.Limits, "to",
from.Spec.Persistence.PersistentVolumeClaimSpec.Resources.Limits)
- requireUpdate = true
-
to.Spec.Persistence.PersistentVolumeClaimSpec.Resources.Limits =
from.Spec.Persistence.PersistentVolumeClaimSpec.Resources.Limits
- }
-
- if
!DeepEqualWithNils(to.Spec.Persistence.PersistentVolumeClaimSpec.AccessModes,
from.Spec.Persistence.PersistentVolumeClaimSpec.AccessModes) {
- logger.Info("Update required because field
changed", "field", "Spec.Persistence.PersistentVolumeClaimSpec.AccessModes",
"from", to.Spec.Persistence.PersistentVolumeClaimSpec.AccessModes, "to",
from.Spec.Persistence.PersistentVolumeClaimSpec.AccessModes)
- requireUpdate = true
-
to.Spec.Persistence.PersistentVolumeClaimSpec.AccessModes =
from.Spec.Persistence.PersistentVolumeClaimSpec.AccessModes
- }
-
- if
!DeepEqualWithNils(to.Spec.Persistence.PersistentVolumeClaimSpec.StorageClassName,
from.Spec.Persistence.PersistentVolumeClaimSpec.StorageClassName) {
- logger.Info("Update required because field
changed", "field",
"Spec.Persistence.PersistentVolumeClaimSpec.StorageClassName", "from",
to.Spec.Persistence.PersistentVolumeClaimSpec.StorageClassName, "to",
from.Spec.Persistence.PersistentVolumeClaimSpec.StorageClassName)
- requireUpdate = true
-
to.Spec.Persistence.PersistentVolumeClaimSpec.StorageClassName =
from.Spec.Persistence.PersistentVolumeClaimSpec.StorageClassName
- }
-
- if
!DeepEqualWithNils(to.Spec.Persistence.VolumeReclaimPolicy,
from.Spec.Persistence.VolumeReclaimPolicy) {
- logger.Info("Update required because field
changed", "field", "Spec.Persistence.VolumeReclaimPolicy", "from",
to.Spec.Persistence.VolumeReclaimPolicy, "to",
from.Spec.Persistence.VolumeReclaimPolicy)
+ to.Spec.Ephemeral = nil
+ }
+ if from.Spec.Persistence != nil {
+ if to.Spec.Persistence == nil {
+ logger.Info("Update required because field
changed", "field", "Spec.Persistence", "from", nil, "to", from.Spec.Persistence)
requireUpdate = true
- to.Spec.Persistence.VolumeReclaimPolicy =
from.Spec.Persistence.VolumeReclaimPolicy
+ to.Spec.Persistence = from.Spec.Persistence
+ } else {
+ if
!DeepEqualWithNils(to.Spec.Persistence.PersistentVolumeClaimSpec.Resources.Requests,
from.Spec.Persistence.PersistentVolumeClaimSpec.Resources.Requests) {
+ logger.Info("Update required because
field changed", "field",
"Spec.Persistence.PersistentVolumeClaimSpec.Resources.Requests", "from",
to.Spec.Persistence.PersistentVolumeClaimSpec.Resources.Requests, "to",
from.Spec.Persistence.PersistentVolumeClaimSpec.Resources.Requests)
+ requireUpdate = true
+
to.Spec.Persistence.PersistentVolumeClaimSpec.Resources.Requests =
from.Spec.Persistence.PersistentVolumeClaimSpec.Resources.Requests
+ }
+
+ if
!DeepEqualWithNils(to.Spec.Persistence.PersistentVolumeClaimSpec.Resources.Limits,
from.Spec.Persistence.PersistentVolumeClaimSpec.Resources.Limits) {
+ logger.Info("Update required because
field changed", "field",
"Spec.Persistence.PersistentVolumeClaimSpec.Resources.Limits", "from",
to.Spec.Persistence.PersistentVolumeClaimSpec.Resources.Limits, "to",
from.Spec.Persistence.PersistentVolumeClaimSpec.Resources.Limits)
+ requireUpdate = true
+
to.Spec.Persistence.PersistentVolumeClaimSpec.Resources.Limits =
from.Spec.Persistence.PersistentVolumeClaimSpec.Resources.Limits
+ }
+
+ if
!DeepEqualWithNils(to.Spec.Persistence.PersistentVolumeClaimSpec.AccessModes,
from.Spec.Persistence.PersistentVolumeClaimSpec.AccessModes) {
+ logger.Info("Update required because
field changed", "field",
"Spec.Persistence.PersistentVolumeClaimSpec.AccessModes", "from",
to.Spec.Persistence.PersistentVolumeClaimSpec.AccessModes, "to",
from.Spec.Persistence.PersistentVolumeClaimSpec.AccessModes)
+ requireUpdate = true
+
to.Spec.Persistence.PersistentVolumeClaimSpec.AccessModes =
from.Spec.Persistence.PersistentVolumeClaimSpec.AccessModes
+ }
+
+ if
!DeepEqualWithNils(to.Spec.Persistence.PersistentVolumeClaimSpec.StorageClassName,
from.Spec.Persistence.PersistentVolumeClaimSpec.StorageClassName) {
+ logger.Info("Update required because
field changed", "field",
"Spec.Persistence.PersistentVolumeClaimSpec.StorageClassName", "from",
to.Spec.Persistence.PersistentVolumeClaimSpec.StorageClassName, "to",
from.Spec.Persistence.PersistentVolumeClaimSpec.StorageClassName)
+ requireUpdate = true
+
to.Spec.Persistence.PersistentVolumeClaimSpec.StorageClassName =
from.Spec.Persistence.PersistentVolumeClaimSpec.StorageClassName
+ }
+
+ if
!DeepEqualWithNils(to.Spec.Persistence.VolumeReclaimPolicy,
from.Spec.Persistence.VolumeReclaimPolicy) {
+ logger.Info("Update required because
field changed", "field", "Spec.Persistence.VolumeReclaimPolicy", "from",
to.Spec.Persistence.VolumeReclaimPolicy, "to",
from.Spec.Persistence.VolumeReclaimPolicy)
+ requireUpdate = true
+ to.Spec.Persistence.VolumeReclaimPolicy
= from.Spec.Persistence.VolumeReclaimPolicy
+ }
+
+ if
!DeepEqualWithNils(to.Spec.Persistence.Annotations,
from.Spec.Persistence.Annotations) {
+ logger.Info("Update required because
field changed", "field", "Spec.Persistence.Annotations", "from",
to.Spec.Persistence.Annotations, "to", from.Spec.Persistence.Annotations)
+ requireUpdate = true
+ to.Spec.Persistence.Annotations =
from.Spec.Persistence.Annotations
+ }
}
-
- if !DeepEqualWithNils(to.Spec.Persistence.Annotations,
from.Spec.Persistence.Annotations) {
- logger.Info("Update required because field
changed", "field", "Spec.Persistence.Annotations", "from",
to.Spec.Persistence.Annotations, "to", from.Spec.Persistence.Annotations)
+ } else if to.Spec.Persistence != nil {
+ logger.Info("Update required because field changed",
"field", "Spec.Persistence", "from", to.Spec.Persistence, "to", nil)
+ requireUpdate = true
+ to.Spec.Persistence = nil
+ }
+ } else if to.Spec.StorageType == "ephemeral" {
+ if to.Spec.Persistence != nil {
+ logger.Info("Update required because field changed",
"field", "Spec.Persistence", "from", to.Spec.Persistence, "to", nil)
+ requireUpdate = true
+ to.Spec.Persistence = nil
+ }
+ if from.Spec.Ephemeral != nil {
+ if to.Spec.Ephemeral == nil {
+ logger.Info("Update required because field
changed", "field", "Spec.Ephemeral", "from", nil, "to", from.Spec.Ephemeral)
requireUpdate = true
- to.Spec.Persistence.Annotations =
from.Spec.Persistence.Annotations
+ to.Spec.Ephemeral = from.Spec.Ephemeral
+ } else {
+ if
!DeepEqualWithNils(to.Spec.Ephemeral.EmptyDirVolumeSource.Medium,
from.Spec.Ephemeral.EmptyDirVolumeSource.Medium) {
+ logger.Info("Update required because
field changed", "field", "Spec.Ephemeral.EmptyDirVolumeSource.Medium", "from",
to.Spec.Ephemeral.EmptyDirVolumeSource.Medium, "to",
from.Spec.Ephemeral.EmptyDirVolumeSource.Medium)
+ requireUpdate = true
+
to.Spec.Ephemeral.EmptyDirVolumeSource.Medium =
from.Spec.Ephemeral.EmptyDirVolumeSource.Medium
+ }
+
+ if
!DeepEqualWithNils(to.Spec.Ephemeral.EmptyDirVolumeSource.SizeLimit,
from.Spec.Ephemeral.EmptyDirVolumeSource.SizeLimit) {
+ logger.Info("Update required because
field changed", "field", "Spec.Ephemeral.EmptyDirVolumeSource.SizeLimit",
"from", to.Spec.Ephemeral.EmptyDirVolumeSource.SizeLimit, "to",
from.Spec.Ephemeral.EmptyDirVolumeSource.SizeLimit)
+ requireUpdate = true
+
to.Spec.Ephemeral.EmptyDirVolumeSource.SizeLimit =
from.Spec.Ephemeral.EmptyDirVolumeSource.SizeLimit
+ }
}
+ } else if to.Spec.Ephemeral != nil {
+ logger.Info("Update required because field changed",
"field", "Spec.Ephemeral", "from", to.Spec.Ephemeral, "to", nil)
+ requireUpdate = true
+ to.Spec.Ephemeral = nil
}
}
- /* Uncomment when the following PR is merged in:
https://github.com/pravega/zookeeper-operator/pull/64
- Otherwise the ZK Operator will create persistence when none is
given, and this will infinitely loop.
- else if to.Spec.Persistence != nil {
- requireUpdate = true
- to.Spec.Persistence = nil
- }*/
if !DeepEqualWithNils(to.Spec.Pod.Resources, from.Spec.Pod.Resources) {
logger.Info("Update required because field changed", "field",
"Spec.Pod.Resources", "from", to.Spec.Pod.Resources, "to",
from.Spec.Pod.Resources)
@@ -254,6 +293,12 @@ func CopyZookeeperClusterFields(from, to
*zk.ZookeeperCluster, logger logr.Logge
}
to.Spec.KubernetesClusterDomain = from.Spec.KubernetesClusterDomain
+ if !DeepEqualWithNils(to.Spec.Probes, from.Spec.Probes) {
+ logger.Info("Update required because field changed", "field",
"Spec.Probes", "from", to.Spec.Probes, "to", from.Spec.Probes)
+ requireUpdate = true
+ to.Spec.Probes = from.Spec.Probes
+ }
+
return requireUpdate
}
diff --git a/helm/solr/templates/solrcloud.yaml
b/helm/solr/templates/solrcloud.yaml
index 83984a5..00fb079 100644
--- a/helm/solr/templates/solrcloud.yaml
+++ b/helm/solr/templates/solrcloud.yaml
@@ -120,13 +120,17 @@ spec:
annotations:
{{- toYaml .Values.dataStorage.persistent.pvc.annotations |
nindent 12 }}
{{- end }}
+ {{- if (or .Values.dataStorage.capacity
.Values.dataStorage.persistent.pvc.storageClassName) }}
spec:
{{- if .Values.dataStorage.capacity }}
resources:
requests:
storage: {{ .Values.dataStorage.capacity | quote }}
{{- end }}
+ {{- if .Values.dataStorage.persistent.pvc.storageClassName }}
storageClassName: {{
.Values.dataStorage.persistent.pvc.storageClassName | quote }}
+ {{- end }}
+ {{- end }}
{{- else }}
ephemeral:
{{- if (and .Values.dataStorage.ephemeral.hostPath (not
.Values.dataStorage.ephemeral.emptyDir)) }}