Skip to content

Commit 1ac543c

Browse files
committed
address most comments
Signed-off-by: Britania Rodriguez Reyes <britaniar@microsoft.com>
1 parent 77a73ab commit 1ac543c

File tree

3 files changed

+300
-36
lines changed

3 files changed

+300
-36
lines changed

pkg/controllers/updaterun/execution.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,7 @@ func checkClusterUpdateResult(
592592
) (bool, error) {
593593
availCond := binding.GetCondition(string(placementv1beta1.ResourceBindingAvailable))
594594
diffReportCondition := binding.GetCondition(string(placementv1beta1.ResourceBindingDiffReported))
595+
klog.InfoS("Checking the cluster update result", "cluster", clusterStatus.ClusterName, "stage", updatingStage.StageName, "updateRun", klog.KObj(updateRun), "availableCondition", availCond, "diffReportCondition", diffReportCondition)
595596
if condition.IsConditionStatusTrue(availCond, binding.GetGeneration()) ||
596597
condition.IsConditionStatusTrue(diffReportCondition, binding.GetGeneration()) {
597598
// The resource updated on the cluster is available or diff is successfully reported.

pkg/controllers/updaterun/stop.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,12 @@ func (r *Reconciler) stopDeleteStage(
156156
}
157157
// In validation, we already check the binding must exist in the status.
158158
delete(existingDeleteStageClusterMap, bindingSpec.TargetCluster)
159+
// Make sure the cluster is not marked as deleted as the binding is still there.
159160
if condition.IsConditionStatusTrue(meta.FindStatusCondition(curCluster.Conditions, string(placementv1beta1.ClusterUpdatingConditionSucceeded)), updateRun.GetGeneration()) {
160161
// The cluster status is marked as deleted.
161-
continue
162+
unexpectedErr := controller.NewUnexpectedBehaviorError(fmt.Errorf("the deleted cluster `%s` in the deleting stage still has a binding", bindingSpec.TargetCluster))
163+
klog.ErrorS(unexpectedErr, "The cluster in the deleting stage is not removed yet but marked as deleted", "cluster", curCluster.ClusterName, "updateRun", updateRunRef)
164+
return false, fmt.Errorf("%w: %s", errStagedUpdatedAborted, unexpectedErr.Error())
162165
}
163166
if condition.IsConditionStatusTrue(meta.FindStatusCondition(curCluster.Conditions, string(placementv1beta1.ClusterUpdatingConditionStarted)), updateRun.GetGeneration()) {
164167
// The cluster status is marked as being deleted.
@@ -182,7 +185,19 @@ func (r *Reconciler) stopDeleteStage(
182185
}
183186

184187
klog.V(2).InfoS("The delete stage is stopping", "numberOfDeletingClusters", len(toBeDeletedBindings), "updateRun", updateRunRef)
185-
if len(toBeDeletedBindings) == 0 {
188+
allDeletingClustersDeleted := true
189+
for _, clusterStatus := range updateRunStatus.DeletionStageStatus.Clusters {
190+
klog.InfoS("Checking deletion status of cluster in delete stage", "cluster", clusterStatus.ClusterName, "conditions", clusterStatus.Conditions, "updateRun", updateRunRef)
191+
if condition.IsConditionStatusTrue(meta.FindStatusCondition(clusterStatus.Conditions,
192+
string(placementv1beta1.ClusterUpdatingConditionStarted)), updateRun.GetGeneration()) && !condition.IsConditionStatusTrue(
193+
meta.FindStatusCondition(clusterStatus.Conditions, string(placementv1beta1.ClusterUpdatingConditionSucceeded)),
194+
updateRun.GetGeneration()) {
195+
allDeletingClustersDeleted = false
196+
break
197+
}
198+
}
199+
200+
if allDeletingClustersDeleted || len(toBeDeletedBindings) == 0 {
186201
markStageUpdatingStopped(updateRunStatus.DeletionStageStatus, updateRun.GetGeneration())
187202
}
188203
return len(toBeDeletedBindings) == 0, nil
@@ -224,13 +239,13 @@ func markStageUpdatingStopped(stageUpdatingStatus *placementv1beta1.StageUpdatin
224239
}
225240

226241
func checkIfErrorStagedUpdateAborted(err error, updateRun placementv1beta1.UpdateRunObj, updatingStageStatus *placementv1beta1.StageUpdatingStatus) {
227-
updateRunStatus := updateRun.GetUpdateRunStatus()
228242
if errors.Is(err, errStagedUpdatedAborted) {
229243
if updatingStageStatus != nil {
230244
klog.InfoS("The update run is aborted due to unrecoverable behavior in updating stage, marking the stage as failed", "stage", updatingStageStatus.StageName, "updateRun", klog.KObj(updateRun))
231245
markStageUpdatingFailed(updatingStageStatus, updateRun.GetGeneration(), err.Error())
232246
} else {
233247
// Handle deletion stage case.
248+
updateRunStatus := updateRun.GetUpdateRunStatus()
234249
markStageUpdatingFailed(updateRunStatus.DeletionStageStatus, updateRun.GetGeneration(), err.Error())
235250
}
236251
}

0 commit comments

Comments
 (0)