Skip to content

Commit adabce3

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 adabce3

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

internal/controller/common.go

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -683,13 +683,15 @@ func (r *Reconciler) EnsureNetworkAttachments(
683683
func (r *Reconciler) VerifyNetworkAttachments(
684684
ctx context.Context,
685685
helper *helper.Helper,
686+
pod *corev1.Pod,
686687
instance client.Object,
687688
networkAttachments []string,
688689
serviceLabels map[string]string,
689690
workflowStepIndex int,
690691
conditions *condition.Conditions,
691692
networkAttachmentStatus *map[string][]string,
692693
) (ctrl.Result, error) {
694+
Log := r.GetLogger(ctx)
693695
if !r.PodExists(ctx, instance, workflowStepIndex) {
694696
return ctrl.Result{}, nil
695697
}
@@ -713,14 +715,31 @@ func (r *Reconciler) VerifyNetworkAttachments(
713715
condition.NetworkAttachmentsReadyMessage)
714716
} else {
715717
err := fmt.Errorf("%w: %s", ErrNetworkAttachmentsMismatch, networkAttachments)
718+
719+
// maxWaitTime to wait for NAD that should escalate to a hard error
720+
const maxWaitTime = 5 * time.Minute
721+
elaspedTime := time.Since(pod.GetCreationTimestamp().Time)
722+
if elaspedTime > maxWaitTime {
723+
conditions.Set(condition.FalseCondition(
724+
condition.NetworkAttachmentsReadyCondition,
725+
condition.ErrorReason,
726+
condition.SeverityError,
727+
condition.NetworkAttachmentsReadyErrorMessage,
728+
fmt.Errorf("timed out waiting for network attachments: %w", err).Error()))
729+
730+
return ctrl.Result{}, err
731+
}
732+
716733
conditions.Set(condition.FalseCondition(
717734
condition.NetworkAttachmentsReadyCondition,
718-
condition.ErrorReason,
735+
"NetworkAttachmentsWaiting",
719736
condition.SeverityWarning,
720737
condition.NetworkAttachmentsReadyErrorMessage,
721738
err.Error()))
722739

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

726745
return ctrl.Result{}, nil

0 commit comments

Comments
 (0)