Skip to content

Commit 88e3c95

Browse files
authored
Merge pull request kubernetes#94647 from pohly/ephemeral-fixes
storage E2E: explicitly wait for PV deletion after ephemeral test
2 parents 686ffd3 + 16635f5 commit 88e3c95

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/e2e/storage/testsuites/provisioning.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,28 @@ func StopPodAndDependents(c clientset.Interface, pod *v1.Pod) {
725725
} else {
726726
framework.Logf("Pod %s has the following logs: %s", pod.Name, body)
727727
}
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+
728750
framework.Logf("Deleting pod %q in namespace %q", pod.Name, pod.Namespace)
729751
deletionPolicy := metav1.DeletePropagationForeground
730752
err = c.CoreV1().Pods(pod.Namespace).Delete(context.TODO(), pod.Name,
@@ -742,6 +764,14 @@ func StopPodAndDependents(c clientset.Interface, pod *v1.Pod) {
742764
}
743765
framework.Logf("Wait up to %v for pod %q to be fully deleted", e2epod.PodDeleteTimeout, pod.Name)
744766
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+
}
745775
}
746776

747777
func verifyPVCsPending(client clientset.Interface, pvcs []*v1.PersistentVolumeClaim) {

0 commit comments

Comments
 (0)