Skip to content

Commit

Permalink
disallow operation modification
Browse files Browse the repository at this point in the history
  • Loading branch information
tanmayja committed Jun 11, 2024
1 parent 1a518c5 commit ebcf676
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions api/v1/aerospikecluster_validating_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down
28 changes: 28 additions & 0 deletions test/on_demand_operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit ebcf676

Please sign in to comment.