Skip to content

Commit 0b1ef24

Browse files
authored
Merge pull request kubernetes#130285 from LionelJouin/fix-130096
Fix DRA flaky test for ResourceClaim device status
2 parents ad4d9b2 + 993f3c3 commit 0b1ef24

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

test/e2e/dra/dra.go

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -411,27 +411,18 @@ var _ = framework.SIGDescribe("node")("DRA", feature.DynamicResourceAllocation,
411411
b.create(ctx, claim, pod)
412412

413413
// Waits for the ResourceClaim to be allocated and the pod to be scheduled.
414-
var allocatedResourceClaim *resourceapi.ResourceClaim
415-
var scheduledPod *v1.Pod
416-
417-
gomega.Eventually(ctx, func(ctx context.Context) (*resourceapi.ResourceClaim, error) {
418-
var err error
419-
allocatedResourceClaim, err = b.f.ClientSet.ResourceV1beta1().ResourceClaims(b.f.Namespace.Name).Get(ctx, claim.Name, metav1.GetOptions{})
420-
return allocatedResourceClaim, err
421-
}).WithTimeout(f.Timeouts.PodDelete).ShouldNot(gomega.HaveField("Status.Allocation", (*resourceapi.AllocationResult)(nil)))
422-
423-
gomega.Eventually(ctx, func(ctx context.Context) error {
424-
var err error
425-
scheduledPod, err = b.f.ClientSet.CoreV1().Pods(pod.Namespace).Get(ctx, pod.Name, metav1.GetOptions{})
426-
if err != nil && scheduledPod.Spec.NodeName != "" {
427-
return fmt.Errorf("expected the test pod %s to exist and to be scheduled on a node: %w", pod.Name, err)
428-
}
429-
return nil
430-
}).WithTimeout(f.Timeouts.PodDelete).Should(gomega.BeNil())
414+
b.testPod(ctx, f, pod)
431415

416+
allocatedResourceClaim, err := b.f.ClientSet.ResourceV1beta1().ResourceClaims(b.f.Namespace.Name).Get(ctx, claim.Name, metav1.GetOptions{})
417+
framework.ExpectNoError(err)
418+
gomega.Expect(allocatedResourceClaim).ToNot(gomega.BeNil())
432419
gomega.Expect(allocatedResourceClaim.Status.Allocation).ToNot(gomega.BeNil())
433420
gomega.Expect(allocatedResourceClaim.Status.Allocation.Devices.Results).To(gomega.HaveLen(1))
434421

422+
scheduledPod, err := b.f.ClientSet.CoreV1().Pods(b.f.Namespace.Name).Get(ctx, pod.Name, metav1.GetOptions{})
423+
framework.ExpectNoError(err)
424+
gomega.Expect(scheduledPod).ToNot(gomega.BeNil())
425+
435426
ginkgo.By("Setting the device status a first time")
436427
allocatedResourceClaim.Status.Devices = append(allocatedResourceClaim.Status.Devices,
437428
resourceapi.AllocatedDeviceStatus{
@@ -446,8 +437,13 @@ var _ = framework.SIGDescribe("node")("DRA", feature.DynamicResourceAllocation,
446437
HardwareAddress: "bc:1c:b6:3e:b8:25",
447438
},
448439
})
440+
449441
// Updates the ResourceClaim from the driver on the same node as the pod.
450-
updatedResourceClaim, err := driver.Nodes[scheduledPod.Spec.NodeName].ExamplePlugin.UpdateStatus(ctx, allocatedResourceClaim)
442+
plugin, ok := driver.Nodes[scheduledPod.Spec.NodeName]
443+
if !ok {
444+
framework.Failf("pod got scheduled to node %s without a plugin", scheduledPod.Spec.NodeName)
445+
}
446+
updatedResourceClaim, err := plugin.UpdateStatus(ctx, allocatedResourceClaim)
451447
framework.ExpectNoError(err)
452448
gomega.Expect(updatedResourceClaim).ToNot(gomega.BeNil())
453449
gomega.Expect(updatedResourceClaim.Status.Devices).To(gomega.Equal(allocatedResourceClaim.Status.Devices))
@@ -465,7 +461,8 @@ var _ = framework.SIGDescribe("node")("DRA", feature.DynamicResourceAllocation,
465461
HardwareAddress: "bc:1c:b6:3e:b8:26",
466462
},
467463
}
468-
updatedResourceClaim2, err := driver.Nodes[scheduledPod.Spec.NodeName].ExamplePlugin.UpdateStatus(ctx, updatedResourceClaim)
464+
465+
updatedResourceClaim2, err := plugin.UpdateStatus(ctx, updatedResourceClaim)
469466
framework.ExpectNoError(err)
470467
gomega.Expect(updatedResourceClaim2).ToNot(gomega.BeNil())
471468
gomega.Expect(updatedResourceClaim2.Status.Devices).To(gomega.Equal(updatedResourceClaim.Status.Devices))

0 commit comments

Comments
 (0)