Skip to content

Commit 958ef64

Browse files
authored
Fix use of deprecated reconcile.Result Requeue field. (#821)
1 parent ed6da17 commit 958ef64

File tree

9 files changed

+61
-48
lines changed

9 files changed

+61
-48
lines changed

controllers/coherencejob_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (in *CoherenceJobReconciler) ReconcileDeployment(ctx context.Context, reque
6969
// request for the same resource is already in progress so requeue this one.
7070
if ok := in.Lock(request); !ok {
7171
log.Info("CoherenceJob resource " + request.Namespace + "/" + request.Name + " is already locked, requeue request")
72-
return reconcile.Result{Requeue: true, RequeueAfter: 0}, nil
72+
return reconcile.Result{RequeueAfter: time.Second * 10}, nil
7373
}
7474
// Make sure that the request is unlocked when this method exits
7575
defer in.Unlock(request)

controllers/errorhandling/error_handler.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ func (eh *ErrorHandler) HandleError(ctx context.Context, err error, resource coh
9898
return eh.attemptRecovery(ctx, err, resource)
9999
case ErrorCategoryPermanent:
100100
// For permanent errors, don't requeue
101-
return reconcile.Result{Requeue: false}, nil
101+
return reconcile.Result{}, nil
102102
default:
103103
// For unknown errors, requeue with a short delay
104-
return reconcile.Result{Requeue: true, RequeueAfter: 5 * time.Second}, nil
104+
return reconcile.Result{RequeueAfter: 5 * time.Second}, nil
105105
}
106106
}
107107

@@ -360,7 +360,7 @@ func (eh *ErrorHandler) handleTransientError(resource coh.CoherenceResource) (re
360360
"errorCount", count,
361361
"backoff", backoff)
362362

363-
return reconcile.Result{Requeue: true, RequeueAfter: backoff}, nil
363+
return reconcile.Result{RequeueAfter: backoff}, nil
364364
}
365365

366366
// attemptRecovery attempts to recover from a recoverable error
@@ -371,7 +371,7 @@ func (eh *ErrorHandler) attemptRecovery(ctx context.Context, err error, resource
371371
Namespace: resource.GetNamespace(),
372372
Name: resource.GetName(),
373373
}, latest); err != nil {
374-
return reconcile.Result{Requeue: true}, err
374+
return reconcile.Result{RequeueAfter: time.Minute}, err
375375
}
376376

377377
// Get the annotations
@@ -391,7 +391,7 @@ func (eh *ErrorHandler) attemptRecovery(ctx context.Context, err error, resource
391391
"resource", resource.GetName(),
392392
"namespace", resource.GetNamespace(),
393393
"lastAttempt", lastAttempt)
394-
return reconcile.Result{Requeue: true, RequeueAfter: 1 * time.Minute}, nil
394+
return reconcile.Result{RequeueAfter: 1 * time.Minute}, nil
395395
}
396396
}
397397
}
@@ -402,7 +402,7 @@ func (eh *ErrorHandler) attemptRecovery(ctx context.Context, err error, resource
402402

403403
// Update the resource
404404
if err := eh.Client.Update(ctx, latest); err != nil {
405-
return reconcile.Result{Requeue: true}, err
405+
return reconcile.Result{RequeueAfter: time.Minute}, err
406406
}
407407

408408
// Log the recovery attempt with detailed diagnostics
@@ -463,7 +463,7 @@ func (eh *ErrorHandler) attemptRecovery(ctx context.Context, err error, resource
463463
eh.Log.Error(updateErr, "Failed to update resource with diagnostic information")
464464
}
465465

466-
return reconcile.Result{Requeue: true, RequeueAfter: 30 * time.Second}, nil
466+
return reconcile.Result{RequeueAfter: 30 * time.Second}, nil
467467
}
468468

469469
// recoverFromServiceSuspensionFailure attempts to recover from a service suspension failure
@@ -485,7 +485,7 @@ func (eh *ErrorHandler) recoverFromServiceSuspensionFailure(ctx context.Context,
485485
Namespace: resource.GetNamespace(),
486486
Name: resource.GetName(),
487487
}, latest); err != nil {
488-
return reconcile.Result{Requeue: true}, err
488+
return reconcile.Result{RequeueAfter: time.Minute}, err
489489
}
490490

