Skip to content

Commit af91e76

Browse files
committed
e2epod: use foreground deletion
This is useful in case that the pod owns some resources, because then waiting for the pod ensures that those resources also were removed. This should not matter at the moment because pods typically are not owners of any other object, but that will change with the introduction of generic ephemeral inline volumes (https://github.com/kubernetes/enhancements/tree/master/keps/sig-storage/1698-generic-ephemeral-volumes).
1 parent 32fdf68 commit af91e76

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

test/e2e/framework/pod/delete.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func DeletePodOrFail(c clientset.Interface, ns, name string) {
4848
}
4949

5050
// DeletePodWithWait deletes the passed-in pod and waits for the pod to be terminated. Resilient to the pod
51-
// not existing.
51+
// not existing. Also waits for all owned resources to be deleted.
5252
func DeletePodWithWait(c clientset.Interface, pod *v1.Pod) error {
5353
if pod == nil {
5454
return nil
@@ -57,10 +57,17 @@ func DeletePodWithWait(c clientset.Interface, pod *v1.Pod) error {
5757
}
5858

5959
// DeletePodWithWaitByName deletes the named and namespaced pod and waits for the pod to be terminated. Resilient to the pod
60-
// not existing.
60+
// not existing. Also waits for all owned resources to be deleted.
6161
func DeletePodWithWaitByName(c clientset.Interface, podName, podNamespace string) error {
6262
e2elog.Logf("Deleting pod %q in namespace %q", podName, podNamespace)
63-
err := c.CoreV1().Pods(podNamespace).Delete(context.TODO(), podName, metav1.DeleteOptions{})
63+
deletionPolicy := metav1.DeletePropagationForeground
64+
err := c.CoreV1().Pods(podNamespace).Delete(context.TODO(), podName,
65+
metav1.DeleteOptions{
66+
// If the pod is the owner of some resources (like ephemeral inline volumes),
67+
// then we want to be sure that those are also gone before we return.
68+
// Blocking pod deletion via metav1.DeletePropagationForeground achieves that.
69+
PropagationPolicy: &deletionPolicy,
70+
})
6471
if err != nil {
6572
if apierrors.IsNotFound(err) {
6673
return nil // assume pod was already deleted

0 commit comments

Comments
 (0)