mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-08 03:33:56 +00:00
e2e dra: add "kubelet must skip NodePrepareResource if not used by any container"
If (for whatever reason) no container uses a claim, then there's no need to prepare it.
This commit is contained in:
parent
bbc7ca94a4
commit
ec70b2ec80
@ -61,11 +61,11 @@ var _ = ginkgo.Describe("[sig-node] DRA [Feature:DynamicResourceAllocation]", fu
|
||||
nodes := NewNodes(f, 1, 1)
|
||||
driver := NewDriver(f, nodes, networkResources) // All tests get their own driver instance.
|
||||
b := newBuilder(f, driver)
|
||||
|
||||
ginkgo.It("registers plugin", func() {
|
||||
ginkgo.By("the driver is running")
|
||||
})
|
||||
|
||||
// This test does not pass at the moment because kubelet doesn't retry.
|
||||
ginkgo.It("must retry NodePrepareResource", func(ctx context.Context) {
|
||||
// We have exactly one host.
|
||||
m := MethodInstance{driver.Nodenames()[0], NodePrepareResourceMethod}
|
||||
@ -95,6 +95,7 @@ var _ = ginkgo.Describe("[sig-node] DRA [Feature:DynamicResourceAllocation]", fu
|
||||
framework.Fail("NodePrepareResource should have been called again")
|
||||
}
|
||||
})
|
||||
|
||||
ginkgo.It("must not run a pod if a claim is not reserved for it", func(ctx context.Context) {
|
||||
parameters := b.parameters()
|
||||
claim := b.externalClaim(resourcev1alpha2.AllocationModeImmediate)
|
||||
@ -118,6 +119,7 @@ var _ = ginkgo.Describe("[sig-node] DRA [Feature:DynamicResourceAllocation]", fu
|
||||
return nil
|
||||
}, 20*time.Second, 200*time.Millisecond).Should(gomega.BeNil())
|
||||
})
|
||||
|
||||
ginkgo.It("must unprepare resources for force-deleted pod", func(ctx context.Context) {
|
||||
parameters := b.parameters()
|
||||
claim := b.externalClaim(resourcev1alpha2.AllocationModeImmediate)
|
||||
@ -140,6 +142,19 @@ var _ = ginkgo.Describe("[sig-node] DRA [Feature:DynamicResourceAllocation]", fu
|
||||
gomega.Eventually(plugin.GetPreparedResources).WithTimeout(time.Minute).Should(gomega.BeEmpty(), "prepared claims on host %s", host)
|
||||
}
|
||||
})
|
||||
|
||||
ginkgo.It("must skip NodePrepareResource if not used by any container", func(ctx context.Context) {
|
||||
parameters := b.parameters()
|
||||
pod, template := b.podInline(resourcev1alpha2.AllocationModeWaitForFirstConsumer)
|
||||
for i := range pod.Spec.Containers {
|
||||
pod.Spec.Containers[i].Resources.Claims = nil
|
||||
}
|
||||
b.create(ctx, parameters, pod, template)
|
||||
framework.ExpectNoError(e2epod.WaitForPodRunningInNamespace(ctx, f.ClientSet, pod), "start pod")
|
||||
for host, plugin := range b.driver.Nodes {
|
||||
gomega.Expect(plugin.GetPreparedResources()).Should(gomega.BeEmpty(), "not claims should be prepared on host %s while pod is running", host)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
ginkgo.Context("driver", func() {
|
||||
|
Loading…
Reference in New Issue
Block a user