Skip to content

Commit 66d9bdf

Browse files
author
Ryan Zhang
committed
refactor resync time
Signed-off-by: Ryan Zhang <[email protected]>
1 parent 55333ba commit 66d9bdf

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pkg/controllers/clusterresourceplacement/controller.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ import (
5151
// if object size is greater than 1MB https://github.com/kubernetes/kubernetes/blob/db1990f48b92d603f469c1c89e2ad36da1b74846/test/integration/master/synthetic_master_test.go#L337
5252
var resourceSnapshotResourceSizeLimit = 800 * (1 << 10) // 800KB
5353

54+
// We use a safety resync period to requeue all the finished request just in case there is a bug in the system.
55+
// TODO: unify all the controllers with this pattern and make this configurable in place of the controller runtime resync period.
56+
const controllerResyncPeriod = 15 * time.Minute
57+
5458
func (r *Reconciler) Reconcile(ctx context.Context, key controller.QueueKey) (ctrl.Result, error) {
5559
name, ok := key.(string)
5660
if !ok {
@@ -189,7 +193,7 @@ func (r *Reconciler) handleUpdate(ctx context.Context, crp *fleetv1beta1.Cluster
189193
return ctrl.Result{}, controller.NewUpdateIgnoreConflictError(updateErr)
190194
}
191195
// no need to retry faster, the user needs to fix the resource selectors
192-
return ctrl.Result{RequeueAfter: 5 * time.Minute}, nil
196+
return ctrl.Result{RequeueAfter: controllerResyncPeriod}, nil
193197
}
194198

195199
latestSchedulingPolicySnapshot, err := r.getOrCreateClusterSchedulingPolicySnapshot(ctx, crp, int(revisionLimit))
@@ -253,11 +257,11 @@ func (r *Reconciler) handleUpdate(ctx context.Context, crp *fleetv1beta1.Cluster
253257
// Here we requeue the request to prevent a bug in the watcher.
254258
klog.V(2).InfoS("Scheduler has not scheduled any cluster yet and requeue the request as a backup",
255259
"clusterResourcePlacement", crpKObj, "scheduledCondition", crp.GetCondition(string(fleetv1beta1.ClusterResourcePlacementScheduledConditionType)), "generation", crp.Generation)
256-
return ctrl.Result{RequeueAfter: 5 * time.Minute}, nil
260+
return ctrl.Result{RequeueAfter: controllerResyncPeriod}, nil
257261
}
258262
klog.V(2).InfoS("Placement rollout has not finished yet and requeue the request", "clusterResourcePlacement", crpKObj, "status", crp.Status, "generation", crp.Generation)
259263
// no need to requeue the request as the binding status will be changed but we add a long resync loop just in case.
260-
return ctrl.Result{RequeueAfter: 5 * time.Minute}, nil
264+
return ctrl.Result{RequeueAfter: controllerResyncPeriod}, nil
261265
}
262266

263267
func (r *Reconciler) getOrCreateClusterSchedulingPolicySnapshot(ctx context.Context, crp *fleetv1beta1.ClusterResourcePlacement, revisionHistoryLimit int) (*fleetv1beta1.ClusterSchedulingPolicySnapshot, error) {

0 commit comments

Comments
 (0)