491491
// Check if this is a deletion and has the Coherence finalizer
@@ -503,7 +503,7 @@ func (eh *ErrorHandler) recoverFromServiceSuspensionFailure(ctx context.Context,
503503
// Update the resource with the annotation
504504
if err := eh.Client.Update(ctx, latest); err != nil {
505505
eh.Log.Error(err, "Failed to add finalizer bypass annotation")
506-
return reconcile.Result{Requeue: true}, err
506+
return reconcile.Result{RequeueAfter: time.Minute}, err
507507
}
508508

509509
eh.Log.Info("Added finalizer bypass annotation to resource",
@@ -515,7 +515,7 @@ func (eh *ErrorHandler) recoverFromServiceSuspensionFailure(ctx context.Context,
515515
}
516516

517517
// 4. Return a result that requeues after a short delay to check if recovery was successful
518-
return reconcile.Result{Requeue: true, RequeueAfter: 10 * time.Second}, nil
518+
return reconcile.Result{RequeueAfter: 10 * time.Second}, nil
519519
}
520520

521521
// recoverFromPDBIssue attempts to recover from Pod Disruption Budget issues
@@ -536,7 +536,7 @@ func (eh *ErrorHandler) recoverFromPDBIssue(ctx context.Context, resource coh.Co
536536
Namespace: resource.GetNamespace(),
537537
Name: resource.GetName(),
538538
}, latest); err != nil {
539-
return reconcile.Result{Requeue: true}, err
539+
return reconcile.Result{RequeueAfter: time.Minute}, err
540540
}
541541

542542
// Add diagnostic information
@@ -552,7 +552,7 @@ func (eh *ErrorHandler) recoverFromPDBIssue(ctx context.Context, resource coh.Co
552552
// Update the resource with the annotation
553553
if err := eh.Client.Update(ctx, latest); err != nil {
554554
eh.Log.Error(err, "Failed to add PDB issue annotation")
555-
return reconcile.Result{Requeue: true}, err
555+
return reconcile.Result{RequeueAfter: time.Minute}, err
556556
}
557557

558558
eh.Log.Info("Added PDB issue annotation to resource",
@@ -563,7 +563,7 @@ func (eh *ErrorHandler) recoverFromPDBIssue(ctx context.Context, resource coh.Co
563563
"Added PDB issue annotation to resource")
564564

565565
// Return a result that requeues after a delay
566-
return reconcile.Result{Requeue: true, RequeueAfter: 30 * time.Second}, nil
566+
return reconcile.Result{RequeueAfter: 30 * time.Second}, nil
567567
}
568568

569569
// recoverFromStatefulSetPatchIssue attempts to recover from StatefulSet patching issues
@@ -583,7 +583,7 @@ func (eh *ErrorHandler) recoverFromStatefulSetPatchIssue(ctx context.Context, re
583583
Namespace: resource.GetNamespace(),
584584
Name: resource.GetName(),
585585
}, latest); err != nil {
586-
return reconcile.Result{Requeue: true}, err
586+
return reconcile.Result{RequeueAfter: time.Minute}, err
587587
}
588588

589589
// Add diagnostic information
@@ -598,7 +598,7 @@ func (eh *ErrorHandler) recoverFromStatefulSetPatchIssue(ctx context.Context, re
598598
// Update the resource with the annotation
599599
if err := eh.Client.Update(ctx, latest); err != nil {
600600
eh.Log.Error(err, "Failed to add force-reconcile annotation")
601-
return reconcile.Result{Requeue: true}, err
601+
return reconcile.Result{RequeueAfter: time.Minute}, err
602602
}
603603

604604
eh.Log.Info("Added force-reconcile annotation to resource",
@@ -609,7 +609,7 @@ func (eh *ErrorHandler) recoverFromStatefulSetPatchIssue(ctx context.Context, re
609609
"Added force-reconcile annotation to resource to address StatefulSet patching issue")
610610

611611
// Return a result that requeues after a delay
612-
return reconcile.Result{Requeue: true, RequeueAfter: 10 * time.Second}, nil
612+
return reconcile.Result{RequeueAfter: 10 * time.Second}, nil
613613
}
614614

615615
// recoverFromQuotaIssue attempts to recover from resource quota issues
@@ -629,7 +629,7 @@ func (eh *ErrorHandler) recoverFromQuotaIssue(ctx context.Context, resource coh.
629629
Namespace: resource.GetNamespace(),
630630
Name: resource.GetName(),
631631
}, latest); err != nil {
632-
return reconcile.Result{Requeue: true}, err
632+
return reconcile.Result{RequeueAfter: time.Minute}, err
633633
}
634634

