Skip to content

Commit

Permalink
adding comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tanmayja committed Jul 8, 2024
1 parent 8072ba8 commit 782b079
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
6 changes: 3 additions & 3 deletions api/v1/aerospikecluster_validating_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -2417,12 +2417,12 @@ func validateOperationUpdate(oldSpec, newSpec *AerospikeClusterSpec, status *Aer
if !reflect.DeepEqual(newSpec.Operations, status.Operations) {
switch {
case newSpec.Size > status.Size:
return fmt.Errorf("cannot perform any on-demand operation along with cluster scale-up")
return fmt.Errorf("cannot change Spec.Operations along with cluster scale-up")
case len(newSpec.RackConfig.Racks) != len(status.RackConfig.Racks) ||
len(newSpec.RackConfig.Racks) != len(oldSpec.RackConfig.Racks):
return fmt.Errorf("cannot perform any on-demand operation along with rack addition/removal")
return fmt.Errorf("cannot change Spec.Operations along with rack addition/removal")
case newSpec.Image != status.Image || newSpec.Image != oldSpec.Image:
return fmt.Errorf("cannot perform any on-demand operation along with image update")
return fmt.Errorf("cannot change Spec.Operations along with image update")
}
}

Expand Down
4 changes: 4 additions & 0 deletions controllers/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -1541,6 +1541,8 @@ func (r *SingleClusterReconciler) updateOperationStatus(restartedASDPodNames, re
statusOp.PodList = statusPods.Union(quickRestartsSet.Intersection(specPods)).UnsortedList()
}

// If the operation is a warm restart and the pod undergoes a cold restart for any reason,
// we will still consider the warm restart operation as completed for that pod.
if podRestartsSet != nil {
statusOp.PodList = statusPods.Union(podRestartsSet.Intersection(specPods)).UnsortedList()
}
Expand All @@ -1563,6 +1565,8 @@ func (r *SingleClusterReconciler) updateOperationStatus(restartedASDPodNames, re
podList = quickRestartsSet.Intersection(specPods).UnsortedList()
}

// If the operation is a warm restart and the pod undergoes a cold restart for any reason,
// we will still consider the warm restart operation as completed for that pod.
if podRestartsSet != nil {
podList = append(podList, podRestartsSet.Intersection(specPods).UnsortedList()...)
}
Expand Down
8 changes: 4 additions & 4 deletions test/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func clusterWithMaxIgnorablePod(ctx goctx.Context) {
aeroCluster.Spec.RackConfig.MaxIgnorablePods = &val
aeroCluster.Spec.AerospikeConfig.Value["security"].(map[string]interface{})["enable-quotas"] = true

// As pod is in pending state, CR object will be won't reach the final phase.
// As pod is in pending state, CR object won't reach the final phase.
// So expectedPhases can be InProgress or Completed
return updateClusterWithExpectedPhases(k8sClient, ctx, aeroCluster, expectedPhases)
}, 1*time.Minute).ShouldNot(HaveOccurred())
Expand All @@ -255,7 +255,7 @@ func clusterWithMaxIgnorablePod(ctx goctx.Context) {
aeroCluster, err = getCluster(k8sClient, ctx, clusterNamespacedName)
Expect(err).ToNot(HaveOccurred())
aeroCluster.Spec.Image = nextImage
// As pod is in pending state, CR object will be won't reach the final phase.
// As pod is in pending state, CR object won't reach the final phase.
// So expectedPhases can be InProgress or Completed
return updateClusterWithExpectedPhases(k8sClient, ctx, aeroCluster, expectedPhases)
}, 1*time.Minute).ShouldNot(HaveOccurred())
Expand Down Expand Up @@ -285,7 +285,7 @@ func clusterWithMaxIgnorablePod(ctx goctx.Context) {
},
}
aeroCluster.Spec.Operations = operations
// As pod is in pending state, CR object will be won't reach the final phase.
// As pod is in pending state, CR object won't reach the final phase.
// So expectedPhases can be InProgress or Completed
return updateClusterWithExpectedPhases(k8sClient, ctx, aeroCluster, expectedPhases)
}, 1*time.Minute).ShouldNot(HaveOccurred())
Expand All @@ -307,7 +307,7 @@ func clusterWithMaxIgnorablePod(ctx goctx.Context) {
aeroCluster, err = getCluster(k8sClient, ctx, clusterNamespacedName)
Expect(err).ToNot(HaveOccurred())
aeroCluster.Spec.Size--
// As pod is in pending state, CR object will be won't reach the final phase.
// As pod is in pending state, CR object won't reach the final phase.
// So expectedPhases can be InProgress or Completed
err = updateClusterWithExpectedPhases(k8sClient, ctx, aeroCluster, expectedPhases)
Expect(err).ToNot(HaveOccurred())
Expand Down

0 comments on commit 782b079

Please sign in to comment.