Skip to content

Commit

Permalink
Return nil error in case NAD not found to use RequeueAfter
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
stuggi authored and openshift-merge-bot[bot] committed Aug 6, 2024
1 parent 26c067f commit fc2cf11
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions controllers/placementapi_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,13 @@ func (r *PlacementAPIReconciler) Reconcile(ctx context.Context, req ctrl.Request
&instance.Status.Conditions)
if err != nil {
if k8s_errors.IsNotFound(err) {
Log.Info(fmt.Sprintf("OpenStack secret %s not found", instance.Spec.Secret))
instance.Status.Conditions.Set(condition.FalseCondition(
condition.InputReadyCondition,
condition.RequestedReason,
condition.SeverityInfo,
condition.InputReadyWaitingMessage))
return ctrl.Result{RequeueAfter: time.Second * 10}, fmt.Errorf("OpenStack secret %s not found", instance.Spec.Secret)
return ctrl.Result{RequeueAfter: time.Second * 10}, nil
}
instance.Status.Conditions.Set(condition.FalseCondition(
condition.InputReadyCondition,
Expand Down Expand Up @@ -600,13 +601,14 @@ func (r *PlacementAPIReconciler) ensureNetworkAttachments(
_, err := nad.GetNADWithName(ctx, h, netAtt, instance.Namespace)
if err != nil {
if k8s_errors.IsNotFound(err) {
r.GetLogger(ctx).Info(fmt.Sprintf("network-attachment-definition %s not found", netAtt))
instance.Status.Conditions.Set(condition.FalseCondition(
condition.NetworkAttachmentsReadyCondition,
condition.RequestedReason,
condition.SeverityInfo,
condition.NetworkAttachmentsReadyWaitingMessage,
netAtt))
return nadAnnotations, ctrl.Result{RequeueAfter: time.Second * 10}, fmt.Errorf("network-attachment-definition %s not found", netAtt)
return nadAnnotations, ctrl.Result{RequeueAfter: time.Second * 10}, nil
}
instance.Status.Conditions.Set(condition.FalseCondition(
condition.NetworkAttachmentsReadyCondition,
Expand Down

0 comments on commit fc2cf11

Please sign in to comment.