@@ -529,7 +529,7 @@ var _ = SIGDescribe("Pods Extended (pod generation)", feature.PodObservedGenerat
529
529
}
530
530
})
531
531
532
- ginkgo .It ("custom-set generation on new pods should be overwritten to 1 " , func (ctx context.Context ) {
532
+ ginkgo .It ("custom-set generation on new pods and graceful delete " , func (ctx context.Context ) {
533
533
ginkgo .By ("creating the pod" )
534
534
name := "pod-generation-" + string (uuid .NewUUID ())
535
535
value := strconv .Itoa (time .Now ().Nanosecond ())
@@ -598,6 +598,10 @@ var _ = SIGDescribe("Pods Extended (pod generation)", feature.PodObservedGenerat
598
598
gomega .Expect (pod .Generation ).To (gomega .BeEquivalentTo (expectedPodGeneration ))
599
599
})
600
600
601
+ // This is the same test as https://github.com/kubernetes/kubernetes/blob/aa08c90fca8d30038d3f05c0e8f127b540b40289/test/e2e/node/pod_admission.go#L35,
602
+ // except that this verifies the pod generation and observedGeneration, which is
603
+ // currently behind a feature gate. When we GA observedGeneration functionality,
604
+ // we can fold these tests together into one.
601
605
ginkgo .It ("pod rejected by kubelet should have updated generation and observedGeneration" , func (ctx context.Context ) {
602
606
node , err := e2enode .GetRandomReadySchedulableNode (ctx , f .ClientSet )
603
607
framework .ExpectNoError (err , "Failed to get a ready schedulable node" )
@@ -631,6 +635,18 @@ var _ = SIGDescribe("Pods Extended (pod generation)", feature.PodObservedGenerat
631
635
return podClient .Delete (ctx , pod .Name , metav1.DeleteOptions {})
632
636
})
633
637
638
+ // Wait for the scheduler to update the pod status
639
+ err = e2epod .WaitForPodNameUnschedulableInNamespace (ctx , f .ClientSet , pod .Name , pod .Namespace )
640
+ framework .ExpectNoError (err )
641
+
642
+ // Fetch the pod to verify that the scheduler has set the PodScheduled condition
643
+ // with observedGeneration.
644
+ pod , err = podClient .Get (ctx , pod .Name , metav1.GetOptions {})
645
+ framework .ExpectNoError (err )
646
+ gomega .Expect (len (pod .Status .Conditions )).To (gomega .BeEquivalentTo (1 ))
647
+ gomega .Expect (pod .Status .Conditions [0 ].Type ).To (gomega .BeEquivalentTo (v1 .PodScheduled ))
648
+ gomega .Expect (pod .Status .Conditions [0 ].ObservedGeneration ).To (gomega .BeEquivalentTo (1 ))
649
+
634
650
// Force assign the Pod to a node in order to get rejection status.
635
651
binding := & v1.Binding {
636
652
ObjectMeta : metav1.ObjectMeta {
@@ -650,7 +666,7 @@ var _ = SIGDescribe("Pods Extended (pod generation)", feature.PodObservedGenerat
650
666
framework .ExpectNoError (err )
651
667
652
668
// Fetch the rejected Pod and verify the generation and observedGeneration.
653
- gotPod , err := f . ClientSet . CoreV1 (). Pods ( pod . Namespace ) .Get (ctx , pod .Name , metav1.GetOptions {})
669
+ gotPod , err := podClient .Get (ctx , pod .Name , metav1.GetOptions {})
654
670
framework .ExpectNoError (err )
655
671
gomega .Expect (gotPod .Generation ).To (gomega .BeEquivalentTo (1 ))
656
672
gomega .Expect (gotPod .Status .ObservedGeneration ).To (gomega .BeEquivalentTo (1 ))
0 commit comments