mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-18 04:54:54 +00:00
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
This commit is contained in:
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user