Skip to content

Commit 9333350

Browse files
committed
revert file
Signed-off-by: Britania Rodriguez Reyes <britaniar@microsoft.com>
1 parent de5d240 commit 9333350

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

pkg/controllers/updaterun/validation.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"reflect"
2323

2424
"k8s.io/apimachinery/pkg/api/meta"
25-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2625
"k8s.io/klog/v2"
2726

2827
placementv1beta1 "github.com/kubefleet-dev/kubefleet/apis/placement/v1beta1"
@@ -186,7 +185,7 @@ func validateClusterUpdatingStatus(
186185
) (int, int, error) {
187186
stageSucceedCond := meta.FindStatusCondition(stageStatus.Conditions, string(placementv1beta1.StageUpdatingConditionSucceeded))
188187
stageStartedCond := meta.FindStatusCondition(stageStatus.Conditions, string(placementv1beta1.StageUpdatingConditionProgressing))
189-
if stageSucceedCond != nil && stageSucceedCond.Status == metav1.ConditionTrue {
188+
if condition.IsConditionStatusTrue(stageSucceedCond, updateRun.GetGeneration()) {
190189
// The stage has finished.
191190
if updatingStageIndex != -1 && curStage > updatingStageIndex {
192191
// The finished stage is after the updating stage.
@@ -197,8 +196,10 @@ func validateClusterUpdatingStatus(
197196
// Make sure that all the clusters are updated.
198197
for curCluster := range stageStatus.Clusters {
199198
// Check if the cluster is still updating.
200-
clusterUpdateSucceedCond := meta.FindStatusCondition(stageStatus.Clusters[curCluster].Conditions, string(placementv1beta1.ClusterUpdatingConditionSucceeded))
201-
if !(clusterUpdateSucceedCond != nil && clusterUpdateSucceedCond.Status == metav1.ConditionTrue) {
199+
if !condition.IsConditionStatusTrue(meta.FindStatusCondition(
200+
stageStatus.Clusters[curCluster].Conditions,
201+
string(placementv1beta1.ClusterUpdatingConditionSucceeded)),
202+
updateRun.GetGeneration()) {
202203
// The clusters in the finished stage should all have finished too.
203204
unexpectedErr := controller.NewUnexpectedBehaviorError(fmt.Errorf("cluster `%s` in the finished stage `%s` has not succeeded", stageStatus.Clusters[curCluster].ClusterName, stageStatus.StageName))
204205
klog.ErrorS(unexpectedErr, "The cluster in a finished stage is still updating", "updateRun", klog.KObj(updateRun))
@@ -213,7 +214,7 @@ func validateClusterUpdatingStatus(
213214
}
214215
// Record the last finished stage so we can continue from the next stage if no stage is updating.
215216
lastFinishedStageIndex = curStage
216-
} else if stageSucceedCond != nil && stageSucceedCond.Status == metav1.ConditionFalse {
217+
} else if condition.IsConditionStatusFalse(stageSucceedCond, updateRun.GetGeneration()) {
217218
// The stage has failed.
218219
failedErr := fmt.Errorf("the stage `%s` has failed, err: %s", stageStatus.StageName, stageSucceedCond.Message)
219220
klog.ErrorS(failedErr, "The stage has failed", "stageCond", stageSucceedCond, "updateRun", klog.KObj(updateRun))

0 commit comments

Comments
 (0)