From 21bf85de15f6f9ad5b23b26b2e50faaad52c7bc8 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Thu, 18 Dec 2025 10:18:12 +0100 Subject: [PATCH] DRA E2E: support usage without real nodes This enables usage in test/integration/dra: - "deploying" a driver merely sets up the usual slices and class - created pods get force-deleted --- test/e2e/dra/utils/builder.go | 7 ++++++- test/e2e/dra/utils/deploy.go | 11 +++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/test/e2e/dra/utils/builder.go b/test/e2e/dra/utils/builder.go index 330c298786e..4422ba776b5 100644 --- a/test/e2e/dra/utils/builder.go +++ b/test/e2e/dra/utils/builder.go @@ -517,7 +517,12 @@ func (b *Builder) tearDown(tCtx ktesting.TContext) { continue } tCtx.Logf("Deleting %T %s", &pod, klog.KObj(&pod)) - err := tCtx.Client().CoreV1().Pods(b.namespace).Delete(tCtx, pod.Name, metav1.DeleteOptions{}) + options := metav1.DeleteOptions{} + if !b.driver.WithRealNodes { + // Force-delete, no kubelet. + options.GracePeriodSeconds = ptr.To(int64(0)) + } + err := tCtx.Client().CoreV1().Pods(b.namespace).Delete(tCtx, pod.Name, options) if !apierrors.IsNotFound(err) { tCtx.ExpectNoError(err, "delete pod") } diff --git a/test/e2e/dra/utils/deploy.go b/test/e2e/dra/utils/deploy.go index 7c777a28f57..becde2315f8 100644 --- a/test/e2e/dra/utils/deploy.go +++ b/test/e2e/dra/utils/deploy.go @@ -311,6 +311,7 @@ func NewDriverInstance(tCtx ktesting.TContext) *Driver { // By default, assume that the kubelet supports DRA and that // the driver's removal causes ResourceSlice cleanup. WithKubelet: true, + WithRealNodes: true, ExpectResourceSliceRemoval: true, } if tCtx != nil { @@ -385,6 +386,9 @@ type Driver struct { // Register the DRA test driver with the kubelet and expect DRA to work (= feature.DynamicResourceAllocation). WithKubelet bool + // Run driver pods. If false, only set up slices and class. + WithRealNodes bool + mutex sync.Mutex fail map[MethodInstance]bool callCounts map[MethodInstance]int64 @@ -456,6 +460,13 @@ func (d *Driver) SetUp(tCtx ktesting.TContext, kubeletRootDir string, nodes *Nod } } + if !d.WithRealNodes { + // Slices have been created as usual. + // We don't actually have nodes, so + // running pods wouldn't work and can be skipped. + return + } + // Create service account and corresponding RBAC rules. d.serviceAccountName = "dra-kubelet-plugin-" + d.Name + d.InstanceSuffix + "-service-account" content := example.PluginPermissions