From e597c578468232974ad68d9faaabcf7cce114b66 Mon Sep 17 00:00:00 2001 From: Martin Schuppert Date: Mon, 5 Aug 2024 18:13:25 +0200 Subject: [PATCH] Return nil error in case NAD not found to use RequeueAfter Currently the reconciler returned both a non-zero result and a non-nil error. The result will always be ignored if the error is non-nil and the non-nil error causes reqeueuing with exponential backoff. In case of NotFound return nil that the ReqeueAfter is used. For more details, see: https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/reconcile#Reconciler Signed-off-by: Martin Schuppert --- controllers/glance_common.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/controllers/glance_common.go b/controllers/glance_common.go index cfd9c9f5..2f80929d 100644 --- a/controllers/glance_common.go +++ b/controllers/glance_common.go @@ -125,13 +125,14 @@ func ensureNAD( _, err = nad.GetNADWithName(ctx, helper, netAtt, helper.GetBeforeObject().GetNamespace()) if err != nil { if k8s_errors.IsNotFound(err) { + helper.GetLogger().Info(fmt.Sprintf("network-attachment-definition %s not found", netAtt)) conditionUpdater.Set(condition.FalseCondition( condition.NetworkAttachmentsReadyCondition, condition.RequestedReason, condition.SeverityInfo, condition.NetworkAttachmentsReadyWaitingMessage, netAtt)) - return serviceAnnotations, ctrl.Result{RequeueAfter: time.Second * 10}, fmt.Errorf("network-attachment-definition %s not found", netAtt) + return serviceAnnotations, glance.ResultRequeue, nil } conditionUpdater.Set(condition.FalseCondition( condition.NetworkAttachmentsReadyCondition,