635635
// Add diagnostic information
@@ -645,7 +645,7 @@ func (eh *ErrorHandler) recoverFromQuotaIssue(ctx context.Context, resource coh.
645645
// Update the resource with the annotation
646646
if err := eh.Client.Update(ctx, latest); err != nil {
647647
eh.Log.Error(err, "Failed to add quota issue annotation")
648-
return reconcile.Result{Requeue: true}, err
648+
return reconcile.Result{RequeueAfter: time.Minute}, err
649649
}
650650

651651
eh.Log.Info("Added quota issue annotation to resource",
@@ -656,7 +656,7 @@ func (eh *ErrorHandler) recoverFromQuotaIssue(ctx context.Context, resource coh.
656656
"Resource quota exceeded - manual intervention may be required to increase quota or reduce resource requests")
657657

658658
// Return a result that requeues after a longer delay
659-
return reconcile.Result{Requeue: true, RequeueAfter: 2 * time.Minute}, nil
659+
return reconcile.Result{RequeueAfter: 2 * time.Minute}, nil
660660
}
661661

662662
// recoverFromSchedulingIssue attempts to recover from pod scheduling issues
@@ -676,7 +676,7 @@ func (eh *ErrorHandler) recoverFromSchedulingIssue(ctx context.Context, resource
676676
Namespace: resource.GetNamespace(),
677677
Name: resource.GetName(),
678678
}, latest); err != nil {
679-
return reconcile.Result{Requeue: true}, err
679+
return reconcile.Result{RequeueAfter: time.Minute}, err
680680
}
681681

682682
// Add diagnostic information
@@ -692,7 +692,7 @@ func (eh *ErrorHandler) recoverFromSchedulingIssue(ctx context.Context, resource
692692
// Update the resource with the annotation
693693
if err := eh.Client.Update(ctx, latest); err != nil {
694694
eh.Log.Error(err, "Failed to add scheduling issue annotation")
695-
return reconcile.Result{Requeue: true}, err
695+
return reconcile.Result{RequeueAfter: time.Minute}, err
696696
}
697697

698698
eh.Log.Info("Added scheduling issue annotation to resource",
@@ -703,7 +703,7 @@ func (eh *ErrorHandler) recoverFromSchedulingIssue(ctx context.Context, resource
703703
"Pod scheduling issue detected - manual intervention may be required to address node resources or affinity rules")
704704

705705
// Return a result that requeues after a longer delay
706-
return reconcile.Result{Requeue: true, RequeueAfter: 2 * time.Minute}, nil
706+
return reconcile.Result{RequeueAfter: 2 * time.Minute}, nil
707707
}
708708

709709
// RetryOnError retries the given function with exponential backoff on error

controllers/job/job_controller.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (in *ReconcileJob) Reconcile(ctx context.Context, request reconcile.Request
6969
// Attempt to lock the requested resource. If the resource is locked then another
7070
// request for the same resource is already in progress so requeue this one.
7171
if ok := in.Lock(request); !ok {
72-
return reconcile.Result{Requeue: true, RequeueAfter: 0}, nil
72+
return reconcile.Result{RequeueAfter: time.Second * 10}, nil
7373
}
7474
// Make sure that the request is unlocked when this method exits
7575
defer in.Unlock(request)
@@ -190,7 +190,7 @@ func (in *ReconcileJob) createJob(ctx context.Context, deployment coh.CoherenceR
190190
Reason: "StatusQuorum",
191191
Message: reason,
192192
})
193-
return reconcile.Result{Requeue: true, RequeueAfter: time.Second * 30}, nil
193+
return reconcile.Result{RequeueAfter: time.Second * 30}, nil
194194
}
195195

