diff --git a/Jenkinsfile b/Jenkinsfile index ce22b6f60..2a82e282b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -80,8 +80,8 @@ pipeline { sh "./snyk-linux test --severity-threshold=high --fail-on=all" // Scan the operator images - sh "./snyk-linux container test ${OPERATOR_CONTAINER_IMAGE_CANDIDATE_NAME} --severity-threshold=high --file=Dockerfile --policy-path=.snyk --fail-on=all" - sh "./snyk-linux container test ${OPERATOR_BUNDLE_IMAGE_CANDIDATE_NAME} --severity-threshold=high --file=Dockerfile --policy-path=.snyk --fail-on=all" + sh "./snyk-linux container test ${OPERATOR_CONTAINER_IMAGE_CANDIDATE_NAME} --severity-threshold=high --file=Dockerfile --policy-path=.snyk --fail-on=all" + sh "./snyk-linux container test ${OPERATOR_BUNDLE_IMAGE_CANDIDATE_NAME} --severity-threshold=high --file=Dockerfile --policy-path=.snyk --fail-on=all" } } } diff --git a/api/v1/aerospikecluster_mutating_webhook.go b/api/v1/aerospikecluster_mutating_webhook.go index 9d80af0a5..e482d5e7f 100644 --- a/api/v1/aerospikecluster_mutating_webhook.go +++ b/api/v1/aerospikecluster_mutating_webhook.go @@ -858,13 +858,13 @@ func setNamespaceDefault(networks []string, namespace string) { func setDefaultOperation(operations *[]OperationSpec) error { for i := range *operations { - if (*operations)[i].OperationID == "" { + if (*operations)[i].ID == "" { id, err := randomString(5) if err != nil { return err } - (*operations)[i].OperationID = id + (*operations)[i].ID = id } } diff --git a/api/v1/aerospikecluster_types.go b/api/v1/aerospikecluster_types.go index 97132fd19..c8380fa58 100644 --- a/api/v1/aerospikecluster_types.go +++ b/api/v1/aerospikecluster_types.go @@ -124,30 +124,31 @@ type AerospikeClusterSpec struct { //nolint:govet // for readability // +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Kubernetes Node BlockList" // +kubebuilder:validation:MinItems:=1 K8sNodeBlockList []string `json:"k8sNodeBlockList,omitempty"` - // Operations is a list of on demand operation to be performed on the Aerospike cluster. + // Operations is a list of on-demand operations to be performed on the Aerospike cluster. // +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Operations" + // +kubebuilder:validation:MaxItems:=1 Operations []OperationSpec `json:"operations,omitempty"` } -type OperationType string +type OperationKind string const ( - // OperationQuickRestart specifies the on demand operation is quick restart of aerospike pods. - OperationQuickRestart OperationType = "quickRestart" + // OperationWarmRestart is the on-demand operation that leads to the warm restart of the aerospike pods + // (Restarting ASD in the pods). https://aerospike.com/docs/cloud/kubernetes/operator/Warm-restart + OperationWarmRestart OperationKind = "WarmRestart" - // OperationPodRestart specifies the on demand operation is cold restart of aerospike pods. - OperationPodRestart OperationType = "podRestart" + // OperationPodRestart is the on-demand operation that leads to the restart of aerospike pods. + OperationPodRestart OperationKind = "PodRestart" ) type OperationSpec struct { - // OperationType is the type of operation to be performed on the Aerospike cluster. - // +kubebuilder:validation:Enum=quickRestart;podRestart - OperationType OperationType `json:"operationType"` - // +kubebuilder:validation:MaxLength=5 - // +kubebuilder:validation:MinLength=5 + // OperationKind is the type of operation to be performed on the Aerospike cluster. + // +kubebuilder:validation:Enum=WarmRestart;PodRestart + Kind OperationKind `json:"kind"` + // +kubebuilder:validation:MaxLength=20 // +optional - OperationID string `json:"operationID"` - PodList []string `json:"podList,omitempty"` + ID string `json:"id"` + PodList []string `json:"podList,omitempty"` } type SeedsFinderServices struct { @@ -723,7 +724,7 @@ type AerospikeClusterStatusSpec struct { //nolint:govet // for readability RosterNodeBlockList []string `json:"rosterNodeBlockList,omitempty"` // K8sNodeBlockList is a list of Kubernetes nodes which are not used for Aerospike pods. K8sNodeBlockList []string `json:"k8sNodeBlockList,omitempty"` - // Operations is a list of on demand operation to be performed on the Aerospike cluster. + // Operations is a list of on-demand operation to be performed on the Aerospike cluster. Operations []OperationSpec `json:"operations,omitempty"` } @@ -1071,9 +1072,9 @@ func CopySpecToStatus(spec *AerospikeClusterSpec) (*AerospikeClusterStatusSpec, } if len(spec.Operations) != 0 { - operation := lib.DeepCopy(&spec.Operations).(*[]OperationSpec) + operations := lib.DeepCopy(&spec.Operations).(*[]OperationSpec) - status.Operations = *operation + status.Operations = *operations } return &status, nil @@ -1176,8 +1177,8 @@ func CopyStatusToSpec(status *AerospikeClusterStatusSpec) (*AerospikeClusterSpec } if len(status.Operations) != 0 { - operation := lib.DeepCopy(&status.Operations).(*[]OperationSpec) - spec.Operations = *operation + operations := lib.DeepCopy(&status.Operations).(*[]OperationSpec) + spec.Operations = *operations } return &spec, nil diff --git a/api/v1/aerospikecluster_validating_webhook.go b/api/v1/aerospikecluster_validating_webhook.go index f63b325e0..8f8b0e1f2 100644 --- a/api/v1/aerospikecluster_validating_webhook.go +++ b/api/v1/aerospikecluster_validating_webhook.go @@ -280,25 +280,21 @@ func (c *AerospikeCluster) validateOperation() error { } if c.Status.AerospikeConfig == nil { - return fmt.Errorf("operation cannot be set on create") + return fmt.Errorf("operation cannot be added during aerospike cluster creation") } - if len(c.Spec.Operations) > 1 { - return fmt.Errorf("only one operation can be set at a time") - } - - allPodNames := GetAllPodNames(c.Name, c.Spec.Size, c.Spec.RackConfig.Racks) + allPodNames := GetAllPodNames(c.Status.Pods) - podSet := sets.NewString(c.Spec.Operations[0].PodList...) - if !allPodNames.IsSuperset(sets.Set[string](podSet)) { - return fmt.Errorf("invalid pod name in operation") + podSet := sets.New(c.Spec.Operations[0].PodList...) + if !allPodNames.IsSuperset(podSet) { + return fmt.Errorf("invalid pod names in operation %v", podSet.Difference(allPodNames).UnsortedList()) } // Don't allow any operation along with cluster scale up or racks added or removed // New pods won't be available for operation if !reflect.DeepEqual(c.Spec.Operations, c.Status.Operations) && (c.Spec.Size > c.Status.Size || len(c.Spec.RackConfig.Racks) != len(c.Status.RackConfig.Racks)) { - return fmt.Errorf("cannot perform any on demand operation along with cluster scale up or racks added or removed") + return fmt.Errorf("cannot perform any on-demand operation along with cluster scale-up or rack addition/removal") } return nil @@ -1333,20 +1329,22 @@ func validateSecurityConfigUpdate( func validateEnableSecurityConfig(newConfSpec, oldConfSpec *AerospikeConfigSpec) error { newConf := newConfSpec.Value oldConf := oldConfSpec.Value + oldSec, oldSecConfFound := oldConf["security"] - newSec, newSecConfFound := newConf["security"] + if !oldSecConfFound { + return nil + } - if oldSecConfFound && !newSecConfFound { + newSec, newSecConfFound := newConf["security"] + if !newSecConfFound { return fmt.Errorf("cannot remove cluster security config") } - if oldSecConfFound { - oldSecFlag, oldEnableSecurityFlagFound := oldSec.(map[string]interface{})["enable-security"] - newSecFlag, newEnableSecurityFlagFound := newSec.(map[string]interface{})["enable-security"] + 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") - } + if oldEnableSecurityFlagFound && oldSecFlag.(bool) && (!newEnableSecurityFlagFound || !newSecFlag.(bool)) { + return fmt.Errorf("cannot disable cluster security in running cluster") } return nil @@ -2401,25 +2399,16 @@ func (c *AerospikeCluster) validateEnableDynamicConfigUpdate() error { return nil } -func validateOperationUpdate(oldOp, newOp *[]OperationSpec) error { - // Define a key extractor function - keyExtractor := func(op OperationSpec) string { - return op.OperationID +func validateOperationUpdate(oldOps, newOps *[]OperationSpec) error { + if len(*oldOps) == 0 || len(*newOps) == 0 { + return nil } - // Convert the array of structs to a map - oldOpMap, err := ConvertToMap(*oldOp, keyExtractor) - if err != nil { - return err - } + oldOp := (*oldOps)[0] + newOp := (*newOps)[0] - for idx := range *newOp { - key := (*newOp)[idx].OperationID - if _, ok := oldOpMap[key]; ok { - if !reflect.DeepEqual(oldOpMap[key], (*newOp)[idx]) { - return fmt.Errorf("operation %s cannot be updated", key) - } - } + if oldOp.ID == newOp.ID && !reflect.DeepEqual(oldOp, newOp) { + return fmt.Errorf("operation %s cannot be updated", newOp.ID) } return nil diff --git a/api/v1/utils.go b/api/v1/utils.go index bf848eadb..d00b5f55c 100644 --- a/api/v1/utils.go +++ b/api/v1/utils.go @@ -7,7 +7,6 @@ import ( "math/big" "os" "regexp" - "strconv" "strings" "k8s.io/apimachinery/pkg/util/sets" @@ -591,31 +590,11 @@ func DistributeItems(totalItems, totalGroups int) []int { return topology } -func ConvertToMap[T any](items []T, keyExtractor func(T) string) (map[string]T, error) { - itemMap := make(map[string]T) - - for _, item := range items { - key := keyExtractor(item) - if _, ok := itemMap[key]; ok { - return nil, fmt.Errorf("duplicate key %s", key) - } - - itemMap[key] = item - } - - return itemMap, nil -} - -func GetAllPodNames(clusterName string, clusterSize int32, racks []Rack) sets.Set[string] { +func GetAllPodNames(pods map[string]AerospikePodStatus) sets.Set[string] { podNames := make(sets.Set[string]) - topology := DistributeItems( - int(clusterSize), len(racks), - ) - for idx := range racks { - for i := 0; i < topology[idx]; i++ { - podNames.Insert(fmt.Sprintf("%s-%s-%d", clusterName, strconv.Itoa(racks[idx].ID), i)) - } + for podName := range pods { + podNames.Insert(podName) } return podNames diff --git a/config/crd/bases/asdb.aerospike.com_aerospikeclusters.yaml b/config/crd/bases/asdb.aerospike.com_aerospikeclusters.yaml index 8e9792a0a..78f31d1a5 100644 --- a/config/crd/bases/asdb.aerospike.com_aerospikeclusters.yaml +++ b/config/crd/bases/asdb.aerospike.com_aerospikeclusters.yaml @@ -313,28 +313,28 @@ spec: Refer Aerospike documentation for more details. x-kubernetes-int-or-string: true operations: - description: Operations is a list of on demand operation to be performed + description: Operations is a list of on-demand operations to be performed on the Aerospike cluster. items: properties: - operationID: - maxLength: 5 - minLength: 5 + id: + maxLength: 20 type: string - operationType: - description: OperationType is the type of operation to be performed + kind: + description: OperationKind is the type of operation to be performed on the Aerospike cluster. enum: - - quickRestart - - podRestart + - WarmRestart + - PodRestart type: string podList: items: type: string type: array required: - - operationType + - kind type: object + maxItems: 1 type: array operatorClientCert: description: Certificates to connect to Aerospike. @@ -9676,27 +9676,26 @@ spec: now part of podSpec" type: boolean operations: - description: Operations is a list of on demand operation to be performed + description: Operations is a list of on-demand operation to be performed on the Aerospike cluster. items: properties: - operationID: - maxLength: 5 - minLength: 5 + id: + maxLength: 20 type: string - operationType: - description: OperationType is the type of operation to be performed + kind: + description: OperationKind is the type of operation to be performed on the Aerospike cluster. enum: - - quickRestart - - podRestart + - WarmRestart + - PodRestart type: string podList: items: type: string type: array required: - - operationType + - kind type: object type: array operatorClientCertSpec: diff --git a/config/manifests/bases/aerospike-kubernetes-operator.clusterserviceversion.yaml b/config/manifests/bases/aerospike-kubernetes-operator.clusterserviceversion.yaml index 21abb5dc6..964726d13 100644 --- a/config/manifests/bases/aerospike-kubernetes-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/aerospike-kubernetes-operator.clusterserviceversion.yaml @@ -71,8 +71,8 @@ spec: for more details. displayName: Max Unavailable path: maxUnavailable - - description: Operations is a list of on demand operation to be performed on - the Aerospike cluster. + - description: Operations is a list of on-demand operations to be performed + on the Aerospike cluster. displayName: Operations path: operations - description: Certificates to connect to Aerospike. diff --git a/controllers/pod.go b/controllers/pod.go index 2c1f11f30..37aa6451f 100644 --- a/controllers/pod.go +++ b/controllers/pod.go @@ -221,11 +221,11 @@ func (r *SingleClusterReconciler) getRollingRestartTypePod( "newTCPPort", r.getReadinessProbe().TCPSocket.String()) } - if op := r.onDemandOperationType(pod.Name); op != noRestart { - restartType = mergeRestartType(restartType, op) + if opType := r.onDemandOperationType(pod.Name); opType != noRestart { + restartType = mergeRestartType(restartType, opType) - r.Log.Info("Pod warm/cold restarted requested. Need rolling restart", - "pod name", pod.Name, "operation", op, "restartType", restartType) + r.Log.Info("Pod warm/cold restart requested. Need rolling restart", + "pod name", pod.Name, "operation", opType, "restartType", restartType) } return restartType @@ -375,9 +375,9 @@ func (r *SingleClusterReconciler) restartPods( restartType := restartTypeMap[pod.Name] if restartType == quickRestart { - // If ASD restart fails, then go ahead and restart the pod + // We assume that the pod server image supports pod warm restart. if err := r.restartASDOrUpdateAerospikeConf(pod.Name, quickRestart); err != nil { - r.Log.Error(err, "Failed to restart asd pod") + r.Log.Error(err, "Failed to warm restart pod", "podName", pod.Name) return reconcileError(err) } @@ -1487,7 +1487,7 @@ func (r *SingleClusterReconciler) patchPodStatus(ctx context.Context, patches [] } func (r *SingleClusterReconciler) onDemandOperationType(podName string) RestartType { - allPodNames := asdbv1.GetAllPodNames(r.aeroCluster.Name, r.aeroCluster.Spec.Size, r.aeroCluster.Spec.RackConfig.Racks) + allPodNames := asdbv1.GetAllPodNames(r.aeroCluster.Status.Pods) quickRestarts, podRestarts := utils.PodsToRestart(r.aeroCluster.Spec.Operations, r.aeroCluster.Status.Operations, allPodNames) @@ -1501,25 +1501,17 @@ func (r *SingleClusterReconciler) onDemandOperationType(podName string) RestartT return noRestart } -func (r *SingleClusterReconciler) updateOperationStatus(quickRestarts, podRestarts []string) error { - if len(quickRestarts)+len(podRestarts) == 0 || len(r.aeroCluster.Spec.Operations) == 0 { +func (r *SingleClusterReconciler) updateOperationStatus(restartedASDPodNames, restartedPodNames []string) error { + if len(restartedASDPodNames)+len(restartedPodNames) == 0 || len(r.aeroCluster.Spec.Operations) == 0 { return nil } - // Define a key extractor function - keyExtractor := func(op asdbv1.OperationSpec) string { - return op.OperationID - } - - statusOpsMap, err := asdbv1.ConvertToMap(r.aeroCluster.Status.Operations, keyExtractor) - if err != nil { - return err - } + statusOps := lib.DeepCopy(r.aeroCluster.Status.Operations).([]asdbv1.OperationSpec) - allPodNames := asdbv1.GetAllPodNames(r.aeroCluster.Name, r.aeroCluster.Spec.Size, r.aeroCluster.Spec.RackConfig.Racks) + allPodNames := asdbv1.GetAllPodNames(r.aeroCluster.Status.Pods) - quickRestartsSet := sets.New[string](quickRestarts...) - podRestartsSet := sets.New[string](podRestarts...) + quickRestartsSet := sets.New(restartedASDPodNames...) + podRestartsSet := sets.New(restartedPodNames...) specOp := r.aeroCluster.Spec.Operations[0] @@ -1529,45 +1521,48 @@ func (r *SingleClusterReconciler) updateOperationStatus(quickRestarts, podRestar if len(specOp.PodList) == 0 { specPods = allPodNames } else { - specPods = sets.New[string](specOp.PodList...) + specPods = sets.New(specOp.PodList...) } - if statusOp, exists := statusOpsMap[specOp.OperationID]; !exists { - var podList []string + opFound := false - if specOp.OperationType == asdbv1.OperationQuickRestart && quickRestartsSet != nil { - podList = quickRestartsSet.Intersection(specPods).UnsortedList() - } + for idx := range statusOps { + statusOp := &statusOps[idx] + if statusOp.ID == specOp.ID { + opFound = true - if specOp.OperationType == asdbv1.OperationPodRestart && podRestartsSet != nil { - podList = podRestartsSet.Intersection(specPods).UnsortedList() - } + if len(statusOp.PodList) != 0 { + statusPods := sets.New(statusOp.PodList...) - statusOpsMap[specOp.OperationID] = asdbv1.OperationSpec{ - OperationID: specOp.OperationID, - OperationType: specOp.OperationType, - PodList: podList, - } - } else if len(statusOp.PodList) != 0 { - statusPods := sets.New[string](statusOp.PodList...) + if statusOp.Kind == asdbv1.OperationWarmRestart && quickRestartsSet != nil { + statusOp.PodList = append(statusOp.PodList, quickRestartsSet.Intersection(specPods). + Difference(statusPods).UnsortedList()...) + } - if statusOp.OperationType == asdbv1.OperationQuickRestart && quickRestartsSet != nil { - statusOp.PodList = append(statusOp.PodList, quickRestartsSet.Intersection(specPods). - Difference(statusPods).UnsortedList()...) + if statusOp.Kind == asdbv1.OperationPodRestart && podRestartsSet != nil { + statusOp.PodList = append(statusOp.PodList, podRestartsSet.Intersection(specPods). + Difference(statusPods).UnsortedList()...) + } + } } + } + + if !opFound { + var podList []string - if statusOp.OperationType == asdbv1.OperationPodRestart && podRestartsSet != nil { - statusOp.PodList = append(statusOp.PodList, podRestartsSet.Intersection(specPods). - Difference(statusPods).UnsortedList()...) + if specOp.Kind == asdbv1.OperationWarmRestart && quickRestartsSet != nil { + podList = quickRestartsSet.Intersection(specPods).UnsortedList() } - statusOpsMap[specOp.OperationID] = statusOp - } + if specOp.Kind == asdbv1.OperationPodRestart && podRestartsSet != nil { + podList = podRestartsSet.Intersection(specPods).UnsortedList() + } - // Convert statusOperation map back to a slice - updatedStatusOperation := make([]asdbv1.OperationSpec, 0, len(statusOpsMap)) - for _, statusOp := range statusOpsMap { - updatedStatusOperation = append(updatedStatusOperation, statusOp) + statusOps = append(statusOps, asdbv1.OperationSpec{ + ID: specOp.ID, + Kind: specOp.Kind, + PodList: podList, + }) } // Get the old object, it may have been updated in between. @@ -1580,7 +1575,7 @@ func (r *SingleClusterReconciler) updateOperationStatus(quickRestarts, podRestar return err } - newAeroCluster.Status.Operations = updatedStatusOperation + newAeroCluster.Status.Operations = statusOps if err := r.patchStatus(newAeroCluster); err != nil { return fmt.Errorf("error updating status: %w", err) diff --git a/helm-charts/aerospike-kubernetes-operator/crds/customresourcedefinition_aerospikeclusters.asdb.aerospike.com.yaml b/helm-charts/aerospike-kubernetes-operator/crds/customresourcedefinition_aerospikeclusters.asdb.aerospike.com.yaml index 8e9792a0a..78f31d1a5 100644 --- a/helm-charts/aerospike-kubernetes-operator/crds/customresourcedefinition_aerospikeclusters.asdb.aerospike.com.yaml +++ b/helm-charts/aerospike-kubernetes-operator/crds/customresourcedefinition_aerospikeclusters.asdb.aerospike.com.yaml @@ -313,28 +313,28 @@ spec: Refer Aerospike documentation for more details. x-kubernetes-int-or-string: true operations: - description: Operations is a list of on demand operation to be performed + description: Operations is a list of on-demand operations to be performed on the Aerospike cluster. items: properties: - operationID: - maxLength: 5 - minLength: 5 + id: + maxLength: 20 type: string - operationType: - description: OperationType is the type of operation to be performed + kind: + description: OperationKind is the type of operation to be performed on the Aerospike cluster. enum: - - quickRestart - - podRestart + - WarmRestart + - PodRestart type: string podList: items: type: string type: array required: - - operationType + - kind type: object + maxItems: 1 type: array operatorClientCert: description: Certificates to connect to Aerospike. @@ -9676,27 +9676,26 @@ spec: now part of podSpec" type: boolean operations: - description: Operations is a list of on demand operation to be performed + description: Operations is a list of on-demand operation to be performed on the Aerospike cluster. items: properties: - operationID: - maxLength: 5 - minLength: 5 + id: + maxLength: 20 type: string - operationType: - description: OperationType is the type of operation to be performed + kind: + description: OperationKind is the type of operation to be performed on the Aerospike cluster. enum: - - quickRestart - - podRestart + - WarmRestart + - PodRestart type: string podList: items: type: string type: array required: - - operationType + - kind type: object type: array operatorClientCertSpec: diff --git a/pkg/utils/pod.go b/pkg/utils/pod.go index 8f52bba7a..d2c99e22b 100644 --- a/pkg/utils/pod.go +++ b/pkg/utils/pod.go @@ -224,20 +224,8 @@ func PodsToRestart(specOps, statusOps []asdbv1.OperationSpec, allPodNames sets.S return quickRestarts, podRestarts } - // Define a key extractor function - keyExtractor := func(op asdbv1.OperationSpec) string { - return op.OperationID - } - - // Ignoring duplicate key error as the operationID will always be unique in status. - statusOpsMap, _ := asdbv1.ConvertToMap(statusOps, keyExtractor) - // Assuming only one operation is present in the spec. specOp := specOps[0] - // If the operation is not a quick restart or pod restart, no pods need to be restarted. - if specOp.OperationType != asdbv1.OperationQuickRestart && specOp.OperationType != asdbv1.OperationPodRestart { - return quickRestarts, podRestarts - } var ( podsToRestart, specPods sets.Set[string] @@ -246,29 +234,40 @@ func PodsToRestart(specOps, statusOps []asdbv1.OperationSpec, allPodNames sets.S if len(specOp.PodList) == 0 { specPods = allPodNames } else { - specPods = sets.New[string](specOp.PodList...) + specPods = sets.New(specOp.PodList...) } + opFound := false + // If the operation is not present in the status, all pods need to be restarted. // If the operation is present in the status, only the pods that are not present in the status need to be restarted. // If the operation is present in the status and podList is empty, no pods need to be restarted. - if statusOp, exists := statusOpsMap[specOp.OperationID]; !exists { - podsToRestart = specPods - } else { + for _, statusOp := range statusOps { + if statusOp.ID != specOp.ID { + continue + } + var statusPods sets.Set[string] if len(statusOp.PodList) == 0 { statusPods = allPodNames } else { - statusPods = sets.New[string](statusOp.PodList...) + statusPods = sets.New(statusOp.PodList...) } podsToRestart = specPods.Difference(statusPods) + opFound = true + + break + } + + if !opFound { + podsToRestart = specPods } // Separate pods to be restarted based on operation type if podsToRestart != nil && podsToRestart.Len() > 0 { - switch specOp.OperationType { - case asdbv1.OperationQuickRestart: + switch specOp.Kind { + case asdbv1.OperationWarmRestart: quickRestarts.Insert(podsToRestart.UnsortedList()...) case asdbv1.OperationPodRestart: podRestarts.Insert(podsToRestart.UnsortedList()...) diff --git a/test/access_control_test.go b/test/access_control_test.go index 78e2cf495..0a20680d1 100644 --- a/test/access_control_test.go +++ b/test/access_control_test.go @@ -2236,6 +2236,13 @@ var _ = Describe( k8sClient, ctx, clusterNamespacedName, 1, ) Expect(err).ToNot(HaveOccurred()) + + if aeroCluster != nil { + err = deleteCluster( + k8sClient, ctx, aeroCluster, + ) + Expect(err).ToNot(HaveOccurred()) + } }) }) }, diff --git a/test/cluster_test.go b/test/cluster_test.go index bc7b236ea..f9075cbd5 100644 --- a/test/cluster_test.go +++ b/test/cluster_test.go @@ -280,7 +280,7 @@ func clusterWithMaxIgnorablePod(ctx goctx.Context) { operations := []asdbv1.OperationSpec{ { - OperationType: asdbv1.OperationQuickRestart, + Kind: asdbv1.OperationWarmRestart, }, } aeroCluster.Spec.Operations = operations diff --git a/test/on_demand_operations_test.go b/test/on_demand_operations_test.go index 990a9c61d..42f3ed302 100644 --- a/test/on_demand_operations_test.go +++ b/test/on_demand_operations_test.go @@ -54,7 +54,7 @@ var _ = Describe( operations := []asdbv1.OperationSpec{ { - OperationType: asdbv1.OperationQuickRestart, + Kind: asdbv1.OperationWarmRestart, }, } @@ -68,9 +68,9 @@ var _ = Describe( ) Expect(err).ToNot(HaveOccurred()) - operationTypeMap := map[string]asdbv1.OperationType{ - "operations-1-0": asdbv1.OperationQuickRestart, - "operations-1-1": asdbv1.OperationQuickRestart, + operationTypeMap := map[string]asdbv1.OperationKind{ + "operations-1-0": asdbv1.OperationWarmRestart, + "operations-1-1": asdbv1.OperationWarmRestart, } err = validateOperationTypes(ctx, aeroCluster, oldPodIDs, operationTypeMap) @@ -90,7 +90,7 @@ var _ = Describe( operations := []asdbv1.OperationSpec{ { - OperationType: asdbv1.OperationPodRestart, + Kind: asdbv1.OperationPodRestart, }, } @@ -104,7 +104,7 @@ var _ = Describe( ) Expect(err).ToNot(HaveOccurred()) - operationTypeMap := map[string]asdbv1.OperationType{ + operationTypeMap := map[string]asdbv1.OperationKind{ "operations-1-0": asdbv1.OperationPodRestart, "operations-1-1": asdbv1.OperationPodRestart, } @@ -126,8 +126,8 @@ var _ = Describe( operations := []asdbv1.OperationSpec{ { - OperationType: asdbv1.OperationPodRestart, - PodList: []string{"operations-1-0"}, + Kind: asdbv1.OperationPodRestart, + PodList: []string{"operations-1-0"}, }, } @@ -143,7 +143,7 @@ var _ = Describe( ) Expect(err).ToNot(HaveOccurred()) - operationTypeMap := map[string]asdbv1.OperationType{ + operationTypeMap := map[string]asdbv1.OperationKind{ "operations-1-0": asdbv1.OperationPodRestart, "operations-1-1": "noRestart", } @@ -175,7 +175,7 @@ var _ = Describe( operations := []asdbv1.OperationSpec{ { - OperationType: asdbv1.OperationPodRestart, + Kind: asdbv1.OperationPodRestart, }, } @@ -190,7 +190,7 @@ var _ = Describe( ) Expect(err).ToNot(HaveOccurred()) - operationTypeMap := map[string]asdbv1.OperationType{ + operationTypeMap := map[string]asdbv1.OperationKind{ "operations-1-0": asdbv1.OperationPodRestart, "operations-1-1": asdbv1.OperationPodRestart, } @@ -212,7 +212,7 @@ var _ = Describe( operations := []asdbv1.OperationSpec{ { - OperationType: asdbv1.OperationQuickRestart, + Kind: asdbv1.OperationWarmRestart, }, } @@ -227,7 +227,7 @@ var _ = Describe( ) Expect(err).ToNot(HaveOccurred()) - operationTypeMap := map[string]asdbv1.OperationType{ + operationTypeMap := map[string]asdbv1.OperationKind{ "operations-1-0": asdbv1.OperationPodRestart, "operations-1-1": asdbv1.OperationPodRestart, } @@ -250,10 +250,10 @@ var _ = Describe( operations := []asdbv1.OperationSpec{ { - OperationType: asdbv1.OperationQuickRestart, + Kind: asdbv1.OperationWarmRestart, }, { - OperationType: asdbv1.OperationPodRestart, + Kind: asdbv1.OperationPodRestart, }, } @@ -273,8 +273,8 @@ var _ = Describe( operations := []asdbv1.OperationSpec{ { - OperationType: asdbv1.OperationQuickRestart, - PodList: []string{"operations-1-0", "invalid-pod"}, + Kind: asdbv1.OperationWarmRestart, + PodList: []string{"operations-1-0", "invalid-pod"}, }, } @@ -294,8 +294,8 @@ var _ = Describe( operations := []asdbv1.OperationSpec{ { - OperationType: asdbv1.OperationQuickRestart, - PodList: []string{"operations-1-0"}, + Kind: asdbv1.OperationWarmRestart, + PodList: []string{"operations-1-0"}, }, } @@ -305,7 +305,7 @@ var _ = Describe( Expect(err).ToNot(HaveOccurred()) // Modify operationType - operations[0].OperationType = asdbv1.OperationPodRestart + operations[0].Kind = asdbv1.OperationPodRestart aeroCluster.Spec.Operations = operations err = updateCluster(k8sClient, ctx, aeroCluster) @@ -322,8 +322,8 @@ var _ = Describe( operations := []asdbv1.OperationSpec{ { - OperationType: asdbv1.OperationQuickRestart, - PodList: []string{"operations-1-0"}, + Kind: asdbv1.OperationWarmRestart, + PodList: []string{"operations-1-0"}, }, } @@ -350,8 +350,8 @@ var _ = Describe( operations := []asdbv1.OperationSpec{ { - OperationType: asdbv1.OperationQuickRestart, - PodList: []string{"operations-1-0"}, + Kind: asdbv1.OperationWarmRestart, + PodList: []string{"operations-1-0"}, }, } @@ -368,13 +368,13 @@ var _ = Describe( ) func validateOperationTypes(ctx goctx.Context, aeroCluster *asdbv1.AerospikeCluster, pid map[string]podID, - operationTypeMap map[string]asdbv1.OperationType) error { + operationTypeMap map[string]asdbv1.OperationKind) error { newPodPidMap, err := getPodIDs(ctx, aeroCluster) Expect(err).ToNot(HaveOccurred()) for podName, opType := range operationTypeMap { switch opType { - case asdbv1.OperationQuickRestart: + case asdbv1.OperationWarmRestart: if newPodPidMap[podName].podUID != pid[podName].podUID || newPodPidMap[podName].asdPID == pid[podName].asdPID { return fmt.Errorf("failed to quick restart pod %s", podName) }