Skip to content

Commit 756cac5

Browse files
committed
address comments
Signed-off-by: Britania Rodriguez Reyes <britaniar@microsoft.com>
1 parent c54c7c6 commit 756cac5

12 files changed

+161
-204
lines changed

apis/placement/v1beta1/stageupdate_types.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,14 @@ func (c *ClusterStagedUpdateRun) SetUpdateRunStatus(status UpdateRunStatus) {
152152
type State string
153153

154154
const (
155-
// StateNotStarted describes user intent to initialize but not execute the update run.
155+
// StateInitialize describes user intent to initialize but not execute the update run.
156156
// This is the default state when an update run is created.
157-
StateNotStarted State = "Initialize"
157+
// Users can subsequently set the state to Execute or Abandon.
158+
StateInitialize State = "Initialize"
158159

159-
// StateStarted describes user intent to execute (or resume execution if paused).
160+
// StateExecute describes user intent to execute (or resume execution if paused).
160161
// Users can subsequently set the state to Pause or Abandon.
161-
StateStarted State = "Execute"
162+
StateExecute State = "Execute"
162163

163164
// StateStopped describes user intent to pause the update run.
164165
// Users can subsequently set the state to Execute or Abandon.
@@ -426,7 +427,6 @@ const (
426427
// Its condition status can be one of the following:
427428
// - "True": The staged update run is initialized successfully.
428429
// - "False": The staged update run encountered an error during initialization and aborted.
429-
// - "Unknown": The staged update run initialization has started.
430430
StagedUpdateRunConditionInitialized StagedUpdateRunConditionType = "Initialized"
431431

432432
// StagedUpdateRunConditionProgressing indicates whether the staged update run is making progress.

pkg/controllers/updaterun/controller.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req runtime.Request) (runtim
120120
return runtime.Result{}, nil
121121
}
122122

123-
if initCond == nil {
124-
// Update the status to indicate that the updateRun is initializing.
125-
// Requeue immediately to continue with initialization.
126-
klog.V(2).InfoS("The updateRun is initializing", "state", state, "updateRun", runObjRef)
127-
return runtime.Result{RequeueAfter: utils.DefaultRequeueAfterDuration}, r.recordUpdateRunInitializing(ctx, updateRun)
128-
}
129-
123+
// Initialize the updateRun.
130124
var initErr error
131125
if toBeUpdatedBindings, toBeDeletedBindings, initErr = r.initialize(ctx, updateRun); initErr != nil {
132126
klog.ErrorS(initErr, "Failed to initialize the updateRun", "updateRun", runObjRef)
@@ -165,7 +159,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req runtime.Request) (runtim
165159
}
166160

167161
// Execute the updateRun.
168-
if state == placementv1beta1.StateStarted {
162+
if state == placementv1beta1.StateExecute {
169163
klog.V(2).InfoS("Continue to execute the updateRun", "state", state, "updatingStageIndex", updatingStageIndex, "updateRun", runObjRef)
170164
finished, waitTime, execErr := r.execute(ctx, updateRun, updatingStageIndex, toBeUpdatedBindings, toBeDeletedBindings)
171165
if errors.Is(execErr, errStagedUpdatedAborted) {
@@ -188,7 +182,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req runtime.Request) (runtim
188182
return runtime.Result{}, execErr
189183
}
190184
if waitTime == 0 {
191-
// If update run is not finished and the waitTime needs to be update to a non-zero value or default requeue duration,
185+
// If update run is not finished and the waitTime needs to be updated to a non-zero value or default requeue duration,
192186
// as we are using RequeueAfter only since Requeue is deprecated.
193187
return runtime.Result{RequeueAfter: utils.DefaultRequeueAfterDuration}, nil
194188
}

pkg/controllers/updaterun/controller_integration_test.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -292,16 +292,6 @@ func generateInitializationFailedMetric(updateRun *placementv1beta1.ClusterStage
292292
}
293293
}
294294

295-
func generateInitializationUnknownMetric(updateRun *placementv1beta1.ClusterStagedUpdateRun) *prometheusclientmodel.Metric {
296-
return &prometheusclientmodel.Metric{
297-
Label: generateMetricsLabels(updateRun, string(placementv1beta1.StagedUpdateRunConditionInitialized),
298-
string(metav1.ConditionUnknown), condition.UpdateRunInitializingReason),
299-
Gauge: &prometheusclientmodel.Gauge{
300-
Value: ptr.To(float64(time.Now().UnixNano()) / 1e9),
301-
},
302-
}
303-
}
304-
305295
func generateProgressingMetric(updateRun *placementv1beta1.ClusterStagedUpdateRun) *prometheusclientmodel.Metric {
306296
return &prometheusclientmodel.Metric{
307297
Label: generateMetricsLabels(updateRun, string(placementv1beta1.StagedUpdateRunConditionProgressing),
@@ -361,7 +351,7 @@ func generateTestClusterStagedUpdateRun() *placementv1beta1.ClusterStagedUpdateR
361351
PlacementName: testCRPName,
362352
ResourceSnapshotIndex: testResourceSnapshotIndex,
363353
StagedUpdateStrategyName: testUpdateStrategyName,
364-
State: placementv1beta1.StateStarted,
354+
State: placementv1beta1.StateExecute,
365355
},
366356
}
367357
}

pkg/controllers/updaterun/execution.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import (
3535
"sigs.k8s.io/controller-runtime/pkg/client"
3636

3737
placementv1beta1 "github.com/kubefleet-dev/kubefleet/apis/placement/v1beta1"
38-
"github.com/kubefleet-dev/kubefleet/pkg/utils"
3938
bindingutils "github.com/kubefleet-dev/kubefleet/pkg/utils/binding"
4039
"github.com/kubefleet-dev/kubefleet/pkg/utils/condition"
4140
"github.com/kubefleet-dev/kubefleet/pkg/utils/controller"
@@ -419,7 +418,7 @@ func (r *Reconciler) checkAfterStageTasksStatus(ctx context.Context, updatingSta
419418
}
420419
}
421420
if passed {
422-
afterStageWaitTime = utils.DefaultRequeueAfterDuration
421+
afterStageWaitTime = 0
423422
}
424423
return passed, afterStageWaitTime, nil
425424
}

0 commit comments

Comments
 (0)