Skip to content

Commit 2af4f4f

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 2af4f4f

1 file changed

Lines changed: 27 additions & 2 deletions

File tree

internal/controller/common.go

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -690,10 +690,16 @@ 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
}
696697

698+
pod, err := r.GetPodIfExists(ctx, instance, workflowStepIndex)
699+
if err != nil {
700+
return ctrl.Result{}, err
701+
}
702+
697703
networkReady, status, err := nad.VerifyNetworkStatusFromAnnotation(
698704
ctx,
699705
helper,
@@ -713,14 +719,33 @@ func (r *Reconciler) VerifyNetworkAttachments(
713719
condition.NetworkAttachmentsReadyMessage)
714720
} else {
715721
err := fmt.Errorf("%w: %s", ErrNetworkAttachmentsMismatch, networkAttachments)
722+
723+
// maxWaitTime to wait for NAD that should escalate to a hard error
724+
const maxWaitTime = 5 * time.Minute
725+
elaspedTime := time.Since(pod.GetCreationTimestamp().Time)
726+
if elaspedTime > maxWaitTime {
727+
conditions.Set(condition.FalseCondition(
728+
condition.NetworkAttachmentsReadyCondition,
729+
condition.ErrorReason,
730+
condition.SeverityError,
731+
condition.NetworkAttachmentsReadyErrorMessage,
732+
fmt.Errorf("timed out waiting for network attachments: %w", err).Error()))
733+
734+
return ctrl.Result{}, err
735+
}
736+
716737
conditions.Set(condition.FalseCondition(
717738
condition.NetworkAttachmentsReadyCondition,
718-
condition.ErrorReason,
739+
"NetworkAttachmentsWaiting",
719740
condition.SeverityWarning,
720741
condition.NetworkAttachmentsReadyErrorMessage,
721742
err.Error()))
722743

723-
return ctrl.Result{}, err
744+
Log.Info("Waiting for network attachments to become ready",
745+
"elaspedTime", elaspedTime,
746+
"maxWaitTime", maxWaitTime)
747+
748+
return ctrl.Result{RequeueAfter: time.Second * 10}, nil
724749
}
725750

726751
return ctrl.Result{}, nil

0 commit comments

Comments
 (0)