diff --git a/api/v1/coherenceresourcespec_types.go b/api/v1/coherenceresourcespec_types.go index f302eaee..edf815d7 100644 --- a/api/v1/coherenceresourcespec_types.go +++ b/api/v1/coherenceresourcespec_types.go @@ -729,7 +729,7 @@ func (in *CoherenceResourceSpec) CreatePodTemplateSpec(deployment CoherenceResou ServiceAccountName: in.GetServiceAccountName(), ShareProcessNamespace: in.ShareProcessNamespace, Tolerations: in.Tolerations, - TopologySpreadConstraints: in.TopologySpreadConstraints, + TopologySpreadConstraints: in.EnsureTopologySpreadConstraints(deployment), InitContainers: []corev1.Container{ in.CreateOperatorInitContainer(deployment), }, diff --git a/api/v1/common_test.go b/api/v1/common_test.go index 2828466f..83e1a8d1 100644 --- a/api/v1/common_test.go +++ b/api/v1/common_test.go @@ -367,7 +367,7 @@ func createMinimalExpectedPodSpec(deployment coh.CoherenceResource) corev1.PodTe }) } - lp, _ := deployment.GetSpec().Coherence.GetLocalPorts() + lp, _ := spec.Coherence.GetLocalPorts() // The Coherence Container cohContainer := corev1.Container{ @@ -467,7 +467,8 @@ func createMinimalExpectedPodSpec(deployment coh.CoherenceResource) corev1.PodTe VolumeSource: emptyVolume, }, }, - Affinity: spec.CreateDefaultPodAffinity(deployment), + TopologySpreadConstraints: spec.EnsureTopologySpreadConstraints(deployment), + Affinity: spec.CreateDefaultPodAffinity(deployment), }, } diff --git a/api/v1/create_statefulset_test.go b/api/v1/create_statefulset_test.go index 75ce9d6e..23f85695 100644 --- a/api/v1/create_statefulset_test.go +++ b/api/v1/create_statefulset_test.go @@ -654,7 +654,6 @@ func TestCreateStatefulSetWithTopologySpreadConstraintsEmpty(t *testing.T) { deployment := createTestDeployment(spec) // Create expected StatefulSet stsExpected := createMinimalExpectedStatefulSet(deployment) - stsExpected.Spec.Template.Spec.TopologySpreadConstraints = []corev1.TopologySpreadConstraint{} // assert that the StatefulSet is as expected assertStatefulSetCreation(t, deployment, stsExpected)