From a5b2605386057eaea943a1f2f3b0111a6497d71d Mon Sep 17 00:00:00 2001 From: Natalia Marukovich Date: Tue, 19 Mar 2024 15:24:11 +0100 Subject: [PATCH] fix PR comments --- pkg/apis/psmdb/v1/psmdb_defaults.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pkg/apis/psmdb/v1/psmdb_defaults.go b/pkg/apis/psmdb/v1/psmdb_defaults.go index f1cdc42a03..8112b5dcdc 100644 --- a/pkg/apis/psmdb/v1/psmdb_defaults.go +++ b/pkg/apis/psmdb/v1/psmdb_defaults.go @@ -768,7 +768,7 @@ func (rs *ReplsetSpec) setSafeDefaults(log logr.Logger) { } func (m *MultiAZ) reconcileOpts(cr *PerconaServerMongoDB) { - m.reconcileAffinityOpts() + m.reconcileAffinityOpts(cr) m.reconcileTopologySpreadConstraints(cr) if cr.CompareVersion("1.15.0") >= 0 { if m.TerminationGracePeriodSeconds == nil || (!cr.Spec.UnsafeConf && *m.TerminationGracePeriodSeconds < 30) { @@ -798,7 +798,16 @@ const AffinityOff = "none" // - if topology key is set and the value not the one of `affinityValidTopologyKeys` - set to `defaultAffinityTopologyKey` // - if topology key set to valuse of `AffinityOff` - disable the affinity at all // - if `Advanced` affinity is set - leave everything as it is and set topology key to nil (Advanced options has a higher priority) -func (m *MultiAZ) reconcileAffinityOpts() { +func (m *MultiAZ) reconcileAffinityOpts(cr *PerconaServerMongoDB) { + + if cr.CompareVersion("1.16.0") < 0 { + affinityValidTopologyKeys = map[string]struct{}{ + AffinityOff: {}, + "kubernetes.io/hostname": {}, + "failure-domain.beta.kubernetes.io/zone": {}, + "failure-domain.beta.kubernetes.io/region": {}, + } + } switch { case m.Affinity == nil: m.Affinity = &PodAffinity{