Skip to content

Commit c54c7c6

Browse files
committed
update to use a default value for RequeueAfter
Signed-off-by: Britania Rodriguez Reyes <britaniar@microsoft.com>
1 parent b44f61f commit c54c7c6

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

pkg/controllers/updaterun/controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req runtime.Request) (runtim
124124
// Update the status to indicate that the updateRun is initializing.
125125
// Requeue immediately to continue with initialization.
126126
klog.V(2).InfoS("The updateRun is initializing", "state", state, "updateRun", runObjRef)
127-
return runtime.Result{RequeueAfter: 1}, r.recordUpdateRunInitializing(ctx, updateRun)
127+
return runtime.Result{RequeueAfter: utils.DefaultRequeueAfterDuration}, r.recordUpdateRunInitializing(ctx, updateRun)
128128
}
129129

130130
var initErr error
@@ -188,9 +188,9 @@ func (r *Reconciler) Reconcile(ctx context.Context, req runtime.Request) (runtim
188188
return runtime.Result{}, execErr
189189
}
190190
if waitTime == 0 {
191-
// If update run is not finished and waitTime is zero, the waitTime needs to be update to a non-zero value
191+
// If update run is not finished and the waitTime needs to be update to a non-zero value or default requeue duration,
192192
// as we are using RequeueAfter only since Requeue is deprecated.
193-
return runtime.Result{RequeueAfter: 1}, nil
193+
return runtime.Result{RequeueAfter: utils.DefaultRequeueAfterDuration}, nil
194194
}
195195
return runtime.Result{RequeueAfter: waitTime}, nil
196196
}

pkg/controllers/updaterun/execution.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ 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"
3839
bindingutils "github.com/kubefleet-dev/kubefleet/pkg/utils/binding"
3940
"github.com/kubefleet-dev/kubefleet/pkg/utils/condition"
4041
"github.com/kubefleet-dev/kubefleet/pkg/utils/controller"
@@ -418,7 +419,7 @@ func (r *Reconciler) checkAfterStageTasksStatus(ctx context.Context, updatingSta
418419
}
419420
}
420421
if passed {
421-
afterStageWaitTime = 0
422+
afterStageWaitTime = utils.DefaultRequeueAfterDuration
422423
}
423424
return passed, afterStageWaitTime, nil
424425
}

pkg/utils/common.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ import (
5454
"github.com/kubefleet-dev/kubefleet/pkg/utils/informer"
5555
)
5656

57+
const (
58+
// DefaultRequeueAfterDuration is the default duration after which to requeue a reconcile request.
59+
// This is used when a controller wants to requeue immediately. A small duration is used to mimic immediate requeue
60+
// that Controller-Runtimes deprecated Requeue=true previously provided.
61+
// For more details, see: https://github.com/kubernetes-sigs/controller-runtime/pull/3107
62+
// The value needs to be small enough to avoid noticeable delay, but greater than 0 as RequeueAfter=0 is treated as no requeue.
63+
DefaultRequeueAfterDuration = time.Microsecond * 1
64+
)
65+
5766
const (
5867
kubePrefix = "kube-"
5968
fleetPrefix = "fleet-"

0 commit comments

Comments
 (0)