196196
err := in.Create(ctx, deployment.GetName(), storage, logger)
@@ -216,12 +216,12 @@ func (in *ReconcileJob) updateJob(ctx context.Context, deployment coh.CoherenceR
216216
if !found {
217217
// Desired state not found requeue and the request should sort itself out next time around
218218
logger.Info("Cannot locate desired state for Job, possibly a deletion, re-queuing request")
219-
return reconcile.Result{Requeue: true}, nil
219+
return reconcile.Result{RequeueAfter: time.Minute}, nil
220220
}
221221
if resource.IsDelete() {
222222
// we should never get here, requeue and the request should sort itself out next time around
223223
logger.Info("In update path for Job, but is a deletion - re-queuing request")
224-
return reconcile.Result{Requeue: true}, nil
224+
return reconcile.Result{RequeueAfter: time.Minute}, nil
225225
}
226226

227227
desired := resource.Spec.(*batchv1.Job)
@@ -254,7 +254,7 @@ func (in *ReconcileJob) patchJob(ctx context.Context, deployment coh.CoherenceRe
254254
msg := fmt.Sprintf("upddates to the job would have been invalid, the update will not be re-queued: %v", errorList)
255255
events := in.GetEventRecorder()
256256
events.Event(deployment, corev1.EventTypeWarning, reconciler.EventReasonUpdated, msg)
257-
return reconcile.Result{Requeue: false}, errors.New(msg)
257+
return reconcile.Result{}, errors.New(msg)
258258
}
259259

260260
// copy the job, so we do not alter the passed in job
@@ -326,7 +326,7 @@ func (in *ReconcileJob) patchJob(ctx context.Context, deployment coh.CoherenceRe
326326
logger.Info("Error patching Job " + err.Error())
327327
return in.HandleErrAndRequeue(ctx, err, deployment, fmt.Sprintf(FailedToPatchMessage, deployment.GetName(), err.Error()), logger)
328328
case !patched:
329-
return reconcile.Result{Requeue: true}, nil
329+
return reconcile.Result{RequeueAfter: time.Minute}, nil
330330
}
331331

332332
return reconcile.Result{}, nil

controllers/reconciler/base_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ func isOperationError(err error) bool {
449449
func (in *CommonReconciler) HandleErrAndFinish(ctx context.Context, err error, deployment *coh.Coherence, msg string, logger logr.Logger) (reconcile.Result, error) {
450450
if err == nil {
451451
logger.V(0).Info(msg)
452-
return reconcile.Result{Requeue: false}, nil
452+
return reconcile.Result{}, nil
453453
}
454454

455455
// Add caller information to the error if it's not already an OperationError
@@ -481,7 +481,7 @@ func (in *CommonReconciler) HandleErrAndFinish(ctx context.Context, err error, d
481481
WithContext("reason", "permanent")
482482
}
483483

484-
return reconcile.Result{Requeue: false}, nil
484+
return reconcile.Result{}, nil
485485
}
486486

487487
// Failed is a common error handler (deprecated, use HandleErrAndRequeue instead)
@@ -514,7 +514,7 @@ func (in *CommonReconciler) Failed(ctx context.Context, err error, deployment co
514514
}
515515
}
516516

517-
return reconcile.Result{Requeue: requeue}, err
517+
return reconcile.Result{}, err
518518
}
519519

520520
// getErrorHandler returns an error handler for this reconciler

controllers/reconciler/simple_reconciler.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ package reconciler
88

99
import (
1010
"context"
11+
"time"
12+
1113
coh "github.com/oracle/coherence-operator/api/v1"
1214
"github.com/oracle/coherence-operator/pkg/clients"
1315
corev1 "k8s.io/api/core/v1"
@@ -65,7 +67,7 @@ func (in *SimpleReconciler) Reconcile(ctx context.Context, request reconcile.Req
6567
// request for the same resource is already in progress so requeue this one.
6668
if ok := in.Lock(request); !ok {
6769
logger.Info("Completed reconcile. Already locked, re-queuing")
68-
return reconcile.Result{Requeue: true, RequeueAfter: 0}, nil
70+
return reconcile.Result{RequeueAfter: time.Second * 10}, nil
6971
}
7072
// Make sure that the request is unlocked when this method exits
7173
defer in.Unlock(request)

controllers/secret/secret_controller.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ package secret
88

99
import (
1010
"context"
11+
"time"
12+
1113
coh "github.com/oracle/coherence-operator/api/v1"
1214
"github.com/oracle/coherence-operator/controllers/reconciler"
1315
"github.com/oracle/coherence-operator/pkg/clients"
@@ -70,7 +72,7 @@ func (in *ReconcileSecret) Reconcile(ctx context.Context, request reconcile.Requ
7072
// request for the same resource is already in progress so requeue this one.
7173
if ok := in.Lock(request); !ok {
7274
logger.Info("Completed reconcile. Already locked, re-queuing")
73-
return reconcile.Result{Requeue: true, RequeueAfter: 0}, nil
75+
return reconcile.Result{RequeueAfter: time.Second * 10}, nil
7476
}
7577
// Make sure that the request is unlocked when this method exits
7678
defer in.Unlock(request)

controllers/servicemonitor/servicemonitor_controller.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ package servicemonitor
99
import (
1010
"context"
1111
"fmt"
12+
"time"
13+
1214
"github.com/go-logr/logr"
1315
coh "github.com/oracle/coherence-operator/api/v1"
1416
"github.com/oracle/coherence-operator/controllers/reconciler"
@@ -69,7 +71,7 @@ func (in *ReconcileServiceMonitor) Reconcile(ctx context.Context, request reconc
6971
// Attempt to lock the requested resource. If the resource is locked then another
7072
// request for the same resource is already in progress so requeue this one.
7173
if ok := in.Lock(request); !ok {
72-
return reconcile.Result{Requeue: true, RequeueAfter: 0}, nil
74+
return reconcile.Result{RequeueAfter: time.Second * 10}, nil
7375
}
7476
// Make sure that the request is unlocked when this method exits
7577
defer in.Unlock(request)

0 commit comments

Comments
 (0)