diff --git a/api/v1/aerospikecluster_mutating_webhook.go b/api/v1/aerospikecluster_mutating_webhook.go index 42c9a5fe8..fbcea4ed6 100644 --- a/api/v1/aerospikecluster_mutating_webhook.go +++ b/api/v1/aerospikecluster_mutating_webhook.go @@ -404,8 +404,9 @@ func setDefaultNsConf(asLog logr.Logger, configSpec AerospikeConfigSpec, // 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 + // rack-id was historically set to 0 for all namespaces, but since the AKO 3.3.0, it reflects actual values. + // During the AKO 3.3.0 upgrade rack-id for namespaces in rack specific config is set to 0. + // Hence, deleting this 0 rack-id so that correct rack-id will be added. if id, ok := nsMap["rack-id"]; ok && id == float64(0) && *rackID != 0 { delete(nsMap, "rack-id") } @@ -419,6 +420,8 @@ func setDefaultNsConf(asLog logr.Logger, configSpec AerospikeConfigSpec, ) } } else { + // Deleting rack-id for namespaces in global config. + // Correct rack-id will be added in rack specific config. delete(nsMap, "rack-id") } } else { diff --git a/api/v1/aerospikecluster_validating_webhook.go b/api/v1/aerospikecluster_validating_webhook.go index 9bede3ad8..fd8dcb34e 100644 --- a/api/v1/aerospikecluster_validating_webhook.go +++ b/api/v1/aerospikecluster_validating_webhook.go @@ -2153,6 +2153,9 @@ func (c *AerospikeCluster) validateNetworkPolicy(namespace string) error { return nil } +// validateBatchSize validates the batch size for the following types: +// - rollingUpdateBatchSize: Rolling update batch size +// - scaleDownBatchSize: Scale down batch size func (c *AerospikeCluster) validateBatchSize(batchSize *intstr.IntOrString, rollingUpdateBatch bool) error { var fieldPath string @@ -2196,6 +2199,7 @@ func (c *AerospikeCluster) validateBatchSize(batchSize *intstr.IntOrString, roll ) } + // If Strong Consistency is enabled, then scaleDownBatchSize can't be used if !rollingUpdateBatch && nsConf.scEnabled { return fmt.Errorf( "can not use %s when namespace `%s` is configured with Strong Consistency", fieldPath, @@ -2326,7 +2330,9 @@ func (c *AerospikeCluster) validateEnableDynamicConfigUpdate() error { } if val < 0 { - return fmt.Errorf("cannot enable enableDynamicConfigUpdate flag, init container are running version less than %s", + return fmt.Errorf("cannot enable enableDynamicConfigUpdate flag, some init containers are running version less"+ + " than %s. Please visit https://aerospike.com/docs/cloud/kubernetes/operator/Cluster-configuration-settings#spec"+ + " for more details about enableDynamicConfigUpdate flag", minInitVersionForDynamicConf) } diff --git a/controllers/configmap.go b/controllers/configmap.go index 1d5871a10..c9271b98d 100644 --- a/controllers/configmap.go +++ b/controllers/configmap.go @@ -107,9 +107,10 @@ 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. + // [Backward compatibility fix for AKO 3.3.0 upgrade] + // rack-id was historically set to 0 for all namespaces, but since the AKO 3.3.0, it reflects actual values. + // This change led to hash mismatches during the AKO 3.3.0 upgrade, triggering unnecessary warm restarts. + // Solution: Replace real rack-id with 0 in hash calculations to avoid this issue. re := regexp.MustCompile(`rack-id.*\d+`) if rackStr := re.FindString(confTemp); rackStr != "" { confTemp = strings.ReplaceAll(confTemp, rackStr, "rack-id 0") @@ -146,6 +147,7 @@ func (r *SingleClusterReconciler) createConfigMapData(rack *asdbv1.Rack) ( return nil, err } + // [Backward compatibility fix for AKO 2.1.0 upgrade] // This is a newly introduced field in 2.1.0. // Ignore empty value from hash computation so that on upgrade clusters are // not rolling restarted. @@ -153,6 +155,7 @@ func (r *SingleClusterReconciler) createConfigMapData(rack *asdbv1.Rack) ( string(podSpecStr), "\"aerospikeInitContainer\":{},", "", )) + // [Backward compatibility fix for AKO 3.3.0 upgrade] // This field is changed from bool type to *bool type in 3.3.0 // Ignore false value from hash computation so that on upgrade clusters are // not rolling restarted. diff --git a/test/dynamic_config_test.go b/test/dynamic_config_test.go index b4fc7e8a4..9e5adc727 100644 --- a/test/dynamic_config_test.go +++ b/test/dynamic_config_test.go @@ -437,8 +437,8 @@ var _ = Describe( BeforeEach( func() { // Create a 2 node cluster - aeroCluster := createDummyAerospikeCluster( - clusterNamespacedName, 2, + aeroCluster := getAerospikeClusterSpecWithLDAP( + clusterNamespacedName, ) aeroCluster.Spec.Storage.Volumes = append(aeroCluster.Spec.Storage.Volumes, asdbv1.VolumeSpec{ @@ -479,11 +479,9 @@ var _ = Describe( getNonSCNamespaceConfig("bar", "/test/dev/xvdf1"), } - aeroCluster.Spec.AerospikeConfig.Value["security"] = map[string]interface{}{ - "log": map[string]interface{}{ - "report-data-op-role": []string{"read"}, - "report-data-op-user": []string{"admin2"}, - }, + aeroCluster.Spec.AerospikeConfig.Value["security"].(map[string]interface{})["log"] = map[string]interface{}{ + "report-data-op-role": []string{"read"}, + "report-data-op-user": []string{"admin2"}, } aeroCluster.Spec.EnableDynamicConfigUpdate = ptr.To(true) diff --git a/test/ldap_auth_test.go b/test/ldap_auth_test.go index 6c697533e..fbeacc410 100644 --- a/test/ldap_auth_test.go +++ b/test/ldap_auth_test.go @@ -10,8 +10,6 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/utils/ptr" @@ -97,7 +95,6 @@ func validateTransactions( func getAerospikeClusterSpecWithLDAP( clusterNamespacedName types.NamespacedName, ) *asdbv1.AerospikeCluster { - cascadeDelete := true networkConf := getNetworkTLSConfig() operatorClientCertSpec := getOperatorCert() @@ -107,32 +104,9 @@ func getAerospikeClusterSpecWithLDAP( Namespace: clusterNamespacedName.Namespace, }, Spec: asdbv1.AerospikeClusterSpec{ - Size: 2, - Image: latestImage, - Storage: asdbv1.AerospikeStorageSpec{ - FileSystemVolumePolicy: asdbv1.AerospikePersistentVolumePolicySpec{ - InputCascadeDelete: &cascadeDelete, - }, - BlockVolumePolicy: asdbv1.AerospikePersistentVolumePolicySpec{ - InputCascadeDelete: &cascadeDelete, - }, - Volumes: []asdbv1.VolumeSpec{ - { - Name: "workdir", - Source: asdbv1.VolumeSource{ - PersistentVolume: &asdbv1.PersistentVolumeSpec{ - Size: resource.MustParse("1Gi"), - StorageClass: storageClass, - VolumeMode: corev1.PersistentVolumeFilesystem, - }, - }, - Aerospike: &asdbv1.AerospikeServerVolumeAttachment{ - Path: "/opt/aerospike", - }, - }, - getStorageVolumeForSecret(), - }, - }, + Size: 2, + Image: latestImage, + Storage: getBasicStorageSpecObject(), AerospikeAccessControl: &asdbv1.AerospikeAccessControlSpec{ Users: []asdbv1.AerospikeUserSpec{ @@ -177,15 +151,7 @@ func getAerospikeClusterSpecWithLDAP( }, }, "namespaces": []interface{}{ - map[string]interface{}{ - "name": "test", - "replication-factor": 2, - "migrate-sleep": 0, - "storage-engine": map[string]interface{}{ - "type": "memory", - "data-size": 1073741824, - }, - }, + getSCNamespaceConfig("test", "/test/dev/xvdf"), }, }, },