@@ -598,17 +598,21 @@ func (r *Reconciler) ReleaseLock(ctx context.Context, instance client.Object) (b
598598 return false , ErrFailedToDeleteLock
599599}
600600
601- // PodExists checks if a pod exists for the given instance and workflow step
602- func (r * Reconciler ) PodExists (ctx context.Context , instance client.Object , workflowStepIndex int ) bool {
603- pod := & corev1.Pod {}
601+ // GetPodIfExists returns the pod for the given instance and workflow step if it exists
602+ func (r * Reconciler ) GetPodIfExists (
603+ ctx context.Context ,
604+ instance client.Object ,
605+ workflowStepIndex int ,
606+ ) (* corev1.Pod , error ) {
604607 podName := r .GetPodName (instance , workflowStepIndex )
605- objectKey := client.ObjectKey {Namespace : instance .GetNamespace (), Name : podName }
606- err := r .Client .Get (ctx , objectKey , pod )
607- if err != nil && k8s_errors .IsNotFound (err ) {
608- return false
608+ pod , err := r .GetPod (ctx , podName , instance .GetNamespace ())
609+ if err != nil {
610+ if k8s_errors .IsNotFound (err ) {
611+ return nil , nil
612+ }
613+ return nil , err
609614 }
610-
611- return true
615+ return pod , nil
612616}
613617
614618// GetCommonRbacRules returns the common RBAC rules for test operations, with optional privileged permissions
@@ -690,8 +694,9 @@ func (r *Reconciler) VerifyNetworkAttachments(
690694 conditions * condition.Conditions ,
691695 networkAttachmentStatus * map [string ][]string ,
692696) (ctrl.Result , error ) {
693- if ! r .PodExists (ctx , instance , workflowStepIndex ) {
694- return ctrl.Result {}, nil
697+ pod , err := r .GetPodIfExists (ctx , instance , workflowStepIndex )
698+ if pod == nil {
699+ return ctrl.Result {}, err
695700 }
696701
697702 networkReady , status , err := nad .VerifyNetworkStatusFromAnnotation (
0 commit comments