Skip to content

Commit 570158d

Browse files
author
Paulina Osikoya
committed
requeue logic for pending NAD
The operator currently returns a misleading reconcile error when Pod interfaces are not yet ready with assigned IPs. This change introduces a requeue mechanism to allow time for NetworkAttachmentDefinitions (NAD) to be fully provisioned.
1 parent 395fa31 commit 570158d

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

internal/controller/common.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,7 @@ func (r *Reconciler) VerifyNetworkAttachments(
690690
conditions *condition.Conditions,
691691
networkAttachmentStatus *map[string][]string,
692692
) (ctrl.Result, error) {
693+
Log := r.GetLogger(ctx)
693694
if !r.PodExists(ctx, instance, workflowStepIndex) {
694695
return ctrl.Result{}, nil
695696
}
@@ -713,14 +714,31 @@ func (r *Reconciler) VerifyNetworkAttachments(
713714
condition.NetworkAttachmentsReadyMessage)
714715
} else {
715716
err := fmt.Errorf("%w: %s", ErrNetworkAttachmentsMismatch, networkAttachments)
717+
718+
// maxWaitTime to wait for NAD that should escalate to a hard error
719+
const maxWaitTime = 5 * time.Minute
720+
elaspedTime := time.Since(instance.GetCreationTimestamp().Time)
721+
if elaspedTime > maxWaitTime {
722+
conditions.Set(condition.FalseCondition(
723+
condition.NetworkAttachmentsReadyCondition,
724+
condition.ErrorReason,
725+
condition.SeverityError,
726+
condition.NetworkAttachmentsReadyErrorMessage,
727+
fmt.Errorf("timed out waiting for network attachments: %w", err).Error()))
728+
729+
return ctrl.Result{}, err
730+
}
731+
716732
conditions.Set(condition.FalseCondition(
717733
condition.NetworkAttachmentsReadyCondition,
718-
condition.ErrorReason,
734+
"NetworkAttachmentsWaiting",
719735
condition.SeverityWarning,
720736
condition.NetworkAttachmentsReadyErrorMessage,
721737
err.Error()))
722738

723-
return ctrl.Result{}, err
739+
Log.Info("Waiting for network attachments to become ready", "elasped time", elaspedTime, "max wait time", maxWaitTime)
740+
741+
return ctrl.Result{RequeueAfter: time.Second * 10}, nil
724742
}
725743

726744
return ctrl.Result{}, nil

0 commit comments

Comments
 (0)