From 782b079753fc8ca552d938fc4b161f83e1758997 Mon Sep 17 00:00:00 2001 From: Tanmay Jain <tjain@aerospike.com> Date: Mon, 8 Jul 2024 23:27:12 +0530 Subject: [PATCH] adding comments --- api/v1/aerospikecluster_validating_webhook.go | 6 +++--- controllers/pod.go | 4 ++++ test/cluster_test.go | 8 ++++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/api/v1/aerospikecluster_validating_webhook.go b/api/v1/aerospikecluster_validating_webhook.go index 7a4512ab..5c08d6af 100644 --- a/api/v1/aerospikecluster_validating_webhook.go +++ b/api/v1/aerospikecluster_validating_webhook.go @@ -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") } } diff --git a/controllers/pod.go b/controllers/pod.go index b86a1939..04708fc1 100644 --- a/controllers/pod.go +++ b/controllers/pod.go @@ -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() } @@ -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()...) } diff --git a/test/cluster_test.go b/test/cluster_test.go index 0e55dea6..1c19952c 100644 --- a/test/cluster_test.go +++ b/test/cluster_test.go @@ -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()) @@ -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()) @@ -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()) @@ -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())