e2e_node: add deferPodDeletion parameter
This commit is contained in:
		@@ -97,7 +97,7 @@ var _ = framework.SIGDescribe("node")("DRA", feature.DynamicResourceAllocation,
 | 
				
			|||||||
		ginkgo.It("must process pod created when kubelet is not running", func(ctx context.Context) {
 | 
							ginkgo.It("must process pod created when kubelet is not running", func(ctx context.Context) {
 | 
				
			||||||
			// Stop Kubelet
 | 
								// Stop Kubelet
 | 
				
			||||||
			startKubelet := stopKubelet()
 | 
								startKubelet := stopKubelet()
 | 
				
			||||||
			pod := createTestObjects(ctx, f.ClientSet, getNodeName(ctx, f), f.Namespace.Name, "draclass", "external-claim", "drapod")
 | 
								pod := createTestObjects(ctx, f.ClientSet, getNodeName(ctx, f), f.Namespace.Name, "draclass", "external-claim", "drapod", true)
 | 
				
			||||||
			// Pod must be in pending state
 | 
								// Pod must be in pending state
 | 
				
			||||||
			err := e2epod.WaitForPodCondition(ctx, f.ClientSet, f.Namespace.Name, pod.Name, "Pending", framework.PodStartShortTimeout, func(pod *v1.Pod) (bool, error) {
 | 
								err := e2epod.WaitForPodCondition(ctx, f.ClientSet, f.Namespace.Name, pod.Name, "Pending", framework.PodStartShortTimeout, func(pod *v1.Pod) (bool, error) {
 | 
				
			||||||
				return pod.Status.Phase == v1.PodPending, nil
 | 
									return pod.Status.Phase == v1.PodPending, nil
 | 
				
			||||||
@@ -113,7 +113,7 @@ var _ = framework.SIGDescribe("node")("DRA", feature.DynamicResourceAllocation,
 | 
				
			|||||||
		ginkgo.It("must keep pod in pending state if NodePrepareResources times out", func(ctx context.Context) {
 | 
							ginkgo.It("must keep pod in pending state if NodePrepareResources times out", func(ctx context.Context) {
 | 
				
			||||||
			ginkgo.By("set delay for the NodePrepareResources call")
 | 
								ginkgo.By("set delay for the NodePrepareResources call")
 | 
				
			||||||
			kubeletPlugin.Block()
 | 
								kubeletPlugin.Block()
 | 
				
			||||||
			pod := createTestObjects(ctx, f.ClientSet, getNodeName(ctx, f), f.Namespace.Name, "draclass", "external-claim", "drapod")
 | 
								pod := createTestObjects(ctx, f.ClientSet, getNodeName(ctx, f), f.Namespace.Name, "draclass", "external-claim", "drapod", true)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			ginkgo.By("wait for pod to be in Pending state")
 | 
								ginkgo.By("wait for pod to be in Pending state")
 | 
				
			||||||
			err := e2epod.WaitForPodCondition(ctx, f.ClientSet, f.Namespace.Name, pod.Name, "Pending", framework.PodStartShortTimeout, func(pod *v1.Pod) (bool, error) {
 | 
								err := e2epod.WaitForPodCondition(ctx, f.ClientSet, f.Namespace.Name, pod.Name, "Pending", framework.PodStartShortTimeout, func(pod *v1.Pod) (bool, error) {
 | 
				
			||||||
@@ -170,7 +170,7 @@ func newKubeletPlugin(ctx context.Context, nodeName string) *testdriver.ExampleP
 | 
				
			|||||||
// NOTE: as scheduler and controller manager are not running by the Node e2e,
 | 
					// NOTE: as scheduler and controller manager are not running by the Node e2e,
 | 
				
			||||||
// the objects must contain all required data to be processed correctly by the API server
 | 
					// the objects must contain all required data to be processed correctly by the API server
 | 
				
			||||||
// and placed on the node without involving the scheduler and the DRA controller
 | 
					// and placed on the node without involving the scheduler and the DRA controller
 | 
				
			||||||
func createTestObjects(ctx context.Context, clientSet kubernetes.Interface, nodename, namespace, className, claimName, podName string) *v1.Pod {
 | 
					func createTestObjects(ctx context.Context, clientSet kubernetes.Interface, nodename, namespace, className, claimName, podName string, deferPodDeletion bool) *v1.Pod {
 | 
				
			||||||
	// ResourceClass
 | 
						// ResourceClass
 | 
				
			||||||
	class := &resourcev1alpha2.ResourceClass{
 | 
						class := &resourcev1alpha2.ResourceClass{
 | 
				
			||||||
		ObjectMeta: metav1.ObjectMeta{
 | 
							ObjectMeta: metav1.ObjectMeta{
 | 
				
			||||||
@@ -231,7 +231,9 @@ func createTestObjects(ctx context.Context, clientSet kubernetes.Interface, node
 | 
				
			|||||||
	createdPod, err := clientSet.CoreV1().Pods(namespace).Create(ctx, pod, metav1.CreateOptions{})
 | 
						createdPod, err := clientSet.CoreV1().Pods(namespace).Create(ctx, pod, metav1.CreateOptions{})
 | 
				
			||||||
	framework.ExpectNoError(err)
 | 
						framework.ExpectNoError(err)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if deferPodDeletion {
 | 
				
			||||||
		ginkgo.DeferCleanup(clientSet.CoreV1().Pods(namespace).Delete, podName, metav1.DeleteOptions{})
 | 
							ginkgo.DeferCleanup(clientSet.CoreV1().Pods(namespace).Delete, podName, metav1.DeleteOptions{})
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Update claim status: set ReservedFor and AllocationResult
 | 
						// Update claim status: set ReservedFor and AllocationResult
 | 
				
			||||||
	// NOTE: This is usually done by the DRA controller
 | 
						// NOTE: This is usually done by the DRA controller
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user