diff --git a/api/v1/aerospikecluster_mutating_webhook.go b/api/v1/aerospikecluster_mutating_webhook.go index 57617d70a..42c9a5fe8 100644 --- a/api/v1/aerospikecluster_mutating_webhook.go +++ b/api/v1/aerospikecluster_mutating_webhook.go @@ -403,6 +403,13 @@ func setDefaultNsConf(asLog logr.Logger, configSpec AerospikeConfigSpec, if rackID != nil { // Add rack-id only in rack specific config, not in global config defaultConfs := map[string]interface{}{"rack-id": *rackID} + + // Delete rack-id from namespace in rack specific config if set to 0 + // This could happen in operator below 3.3.0 + if id, ok := nsMap["rack-id"]; ok && id == float64(0) && *rackID != 0 { + delete(nsMap, "rack-id") + } + if err := setDefaultsInConfigMap( asLog, nsMap, defaultConfs, ); err != nil { @@ -411,6 +418,8 @@ func setDefaultNsConf(asLog logr.Logger, configSpec AerospikeConfigSpec, err, ) } + } else { + delete(nsMap, "rack-id") } } else { // User may have added this key or may have patched object with new smaller rackEnabledNamespace list diff --git a/controllers/configmap.go b/controllers/configmap.go index 458f3cc28..1d5871a10 100644 --- a/controllers/configmap.go +++ b/controllers/configmap.go @@ -8,6 +8,7 @@ import ( "fmt" "io/fs" "path/filepath" + "regexp" "strings" "text/template" @@ -106,6 +107,14 @@ func (r *SingleClusterReconciler) createConfigMapData(rack *asdbv1.Rack) ( confData[aerospikeTemplateConfFileName] = confTemp + // This field value is rectified in 3.3.0. + // Ignore rack-id change from hash computation so that on upgrade clusters are + // not rolling restarted. + re := regexp.MustCompile(`rack-id.*\d+`) + if rackStr := re.FindString(confTemp); rackStr != "" { + confTemp = strings.ReplaceAll(confTemp, rackStr, "rack-id 0") + } + // Add conf hash confHash, err := utils.GetHash(confTemp) if err != nil {