Skip to content

Commit b071443

Browse files
authored
Merge pull request kubernetes#127592 from dims/wait-for-gpus-even-for-aws-kubetest2-ec2-harness
Wait for GPUs even for AWS kubetest2 ec2 harness
2 parents 5607108 + 472ca3b commit b071443

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

test/e2e/node/gpu.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,11 @@ print(f"Time taken for {n}x{n} matrix multiplication: {end_time - start_time:.2f
263263
func SetupEnvironmentAndSkipIfNeeded(ctx context.Context, f *framework.Framework, clientSet clientset.Interface) {
264264
if framework.ProviderIs("gce") {
265265
SetupNVIDIAGPUNode(ctx, f)
266+
} else if framework.ProviderIs("aws") {
267+
// see nvidia-device-plugin.yml in https://github.com/NVIDIA/k8s-device-plugin/tree/main/deployments/static
268+
waitForGPUs(ctx, f, "kube-system", "nvidia-device-plugin-daemonset")
266269
}
270+
267271
nodes, err := e2enode.GetReadySchedulableNodes(ctx, clientSet)
268272
framework.ExpectNoError(err)
269273
capacity := 0
@@ -281,10 +285,10 @@ func SetupEnvironmentAndSkipIfNeeded(ctx context.Context, f *framework.Framework
281285
allocatable += int(val.Value())
282286
}
283287
if capacity == 0 {
284-
e2eskipper.Skipf("%d ready nodes do not have any Nvidia GPU(s). Skipping...", len(nodes.Items))
288+
framework.Failf("%d ready nodes do not have any Nvidia GPU(s). Bailing out...", len(nodes.Items))
285289
}
286290
if allocatable == 0 {
287-
e2eskipper.Skipf("%d ready nodes do not have any allocatable Nvidia GPU(s). Skipping...", len(nodes.Items))
291+
framework.Failf("%d ready nodes do not have any allocatable Nvidia GPU(s). Bailing out...", len(nodes.Items))
288292
}
289293
}
290294

@@ -296,6 +300,9 @@ func areGPUsAvailableOnAllSchedulableNodes(ctx context.Context, clientSet client
296300
if node.Spec.Unschedulable {
297301
continue
298302
}
303+
if _, ok := node.Labels[framework.ControlPlaneLabel]; ok {
304+
continue
305+
}
299306
framework.Logf("gpuResourceName %s", e2egpu.NVIDIAGPUResourceName)
300307
if val, ok := node.Status.Capacity[e2egpu.NVIDIAGPUResourceName]; !ok || val.Value() == 0 {
301308
framework.Logf("Nvidia GPUs not available on Node: %q", node.Name)
@@ -351,7 +358,11 @@ func SetupNVIDIAGPUNode(ctx context.Context, f *framework.Framework) {
351358
framework.ExpectNoError(err, "failed to create nvidia-driver-installer daemonset")
352359
framework.Logf("Successfully created daemonset to install Nvidia drivers.")
353360

354-
pods, err := e2eresource.WaitForControlledPods(ctx, f.ClientSet, ds.Namespace, ds.Name, extensionsinternal.Kind("DaemonSet"))
361+
waitForGPUs(ctx, f, ds.Namespace, ds.Name)
362+
}
363+
364+
func waitForGPUs(ctx context.Context, f *framework.Framework, namespace, name string) {
365+
pods, err := e2eresource.WaitForControlledPods(ctx, f.ClientSet, namespace, name, extensionsinternal.Kind("DaemonSet"))
355366
framework.ExpectNoError(err, "failed to get pods controlled by the nvidia-driver-installer daemonset")
356367

357368
devicepluginPods, err := e2eresource.WaitForControlledPods(ctx, f.ClientSet, "kube-system", "nvidia-gpu-device-plugin", extensionsinternal.Kind("DaemonSet"))

0 commit comments

Comments
 (0)