@@ -725,6 +725,28 @@ func StopPodAndDependents(c clientset.Interface, pod *v1.Pod) {
725
725
} else {
726
726
framework .Logf ("Pod %s has the following logs: %s" , pod .Name , body )
727
727
}
728
+
729
+ // We must wait explicitly for removal of the generic ephemeral volume PVs.
730
+ // For that we must find them first...
731
+ pvs , err := c .CoreV1 ().PersistentVolumes ().List (context .TODO (), metav1.ListOptions {})
732
+ framework .ExpectNoError (err , "list PVs" )
733
+ var podPVs []v1.PersistentVolume
734
+ for _ , pv := range pvs .Items {
735
+ if pv .Spec .ClaimRef == nil ||
736
+ pv .Spec .ClaimRef .Namespace != pod .Namespace {
737
+ continue
738
+ }
739
+ pvc , err := c .CoreV1 ().PersistentVolumeClaims (pod .Namespace ).Get (context .TODO (), pv .Spec .ClaimRef .Name , metav1.GetOptions {})
740
+ if err != nil && apierrors .IsNotFound (err ) {
741
+ // Must have been some unrelated PV, otherwise the PVC should exist.
742
+ continue
743
+ }
744
+ framework .ExpectNoError (err , "get PVC" )
745
+ if pv .Spec .ClaimRef .UID == pvc .UID && metav1 .IsControlledBy (pvc , pod ) {
746
+ podPVs = append (podPVs , pv )
747
+ }
748
+ }
749
+
728
750
framework .Logf ("Deleting pod %q in namespace %q" , pod .Name , pod .Namespace )
729
751
deletionPolicy := metav1 .DeletePropagationForeground
730
752
err = c .CoreV1 ().Pods (pod .Namespace ).Delete (context .TODO (), pod .Name ,
@@ -742,6 +764,14 @@ func StopPodAndDependents(c clientset.Interface, pod *v1.Pod) {
742
764
}
743
765
framework .Logf ("Wait up to %v for pod %q to be fully deleted" , e2epod .PodDeleteTimeout , pod .Name )
744
766
e2epod .WaitForPodNotFoundInNamespace (c , pod .Name , pod .Namespace , e2epod .PodDeleteTimeout )
767
+ if len (podPVs ) > 0 {
768
+ for _ , pv := range podPVs {
769
+ // As with CSI inline volumes, we use the pod delete timeout here because conceptually
770
+ // the volume deletion needs to be that fast (whatever "that" is).
771
+ framework .Logf ("Wait up to %v for pod PV %s to be fully deleted" , e2epod .PodDeleteTimeout , pv .Name )
772
+ e2epv .WaitForPersistentVolumeDeleted (c , pv .Name , 5 * time .Second , e2epod .PodDeleteTimeout )
773
+ }
774
+ }
745
775
}
746
776
747
777
func verifyPVCsPending (client clientset.Interface , pvcs []* v1.PersistentVolumeClaim ) {
0 commit comments