Skip to content

Commit

Permalink
wip: use RequeueAfter instead of Requeue
Browse files Browse the repository at this point in the history
  • Loading branch information
ushitora-anqou committed Dec 5, 2024
1 parent dcf3643 commit 440f0dd
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions internal/controller/mantlebackup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func (r *MantleBackupReconciler) getSnapshotTarget(ctx context.Context, backup *
}
if !ok {
logger.Info("waiting for PVC bound.")
return nil, ctrl.Result{Requeue: true}, nil
return nil, ctrl.Result{RequeueAfter: 1 * time.Minute}, nil
}

pvName := pvc.Spec.VolumeName
Expand Down Expand Up @@ -398,7 +398,7 @@ func (r *MantleBackupReconciler) reconcileAsStandalone(ctx context.Context, back
if err != nil {
return ctrl.Result{}, err
}
return ctrl.Result{Requeue: true}, nil
return ctrl.Result{RequeueAfter: 1 * time.Minute}, nil
}

if err := r.expire(ctx, backup); err != nil {
Expand Down Expand Up @@ -547,7 +547,7 @@ func (r *MantleBackupReconciler) replicateManifests(
*backup1.Status.SnapID < *backup.Status.SnapID &&
backup1.ObjectMeta.DeletionTimestamp.IsZero() &&
!meta.IsStatusConditionTrue(backup1.Status.Conditions, mantlev1.BackupConditionSyncedToRemote) {
return ctrl.Result{Requeue: true}, nil
return ctrl.Result{RequeueAfter: 1 * time.Minute}, nil
}
}

Expand Down Expand Up @@ -686,7 +686,7 @@ func (r *MantleBackupReconciler) finalizeStandalone(
) (ctrl.Result, error) {
logger := log.FromContext(ctx)
if _, ok := backup.GetAnnotations()[annotDiffTo]; ok {
return ctrl.Result{Requeue: true}, nil
return ctrl.Result{RequeueAfter: 1 * time.Minute}, nil
}

if !controllerutil.ContainsFinalizer(backup, MantleBackupFinalizerName) {
Expand Down Expand Up @@ -724,7 +724,7 @@ func (r *MantleBackupReconciler) finalizeSecondary(
) (ctrl.Result, error) {
logger := log.FromContext(ctx)
if _, ok := backup.GetAnnotations()[annotDiffTo]; ok {
return ctrl.Result{Requeue: true}, nil
return ctrl.Result{RequeueAfter: 1 * time.Minute}, nil
}

if !controllerutil.ContainsFinalizer(backup, MantleBackupFinalizerName) {
Expand Down Expand Up @@ -948,7 +948,7 @@ func (r *MantleBackupReconciler) export(
return ctrl.Result{}, err
}

return ctrl.Result{Requeue: true}, nil
return ctrl.Result{RequeueAfter: 1 * time.Minute}, nil
}

func (r *MantleBackupReconciler) annotateExportTargetMantleBackup(
Expand Down Expand Up @@ -1008,7 +1008,7 @@ func (r *MantleBackupReconciler) checkIfNewJobCanBeCreated(ctx context.Context)
}

if len(jobs.Items) >= r.primarySettings.MaxExportJobs {
return ctrl.Result{Requeue: true}, nil
return ctrl.Result{RequeueAfter: 1 * time.Minute}, nil
}

return ctrl.Result{}, nil
Expand Down Expand Up @@ -1254,7 +1254,7 @@ func (r *MantleBackupReconciler) checkIfExportJobIsCompleted(
return ctrl.Result{}, nil
}

return ctrl.Result{Requeue: true}, nil
return ctrl.Result{RequeueAfter: 1 * time.Minute}, nil
}

func (r *MantleBackupReconciler) createOrUpdateExportDataUploadJob(ctx context.Context, target *mantlev1.MantleBackup) error {
Expand Down Expand Up @@ -1393,7 +1393,7 @@ func (r *MantleBackupReconciler) startImport(
) (ctrl.Result, error) {
if !r.doesMantleBackupHaveSyncModeAnnot(backup) {
// SetSynchronizingg is not called yet or the cache is stale.
return ctrl.Result{Requeue: true}, nil
return ctrl.Result{RequeueAfter: 1 * time.Minute}, nil
}

if result, err := r.isExportDataAlreadyUploaded(ctx, backup); err != nil || !result.IsZero() {
Expand All @@ -1402,7 +1402,7 @@ func (r *MantleBackupReconciler) startImport(

// Requeue if the PV is smaller than the PVC. (This may be the case if pvc-autoresizer is used.)
if isPVSmallerThanPVC(target.pv, target.pvc) {
return ctrl.Result{Requeue: true}, nil
return ctrl.Result{RequeueAfter: 1 * time.Minute}, nil
}

if err := r.updateStatusManifests(ctx, backup, target.pv, target.pvc); err != nil {
Expand Down Expand Up @@ -1499,7 +1499,7 @@ func (r *MantleBackupReconciler) isExportDataAlreadyUploaded(
if uploaded {
return ctrl.Result{}, nil
}
return ctrl.Result{Requeue: true}, nil
return ctrl.Result{RequeueAfter: 1 * time.Minute}, nil
}

func isPVSmallerThanPVC(
Expand Down Expand Up @@ -1563,7 +1563,7 @@ func (r *MantleBackupReconciler) reconcileDiscardJob(
if completed {
return ctrl.Result{}, nil
}
return ctrl.Result{Requeue: true}, nil
return ctrl.Result{RequeueAfter: 1 * time.Minute}, nil
}

func (r *MantleBackupReconciler) createOrUpdateDiscardPV(
Expand Down Expand Up @@ -1748,11 +1748,11 @@ func (r *MantleBackupReconciler) reconcileImportJob(
if err := r.createOrImportJob(ctx, backup, snapshotTarget); err != nil {
return ctrl.Result{}, err
}
return ctrl.Result{Requeue: true}, nil
return ctrl.Result{RequeueAfter: 1 * time.Minute}, nil
}

if !IsJobConditionTrue(job.Status.Conditions, batchv1.JobComplete) {
return ctrl.Result{Requeue: true}, nil
return ctrl.Result{RequeueAfter: 1 * time.Minute}, nil
}

snapshot, err := ceph.FindRBDSnapshot(
Expand Down

0 comments on commit 440f0dd

Please sign in to comment.