diff --git a/api/v1/aerospikecluster_validating_webhook.go b/api/v1/aerospikecluster_validating_webhook.go index c63e7c81d..f63b325e0 100644 --- a/api/v1/aerospikecluster_validating_webhook.go +++ b/api/v1/aerospikecluster_validating_webhook.go @@ -2416,8 +2416,8 @@ func validateOperationUpdate(oldOp, newOp *[]OperationSpec) error { for idx := range *newOp { key := (*newOp)[idx].OperationID if _, ok := oldOpMap[key]; ok { - if oldOpMap[key].OperationType != (*newOp)[idx].OperationType { - return fmt.Errorf("operation type of existing operation %s cannot be updated", key) + if !reflect.DeepEqual(oldOpMap[key], (*newOp)[idx]) { + return fmt.Errorf("operation %s cannot be updated", key) } } } diff --git a/test/on_demand_operations_test.go b/test/on_demand_operations_test.go index bfd981bf9..990a9c61d 100644 --- a/test/on_demand_operations_test.go +++ b/test/on_demand_operations_test.go @@ -313,6 +313,34 @@ var _ = Describe( }, ) + It( + "should fail if podList is modified", func() { + aeroCluster, err := getCluster( + k8sClient, ctx, clusterNamespacedName, + ) + Expect(err).ToNot(HaveOccurred()) + + operations := []asdbv1.OperationSpec{ + { + OperationType: asdbv1.OperationQuickRestart, + PodList: []string{"operations-1-0"}, + }, + } + + aeroCluster.Spec.Operations = operations + + err = updateCluster(k8sClient, ctx, aeroCluster) + Expect(err).ToNot(HaveOccurred()) + + // Modify podList + operations[0].PodList = []string{"operations-1-1"} + aeroCluster.Spec.Operations = operations + + err = updateCluster(k8sClient, ctx, aeroCluster) + Expect(err).To(HaveOccurred()) + }, + ) + It( "should fail any operation along with cluster scale-up", func() { aeroCluster, err := getCluster(