From cb6bf665458fab0e99adf744177a852072f645e4 Mon Sep 17 00:00:00 2001 From: Abhisek Dwivedi Date: Wed, 22 Jan 2025 00:10:51 +0530 Subject: [PATCH] Removed code and tests for server version < 6.0 --- PROJECT | 9 -- api/v1/access_control_validate.go | 2 +- api/v1/aerospikecluster_validating_webhook.go | 146 +++--------------- api/v1/utils.go | 17 +- ...rnetes-operator.clusterserviceversion.yaml | 61 -------- internal/controller/cluster/access_control.go | 21 +-- internal/controller/cluster/reconciler.go | 9 +- test/cluster/access_control_test.go | 60 +++---- test/cluster/cluster_helper.go | 121 +-------------- test/cluster/cluster_test.go | 66 +------- test/cluster/storage_wipe_test.go | 44 ------ test/cluster/utils.go | 48 ++---- 12 files changed, 62 insertions(+), 542 deletions(-) diff --git a/PROJECT b/PROJECT index 5b3f4a2d9..a5e5494d8 100644 --- a/PROJECT +++ b/PROJECT @@ -11,15 +11,6 @@ plugins: projectName: aerospike-kubernetes-operator repo: github.com/aerospike/aerospike-kubernetes-operator resources: -- api: - crdVersion: v1 - namespaced: true - controller: true - domain: aerospike.com - group: asdb - kind: AerospikeCluster - path: github.com/aerospike/aerospike-kubernetes-operator/api/v1beta1 - version: v1beta1 - api: crdVersion: v1 namespaced: true diff --git a/api/v1/access_control_validate.go b/api/v1/access_control_validate.go index 2fc11011a..ac6e70e94 100644 --- a/api/v1/access_control_validate.go +++ b/api/v1/access_control_validate.go @@ -108,7 +108,7 @@ func IsAerospikeAccessControlValid(aerospikeClusterSpec *AerospikeClusterSpec) ( return false, err } - enabled, err := IsSecurityEnabled(version, aerospikeClusterSpec.AerospikeConfig) + enabled, err := IsSecurityEnabled(aerospikeClusterSpec.AerospikeConfig) if err != nil { return false, err } diff --git a/api/v1/aerospikecluster_validating_webhook.go b/api/v1/aerospikecluster_validating_webhook.go index 5c4881911..e7e06f806 100644 --- a/api/v1/aerospikecluster_validating_webhook.go +++ b/api/v1/aerospikecluster_validating_webhook.go @@ -125,8 +125,7 @@ func (c *AerospikeCluster) ValidateUpdate(oldObj runtime.Object) (admission.Warn // Validate AerospikeConfig update if err := validateAerospikeConfigUpdate( - aslog, incomingVersion, outgoingVersion, - c.Spec.AerospikeConfig, old.Spec.AerospikeConfig, + aslog, c.Spec.AerospikeConfig, old.Spec.AerospikeConfig, c.Status.AerospikeConfig, ); err != nil { return nil, err @@ -192,7 +191,7 @@ func (c *AerospikeCluster) validate(aslog logr.Logger) error { ) } - err = validateClusterSize(aslog, version, int(c.Spec.Size)) + err = validateClusterSize(aslog, int(c.Spec.Size)) if err != nil { return err } @@ -228,7 +227,7 @@ func (c *AerospikeCluster) validate(aslog logr.Logger) error { } if err := validateRequiredFileStorageForMetadata( - rack.AerospikeConfig, &rack.Storage, c.Spec.ValidationPolicy, version, + rack.AerospikeConfig, &rack.Storage, c.Spec.ValidationPolicy, ); err != nil { return err } @@ -423,16 +422,6 @@ func (c *AerospikeCluster) validateRackUpdate( return nil } - outgoingVersion, err := GetImageVersion(old.Spec.Image) - if err != nil { - return err - } - - incomingVersion, err := GetImageVersion(c.Spec.Image) - if err != nil { - return err - } - // Old racks cannot be updated // Also need to exclude a default rack with default rack ID. No need to check here, // user should not provide or update default rackID @@ -466,8 +455,7 @@ func (c *AerospikeCluster) validateRackUpdate( // Validate aerospikeConfig update if err := validateAerospikeConfigUpdate( - aslog, incomingVersion, outgoingVersion, - &newRack.AerospikeConfig, &oldRack.AerospikeConfig, + aslog, &newRack.AerospikeConfig, &oldRack.AerospikeConfig, rackStatusConfig, ); err != nil { return fmt.Errorf( @@ -691,29 +679,11 @@ func getNsConfForNamespaces(rackConfig RackConfig) map[string]nsConf { // ****************************************************************************** // TODO: This should be version specific and part of management lib. -// max cluster size for pre-5.0 cluster -const maxEnterpriseClusterSzLt5_0 = 128 - // max cluster size for 5.0+ cluster const maxEnterpriseClusterSzGt5_0 = 256 -const versionForSzCheck = "5.0.0" - -func validateClusterSize(_ logr.Logger, version string, sz int) error { - val, err := lib.CompareVersions(version, versionForSzCheck) - if err != nil { - return fmt.Errorf( - "failed to validate cluster size limit from version: %v", err, - ) - } - - if val < 0 && sz > maxEnterpriseClusterSzLt5_0 { - return fmt.Errorf( - "cluster size cannot be more than %d", maxEnterpriseClusterSzLt5_0, - ) - } - - if val > 0 && sz > maxEnterpriseClusterSzGt5_0 { +func validateClusterSize(_ logr.Logger, sz int) error { + if sz > maxEnterpriseClusterSzGt5_0 { return fmt.Errorf( "cluster size cannot be more than %d", maxEnterpriseClusterSzGt5_0, ) @@ -1281,82 +1251,41 @@ func getNamespaceReplicationFactor(nsConf map[string]interface{}) (int, error) { return rf, nil } -func validateSecurityConfigUpdate( - newVersion, oldVersion string, newSpec, oldSpec, currentStatus *AerospikeConfigSpec) error { +func validateSecurityConfigUpdate(newSpec, oldSpec, currentStatus *AerospikeConfigSpec) error { if currentStatus != nil { - currentSecurityConfig, err := IsSecurityEnabled(oldVersion, currentStatus) + currentSecurityEnabled, err := IsSecurityEnabled(currentStatus) if err != nil { return err } - desiredSecurityConfig, err := IsSecurityEnabled(newVersion, newSpec) + desiredSecurityEnabled, err := IsSecurityEnabled(newSpec) if err != nil { return err } - if currentSecurityConfig && !desiredSecurityConfig { + if currentSecurityEnabled && !desiredSecurityEnabled { return fmt.Errorf("cannot disable cluster security in running cluster") } } - nv, err := lib.CompareVersions(newVersion, "5.7.0") - if err != nil { - return err - } - - ov, err := lib.CompareVersions(oldVersion, "5.7.0") - if err != nil { - return err - } - - if nv >= 0 || ov >= 0 { - return validateSecurityContext(newVersion, oldVersion, newSpec, oldSpec) - } - - return validateEnableSecurityConfig(newSpec, oldSpec) -} - -func validateEnableSecurityConfig(newConfSpec, oldConfSpec *AerospikeConfigSpec) error { - newConf := newConfSpec.Value - oldConf := oldConfSpec.Value - - oldSec, oldSecConfFound := oldConf["security"] - if !oldSecConfFound { - return nil - } - - newSec, newSecConfFound := newConf["security"] - if !newSecConfFound { - return fmt.Errorf("cannot remove cluster security config") - } - - oldSecFlag, oldEnableSecurityFlagFound := oldSec.(map[string]interface{})["enable-security"] - newSecFlag, newEnableSecurityFlagFound := newSec.(map[string]interface{})["enable-security"] - - if oldEnableSecurityFlagFound && oldSecFlag.(bool) && (!newEnableSecurityFlagFound || !newSecFlag.(bool)) { - return fmt.Errorf("cannot disable cluster security in running cluster") - } - - return nil + return validateSecurityContext(newSpec, oldSpec) } -func validateSecurityContext( - newVersion, oldVersion string, newSpec, oldSpec *AerospikeConfigSpec) error { - ovflag, err := IsSecurityEnabled(oldVersion, oldSpec) +func validateSecurityContext(newSpec, oldSpec *AerospikeConfigSpec) error { + ovflag, err := IsSecurityEnabled(oldSpec) if err != nil { if !errors.Is(err, internalerrors.ErrNotFound) { return fmt.Errorf( - "validateEnableSecurityConfig got an error - oldVersion: %s: %w", - oldVersion, err, + "failed to validate Security context of old aerospike conf: %w", err, ) } } - ivflag, err := IsSecurityEnabled(newVersion, newSpec) + ivflag, err := IsSecurityEnabled(newSpec) if err != nil { if !errors.Is(err, internalerrors.ErrNotFound) { return fmt.Errorf( - "validateEnableSecurityConfig got an error: %w", err, + "failed to validate Security context of new aerospike conf: %w", err, ) } } @@ -1369,14 +1298,12 @@ func validateSecurityContext( } func validateAerospikeConfigUpdate( - aslog logr.Logger, incomingVersion, outgoingVersion string, + aslog logr.Logger, incomingSpec, outgoingSpec, currentStatus *AerospikeConfigSpec, ) error { aslog.Info("Validate AerospikeConfig update") - if err := validateSecurityConfigUpdate( - incomingVersion, outgoingVersion, incomingSpec, outgoingSpec, - currentStatus); err != nil { + if err := validateSecurityConfigUpdate(incomingSpec, outgoingSpec, currentStatus); err != nil { return err } @@ -1759,7 +1686,7 @@ func validateWorkDir(workDirPath string, fileStorageList []string) error { func validateRequiredFileStorageForMetadata( configSpec AerospikeConfigSpec, storage *AerospikeStorageSpec, - validationPolicy *ValidationPolicySpec, version string, + validationPolicy *ValidationPolicySpec, ) error { _, onlyPVFileStorageList, err := storage.getAerospikeStorageList(true) if err != nil { @@ -1788,41 +1715,6 @@ func validateRequiredFileStorageForMetadata( } } - if !validationPolicy.SkipXdrDlogFileValidate { - val, err := lib.CompareVersions(version, "5.0.0") - if err != nil { - return fmt.Errorf("failed to check image version: %v", err) - } - - if val < 0 { - // Validate xdr-digestlog-path for pre-5.0.0 versions. - if IsXdrEnabled(configSpec) { - dglogFilePath, err := GetDigestLogFile(configSpec) - if err != nil { - return err - } - - if !filepath.IsAbs(*dglogFilePath) { - return fmt.Errorf( - "xdr digestlog path %v must be absolute in storage config %v", - dglogFilePath, storage, - ) - } - - dglogDirPath := filepath.Dir(*dglogFilePath) - - if !isFileStorageConfiguredForDir( - onlyPVFileStorageList, dglogDirPath, - ) { - return fmt.Errorf( - "xdr digestlog path %v not mounted in Storage config %v", - dglogFilePath, storage, - ) - } - } - } - } - return nil } diff --git a/api/v1/utils.go b/api/v1/utils.go index a96d363de..6980155f3 100644 --- a/api/v1/utils.go +++ b/api/v1/utils.go @@ -34,7 +34,7 @@ const ( ) const ( - baseVersion = "4.9.0.3" + baseVersion = "6.0.0.0" baseInitVersion = "1.0.0" minInitVersionForDynamicConf = "2.2.0" ) @@ -242,20 +242,7 @@ func IsServiceTLSEnabled(aerospikeConfigSpec *AerospikeConfigSpec) bool { // IsSecurityEnabled tells if security is enabled in cluster // TODO: can an invalid map come here -func IsSecurityEnabled( - version string, aerospikeConfig *AerospikeConfigSpec, -) (bool, error) { - retval, err := lib.CompareVersions(version, "5.7.0") - if err != nil { - return false, err - } - - if retval == -1 { - return IsAttributeEnabled( - aerospikeConfig, "security", "enable-security", - ) - } - +func IsSecurityEnabled(aerospikeConfig *AerospikeConfigSpec) (bool, error) { if _, err := GetConfigContext(aerospikeConfig, "security"); err != nil { if errors.Is(err, internalerrors.ErrNotFound) { return false, nil diff --git a/config/manifests/bases/aerospike-kubernetes-operator.clusterserviceversion.yaml b/config/manifests/bases/aerospike-kubernetes-operator.clusterserviceversion.yaml index 2e00c05b8..663320bce 100644 --- a/config/manifests/bases/aerospike-kubernetes-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/aerospike-kubernetes-operator.clusterserviceversion.yaml @@ -163,67 +163,6 @@ spec: displayName: Validation Policy path: validationPolicy version: v1 - - description: AerospikeCluster is the schema for the AerospikeCluster API - displayName: Aerospike Cluster - kind: AerospikeCluster - name: aerospikeclusters.asdb.aerospike.com - resources: - - kind: Pod - name: "" - version: v1 - - kind: Service - name: "" - version: v1 - - kind: StatefulSet - name: "" - version: v1 - specDescriptors: - - description: Has the Aerospike roles and users definitions. Required if aerospike - cluster security is enabled. - displayName: Access Control - path: aerospikeAccessControl - - description: Sets config in aerospike.conf file. Other configs are taken as - default - displayName: Aerospike Server Configuration - path: aerospikeConfig - - description: AerospikeNetworkPolicy specifies how clients and tools access - the Aerospike cluster. - displayName: Aerospike Network Policy - path: aerospikeNetworkPolicy - - description: Aerospike server image - displayName: Server Image - path: image - - description: Certificates to connect to Aerospike. - displayName: Operator Client Cert - path: operatorClientCert - - description: Specify additional configuration for the Aerospike pods - displayName: Pod Configuration - path: podSpec - - description: |- - RackConfig Configures the operator to deploy rack aware Aerospike cluster. - Pods will be deployed in given racks based on given configuration - displayName: Rack Config - path: rackConfig - - description: |- - SeedsFinderServices creates additional Kubernetes service that allow - clients to discover Aerospike cluster nodes. - displayName: Seeds Finder Services - path: seedsFinderServices - - description: Aerospike cluster size - displayName: Cluster Size - path: size - - description: Storage specify persistent storage to use for the Aerospike pods - displayName: Storage - path: storage - - description: ValidationPolicy controls validation of the Aerospike cluster - resource. - displayName: Validation Policy - path: validationPolicy - statusDescriptors: - - description: Aerospike cluster size - displayName: Cluster Size - path: size - version: v1beta1 - description: AerospikeRestore is the Schema for the aerospikerestores API displayName: Aerospike Restore kind: AerospikeRestore diff --git a/internal/controller/cluster/access_control.go b/internal/controller/cluster/access_control.go index 9a2fe3d6d..bfeacc13c 100644 --- a/internal/controller/cluster/access_control.go +++ b/internal/controller/cluster/access_control.go @@ -43,25 +43,10 @@ func AerospikeAdminCredentials( desiredSecurityErr error ) - incomingVersion, incomingVersionErr := asdbv1.GetImageVersion(desiredState.Image) - if incomingVersionErr == nil { - enabled, desiredSecurityErr = asdbv1.IsSecurityEnabled( - incomingVersion, desiredState.AerospikeConfig, - ) - } else { - desiredSecurityErr = incomingVersionErr - } - + enabled, desiredSecurityErr = asdbv1.IsSecurityEnabled(desiredState.AerospikeConfig) if !enabled { - outgoingVersion, outgoingVersionErr := asdbv1.GetImageVersion(currentState.Image) - if outgoingVersionErr == nil { - // It is possible that this is a new cluster and current state is empty. - enabled, currentSecurityErr = asdbv1.IsSecurityEnabled( - outgoingVersion, currentState.AerospikeConfig, - ) - } else { - currentSecurityErr = outgoingVersionErr - } + // It is possible that this is a new cluster and current state is empty. + enabled, currentSecurityErr = asdbv1.IsSecurityEnabled(currentState.AerospikeConfig) if currentSecurityErr != nil && desiredSecurityErr != nil { return "", "", desiredSecurityErr diff --git a/internal/controller/cluster/reconciler.go b/internal/controller/cluster/reconciler.go index bcb673a22..282909f32 100644 --- a/internal/controller/cluster/reconciler.go +++ b/internal/controller/cluster/reconciler.go @@ -326,14 +326,7 @@ func (r *SingleClusterReconciler) validateAndReconcileAccessControl( selectedPods []corev1.Pod, ignorablePodNames sets.Set[string], ) error { - version, err := asdbv1.GetImageVersion(r.aeroCluster.Spec.Image) - if err != nil { - return err - } - - enabled, err := asdbv1.IsSecurityEnabled( - version, r.aeroCluster.Spec.AerospikeConfig, - ) + enabled, err := asdbv1.IsSecurityEnabled(r.aeroCluster.Spec.AerospikeConfig) if err != nil { return fmt.Errorf("failed to get cluster security status: %v", err) } diff --git a/test/cluster/access_control_test.go b/test/cluster/access_control_test.go index f06499b0b..1453b1b2e 100644 --- a/test/cluster/access_control_test.go +++ b/test/cluster/access_control_test.go @@ -1403,9 +1403,8 @@ var _ = Describe( ), ) } - if err = aerospikeConfigSpec.setEnableSecurity(false); err != nil { - Expect(err).ToNot(HaveOccurred()) - } + + aerospikeConfigSpec.setEnableSecurity(false) aeroCluster := getAerospikeClusterSpecWithAccessControl( clusterNamespacedName, &accessControl, @@ -1488,9 +1487,8 @@ var _ = Describe( ), ) } - if err = aerospikeConfigSpec.setEnableSecurity(true); err != nil { - Expect(err).ToNot(HaveOccurred()) - } + + aerospikeConfigSpec.setEnableSecurity(true) aeroCluster := getAerospikeClusterSpecWithAccessControl( clusterNamespacedName, &accessControl, @@ -1644,9 +1642,8 @@ var _ = Describe( ), ) } - if err = aerospikeConfigSpec.setEnableSecurity(false); err != nil { - Expect(err).ToNot(HaveOccurred()) - } + + aerospikeConfigSpec.setEnableSecurity(false) // Save cluster variable as well for cleanup. aeroCluster := getAerospikeClusterSpecWithAccessControl( @@ -1702,9 +1699,8 @@ var _ = Describe( ), ) } - if err = aerospikeConfigSpec.setEnableSecurity(true); err != nil { - Expect(err).ToNot(HaveOccurred()) - } + + aerospikeConfigSpec.setEnableSecurity(true) aeroCluster = getAerospikeClusterSpecWithAccessControl( clusterNamespacedName, accessControl, @@ -1795,9 +1791,7 @@ var _ = Describe( ) } - if err = aerospikeConfigSpec.setEnableSecurity(true); err != nil { - Expect(err).ToNot(HaveOccurred()) - } + aerospikeConfigSpec.setEnableSecurity(true) aeroCluster := getAerospikeClusterSpecWithAccessControl( clusterNamespacedName, &accessControl, @@ -1853,9 +1847,8 @@ var _ = Describe( ), ) } - if err = aerospikeConfigSpec.setEnableSecurity(true); err != nil { - Expect(err).ToNot(HaveOccurred()) - } + + aerospikeConfigSpec.setEnableSecurity(true) aeroCluster = getAerospikeClusterSpecWithAccessControl( clusterNamespacedName, &accessControl, @@ -1876,9 +1869,9 @@ var _ = Describe( ), ) } - if err = aerospikeConfigSpec.setEnableSecurity(false); err != nil { - Expect(err).ToNot(HaveOccurred()) - } + + aerospikeConfigSpec.setEnableSecurity(false) + aeroCluster = getAerospikeClusterSpecWithAccessControl( clusterNamespacedName, nil, aerospikeConfigSpec, @@ -1957,12 +1950,9 @@ var _ = Describe( ), ) } - if err = aerospikeConfigSpec.setEnableSecurity(true); err != nil { - Expect(err).ToNot(HaveOccurred()) - } - if err = aerospikeConfigSpec.setEnableQuotas(true); err != nil { - Expect(err).ToNot(HaveOccurred()) - } + + aerospikeConfigSpec.setEnableSecurity(true) + aerospikeConfigSpec.setEnableQuotas(true) aeroCluster = getAerospikeClusterSpecWithAccessControl( clusterNamespacedName, &accessControl, @@ -2033,12 +2023,8 @@ var _ = Describe( ), ) } - if err = aerospikeConfigSpec.setEnableSecurity(true); err != nil { - Expect(err).ToNot(HaveOccurred()) - } - if err = aerospikeConfigSpec.setEnableQuotas(false); err != nil { - Expect(err).ToNot(HaveOccurred()) - } + aerospikeConfigSpec.setEnableSecurity(true) + aerospikeConfigSpec.setEnableQuotas(false) aeroCluster = getAerospikeClusterSpecWithAccessControl( clusterNamespacedName, &accessControl, @@ -2111,12 +2097,8 @@ var _ = Describe( ), ) } - if err = aerospikeConfigSpec.setEnableSecurity(true); err != nil { - Expect(err).ToNot(HaveOccurred()) - } - if err = aerospikeConfigSpec.setEnableQuotas(false); err != nil { - Expect(err).ToNot(HaveOccurred()) - } + aerospikeConfigSpec.setEnableSecurity(true) + aerospikeConfigSpec.setEnableQuotas(false) aeroCluster = getAerospikeClusterSpecWithAccessControl( clusterNamespacedName, &accessControl, diff --git a/test/cluster/cluster_helper.go b/test/cluster/cluster_helper.go index 2ebdb2d1d..db63394e4 100644 --- a/test/cluster/cluster_helper.go +++ b/test/cluster/cluster_helper.go @@ -2,7 +2,6 @@ package cluster import ( goctx "context" - "errors" "fmt" "reflect" "strconv" @@ -25,7 +24,6 @@ import ( as "github.com/aerospike/aerospike-client-go/v7" asdbv1 "github.com/aerospike/aerospike-kubernetes-operator/api/v1" - internalerrors "github.com/aerospike/aerospike-kubernetes-operator/errors" "github.com/aerospike/aerospike-kubernetes-operator/pkg/utils" "github.com/aerospike/aerospike-kubernetes-operator/test" lib "github.com/aerospike/aerospike-management-lib" @@ -39,7 +37,6 @@ const ( invalidVersion = "3.0.0.4" post6Version = "7.0.0.0" - pre6Version = "5.7.0.17" version6 = "6.0.0.5" latestSchemaVersion = "7.2.0" @@ -78,7 +75,6 @@ var ( // Storage wipe test post6Image = fmt.Sprintf("%s:%s", baseImage, post6Version) version6Image = fmt.Sprintf("%s:%s", baseImage, version6) - pre6Image = fmt.Sprintf("%s:%s", baseImage, pre6Version) ) func rollingRestartClusterByEnablingTLS( @@ -897,70 +893,7 @@ func getClusterPodList( } // feature-key file needed -func createAerospikeClusterPost460( - clusterNamespacedName types.NamespacedName, size int32, image string, -) *asdbv1.AerospikeCluster { - // create Aerospike custom resource - aeroCluster := &asdbv1.AerospikeCluster{ - ObjectMeta: metav1.ObjectMeta{ - Name: clusterNamespacedName.Name, - Namespace: clusterNamespacedName.Namespace, - }, - Spec: asdbv1.AerospikeClusterSpec{ - Size: size, - Image: image, - AerospikeAccessControl: &asdbv1.AerospikeAccessControlSpec{ - Users: []asdbv1.AerospikeUserSpec{ - { - Name: "admin", - SecretName: test.AuthSecretName, - Roles: []string{ - "sys-admin", - "user-admin", - }, - }, - }, - }, - - PodSpec: asdbv1.AerospikePodSpec{ - MultiPodPerHost: ptr.To(true), - }, - OperatorClientCertSpec: &asdbv1.AerospikeOperatorClientCertSpec{ - AerospikeOperatorCertSource: asdbv1.AerospikeOperatorCertSource{ - SecretCertSource: &asdbv1.AerospikeSecretCertSource{ - SecretName: test.AerospikeSecretName, - CaCertsFilename: "cacert.pem", - ClientCertFilename: "svc_cluster_chain.pem", - ClientKeyFilename: "svc_key.pem", - }, - }, - }, - AerospikeConfig: &asdbv1.AerospikeConfigSpec{ - Value: map[string]interface{}{ - - "service": map[string]interface{}{ - "feature-key-file": "/etc/aerospike/secret/features.conf", - }, - "security": map[string]interface{}{ - "enable-security": true, - }, - "network": getNetworkTLSConfig(), - "namespaces": []interface{}{ - getNonSCNamespaceConfigPre700("test", "/test/dev/xvdf"), - }, - }, - }, - }, - } - aeroCluster.Spec.Storage = getBasicStorageSpecObject() - aeroCluster.Spec.Storage.BlockVolumePolicy.InputCascadeDelete = &cascadeDeleteTrue - aeroCluster.Spec.Storage.FileSystemVolumePolicy.InputCascadeDelete = &cascadeDeleteTrue - - return aeroCluster -} - -// feature-key file needed -func createAerospikeClusterPost560( +func createAerospikeClusterPost570( clusterNamespacedName types.NamespacedName, size int32, image string, ) *asdbv1.AerospikeCluster { // create Aerospike custom resource @@ -1024,7 +957,7 @@ func createAerospikeClusterPost640( clusterNamespacedName types.NamespacedName, size int32, image string, ) *asdbv1.AerospikeCluster { // create Aerospike custom resource - aeroCluster := createAerospikeClusterPost560(clusterNamespacedName, size, image) + aeroCluster := createAerospikeClusterPost570(clusterNamespacedName, size, image) aeroCluster.Spec.AerospikeConfig.Value["namespaces"] = []interface{}{ getNonSCNamespaceConfig("test", "/test/dev/xvdf"), } @@ -1273,56 +1206,6 @@ func UpdateClusterImage( } } - ov, err = lib.CompareVersions(outgoingVersion, "5.7.0") - if err != nil { - return err - } - - nv, err = lib.CompareVersions(incomingVersion, "5.7.0") - if err != nil { - return err - } - - switch { - case nv >= 0 && ov >= 0, nv < 0 && ov < 0: - aerocluster.Spec.Image = image - return nil - case nv >= 0 && ov < 0: - enableSecurityFlag, err := asdbv1.IsSecurityEnabled( - outgoingVersion, aerocluster.Spec.AerospikeConfig, - ) - if err != nil && !errors.Is(err, internalerrors.ErrNotFound) { - return err - } - - aerocluster.Spec.Image = image - if enableSecurityFlag { - securityConfigMap := aerocluster.Spec.AerospikeConfig.Value["security"].(map[string]interface{}) - delete(securityConfigMap, "enable-security") - - return nil - } - - delete(aerocluster.Spec.AerospikeConfig.Value, "security") - default: - enableSecurityFlag, err := asdbv1.IsSecurityEnabled( - outgoingVersion, aerocluster.Spec.AerospikeConfig, - ) - if err != nil { - return err - } - - aerocluster.Spec.Image = image - if enableSecurityFlag { - securityConfigMap := aerocluster.Spec.AerospikeConfig.Value["security"].(map[string]interface{}) - securityConfigMap["enable-security"] = true - - return nil - } - - aerocluster.Spec.AerospikeConfig.Value["security"] = map[string]interface{}{"enable-security": false} - } - return nil } diff --git a/test/cluster/cluster_test.go b/test/cluster/cluster_test.go index ac713ba8d..7a271e8bb 100644 --- a/test/cluster/cluster_test.go +++ b/test/cluster/cluster_test.go @@ -27,7 +27,7 @@ var _ = Describe( // Cluster lifecycle related Context( "DeployClusterPost490", func() { - DeployClusterForAllImagesPost490(ctx) + DeployClusterForAllImagesPost570(ctx) }, ) Context( @@ -76,11 +76,6 @@ var _ = Describe( ScaleDownWithMigrateFillDelay(ctx) }, ) - Context( - "UpdateClusterPre600", func() { - UpdateClusterPre600(ctx) - }, - ) Context( "PauseReconcile", func() { PauseReconcileTest(ctx) @@ -298,60 +293,6 @@ func ValidateAerospikeBenchmarkConfigs(ctx goctx.Context) { ) } -func UpdateClusterPre600(ctx goctx.Context) { - Context( - "UpdateClusterPre600", func() { - clusterNamespacedName := getNamespacedName( - "deploy-cluster-pre6", namespace, - ) - - BeforeEach( - func() { - image := fmt.Sprintf( - "aerospike/aerospike-server-enterprise:%s", pre6Version, - ) - aeroCluster, err := getAeroClusterConfig( - clusterNamespacedName, image, - ) - Expect(err).ToNot(HaveOccurred()) - - err = deployCluster(k8sClient, ctx, aeroCluster) - Expect(err).ToNot(HaveOccurred()) - }, - ) - - AfterEach( - func() { - aeroCluster, err := getCluster( - k8sClient, ctx, clusterNamespacedName, - ) - Expect(err).ToNot(HaveOccurred()) - - _ = deleteCluster(k8sClient, ctx, aeroCluster) - }, - ) - - It( - "UpdateReplicationFactor: should fail for updating namespace replication-factor on server"+ - "before 6.0.0. Cannot be updated", func() { - aeroCluster, err := getCluster(k8sClient, ctx, clusterNamespacedName) - Expect(err).ToNot(HaveOccurred()) - - namespaceConfig := - aeroCluster.Spec.AerospikeConfig.Value["namespaces"].([]interface{})[0].(map[string]interface{}) - namespaceConfig["replication-factor"] = 5 - aeroCluster.Spec.AerospikeConfig.Value["namespaces"].([]interface{})[0] = namespaceConfig - - err = k8sClient.Update( - ctx, aeroCluster, - ) - Expect(err).Should(HaveOccurred()) - }, - ) - }, - ) -} - func ScaleDownWithMigrateFillDelay(ctx goctx.Context) { Context( "ScaleDownWithMigrateFillDelay", func() { @@ -714,10 +655,9 @@ func deployClusterForMaxIgnorablePods(ctx goctx.Context, clusterNamespacedName t } // Test cluster deployment with all image post 4.9.0 -func DeployClusterForAllImagesPost490(ctx goctx.Context) { - // post 4.9.0, need feature-key file +func DeployClusterForAllImagesPost570(ctx goctx.Context) { versions := []string{ - "6.4.0.7", "6.3.0.13", "6.2.0.9", "6.1.0.14", "6.0.0.16", "5.7.0.8", "5.6.0.7", "5.5.0.3", "5.4.0.5", + "7.2.0.6", "7.1.0.12", "7.0.0.20", "6.4.0.7", "6.3.0.13", "6.2.0.9", "6.1.0.14", "6.0.0.16", } for _, v := range versions { diff --git a/test/cluster/storage_wipe_test.go b/test/cluster/storage_wipe_test.go index 99586293f..2f57e8d2e 100644 --- a/test/cluster/storage_wipe_test.go +++ b/test/cluster/storage_wipe_test.go @@ -140,50 +140,6 @@ var _ = Describe( ) } - By( - fmt.Sprintf( - "Downgrading image from %s to %s - volumes should be wiped", - version6, pre6Version, - ), - ) - err = UpdateClusterImage(aeroCluster, pre6Image) - Expect(err).ToNot(HaveOccurred()) - err = aerospikeClusterCreateUpdate( - k8sClient, aeroCluster, ctx, - ) - Expect(err).ToNot(HaveOccurred()) - - aeroCluster, err = getCluster( - k8sClient, ctx, clusterNamespacedName, - ) - Expect(err).ToNot(HaveOccurred()) - - By("Checking - unrelated volume attachments should not be wiped") - err = checkData( - aeroCluster, true, true, map[string]struct{}{ - "test-wipe-device-dd-1": {}, - "test-wipe-device-blkdiscard-1": {}, - "test-wipe-device-dd-2": {}, - "test-wipe-device-blkdiscard-2": {}, - "test-wipe-files-deletefiles-2": {}, - }, - ) - Expect(err).ToNot(HaveOccurred()) - - By("Checking - cluster data should be wiped") - records, err = CheckDataInCluster( - aeroCluster, k8sClient, namespaces, - ) - Expect(err).ToNot(HaveOccurred()) - - for namespace, recordExists := range records { - Expect(recordExists).To( - BeFalse(), fmt.Sprintf( - "Namespace: %s - should have records", - namespace, - ), - ) - } err = deleteCluster(k8sClient, ctx, aeroCluster) Expect(err).ToNot(HaveOccurred()) diff --git a/test/cluster/utils.go b/test/cluster/utils.go index 628eff506..c9f2329f2 100644 --- a/test/cluster/utils.go +++ b/test/cluster/utils.go @@ -243,42 +243,19 @@ func (acs *AerospikeConfSpec) getVersion() string { return acs.version } -func (acs *AerospikeConfSpec) setEnableSecurity(enableSecurity bool) error { - cmpVal, err := lib.CompareVersions(acs.version, "5.7.0") - if err != nil { - return err - } - - if cmpVal >= 0 { - if enableSecurity { - security := map[string]interface{}{} - acs.security = security - } - - return nil +func (acs *AerospikeConfSpec) setEnableSecurity(enableSecurity bool) { + if enableSecurity { + security := map[string]interface{}{} + acs.security = security } - - acs.security = map[string]interface{}{} - acs.security["enable-security"] = enableSecurity - - return nil } -func (acs *AerospikeConfSpec) setEnableQuotas(enableQuotas bool) error { - cmpVal, err := lib.CompareVersions(acs.version, "5.6.0") - if err != nil { - return err - } - - if cmpVal >= 0 { - if acs.security == nil { - acs.security = map[string]interface{}{} - } - - acs.security["enable-quotas"] = enableQuotas +func (acs *AerospikeConfSpec) setEnableQuotas(enableQuotas bool) { + if acs.security == nil { + acs.security = map[string]interface{}{} } - return nil + acs.security["enable-quotas"] = enableQuotas } func (acs *AerospikeConfSpec) getSpec() map[string]interface{} { @@ -406,7 +383,7 @@ func getAeroClusterConfig( return nil, err } - cmpVal1, err := lib.CompareVersions(version, "5.7.0") + cmpVal1, err := lib.CompareVersions(version, "6.0.0") if err != nil { return nil, err } @@ -423,12 +400,7 @@ func getAeroClusterConfig( ), nil case cmpVal1 >= 0: - return createAerospikeClusterPost560( - namespace, 2, image, - ), nil - - case cmpVal1 < 0: - return createAerospikeClusterPost460( + return createAerospikeClusterPost570( namespace, 2, image, ), nil