Skip to content

Commit 36cd2e7

Browse files
authored
Merge branch 'main' into posikoya/refator-reconcile-err
2 parents d89fe42 + 16033b8 commit 36cd2e7

2 files changed

Lines changed: 19 additions & 15 deletions

File tree

OWNERS_ALIASES

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ aliases:
77
- stuggi
88
test-approvers:
99
- lpiwowar
10+
- adrianfusco
1011
- arxcruz
1112
- kstrenkova
1213
test-reviewers:
1314
- evallesp
14-
- frenzyfriday
15-
- sdatko
16-
- adrianfusco
15+
- rebtoor
16+
- Valkyrie00
17+
- imatza-rh
18+
- posikoya

internal/controller/common.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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,10 +694,8 @@ func (r *Reconciler) VerifyNetworkAttachments(
690694
conditions *condition.Conditions,
691695
networkAttachmentStatus *map[string][]string,
692696
) (ctrl.Result, error) {
693-
Log := r.GetLogger(ctx)
694-
695697
pod, err := r.GetPodIfExists(ctx, instance, workflowStepIndex)
696-
if err != nil {
698+
if pod == nil {
697699
return ctrl.Result{}, err
698700
}
699701

0 commit comments

Comments
 (0)