Skip to content

Commit d89fe42

Browse files
Paulina Osikoyaposikoya
authored andcommitted
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 d89fe42

1 file changed

Lines changed: 26 additions & 4 deletions

File tree

internal/controller/common.go

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -690,8 +690,11 @@ func (r *Reconciler) VerifyNetworkAttachments(
690690
conditions *condition.Conditions,
691691
networkAttachmentStatus *map[string][]string,
692692
) (ctrl.Result, error) {
693-
if !r.PodExists(ctx, instance, workflowStepIndex) {
694-
return ctrl.Result{}, nil
693+
Log := r.GetLogger(ctx)
694+
695+
pod, err := r.GetPodIfExists(ctx, instance, workflowStepIndex)
696+
if err != nil {
697+
return ctrl.Result{}, err
695698
}
696699

697700
networkReady, status, err := nad.VerifyNetworkStatusFromAnnotation(
@@ -713,14 +716,33 @@ func (r *Reconciler) VerifyNetworkAttachments(
713716
condition.NetworkAttachmentsReadyMessage)
714717
} else {
715718
err := fmt.Errorf("%w: %s", ErrNetworkAttachmentsMismatch, networkAttachments)
719+
720+
// maxWaitTime to wait for NAD that should escalate to a hard error
721+
const maxWaitTime = 5 * time.Minute
722+
elaspedTime := time.Since(pod.GetCreationTimestamp().Time)
723+
if elaspedTime > maxWaitTime {
724+
conditions.Set(condition.FalseCondition(
725+
condition.NetworkAttachmentsReadyCondition,
726+
condition.ErrorReason,
727+
condition.SeverityError,
728+
condition.NetworkAttachmentsReadyErrorMessage,
729+
fmt.Errorf("timed out waiting for network attachments: %w", err).Error()))
730+
731+
return ctrl.Result{}, err
732+
}
733+
716734
conditions.Set(condition.FalseCondition(
717735
condition.NetworkAttachmentsReadyCondition,
718-
condition.ErrorReason,
736+
"NetworkAttachmentsWaiting",
719737
condition.SeverityWarning,
720738
condition.NetworkAttachmentsReadyErrorMessage,
721739
err.Error()))
722740

723-
return ctrl.Result{}, err
741+
Log.Info("Waiting for network attachments to become ready",
742+
"elaspedTime", elaspedTime,
743+
"maxWaitTime", maxWaitTime)
744+
745+
return ctrl.Result{RequeueAfter: time.Second * 10}, nil
724746
}
725747

726748
return ctrl.Result{}, nil

0 commit comments

Comments
 (0)