Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions test/e2e/framework/pod/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,13 +495,23 @@ func WaitForPodsWithSchedulingGates(ctx context.Context, c clientset.Interface,
return err
}

// WaitForPodTerminatedInNamespace returns an error if it takes too long for the pod to terminate,
// WaitForPodTerminatedInNamespace returns an error if it takes too long for the pod to terminate after podStartTimeout,
// if the pod Get api returns an error (IsNotFound or other), or if the pod failed (and thus did not
// terminate) with an unexpected reason. Typically called to test that the passed-in pod is fully
// terminated (reason==""), but may be called to detect if a pod did *not* terminate according to
// the supplied reason.
func WaitForPodTerminatedInNamespace(ctx context.Context, c clientset.Interface, podName, reason, namespace string) error {
return WaitForPodCondition(ctx, c, namespace, podName, fmt.Sprintf("terminated with reason %s", reason), podStartTimeout, func(pod *v1.Pod) (bool, error) {
return WaitForPodTerminatedInNamespaceTimeout(ctx, c, podName, reason, namespace, podStartTimeout)
}

// WaitForPodTerminatedInNamespaceTimeout returns an error if it takes too long
// for the pod to terminate after the provided timeout, if the pod Get api
// returns an error (IsNotFound or other), or if the pod failed (and thus did
// not terminate) with an unexpected reason. Typically called to test that the
// passed-in pod is fully terminated (reason==""), but may be called to detect
// if a pod did *not* terminate according to the supplied reason.
func WaitForPodTerminatedInNamespaceTimeout(ctx context.Context, c clientset.Interface, podName, reason, namespace string, timeout time.Duration) error {
return WaitForPodCondition(ctx, c, namespace, podName, fmt.Sprintf("terminated with reason %s", reason), timeout, func(pod *v1.Pod) (bool, error) {
// Only consider Failed pods. Successful pods will be deleted and detected in
// waitForPodCondition's Get call returning `IsNotFound`
if pod.Status.Phase == v1.PodFailed {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/node/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ var _ = SIGDescribe("Pods Extended", func() {
return podClient.Delete(ctx, pod.Name, metav1.DeleteOptions{})
})

err := e2epod.WaitForPodTerminatedInNamespace(ctx, f.ClientSet, pod.Name, "Evicted", f.Namespace.Name)
err := e2epod.WaitForPodTerminatedInNamespaceTimeout(ctx, f.ClientSet, pod.Name, "Evicted", f.Namespace.Name, 15*time.Minute)
if err != nil {
framework.Failf("error waiting for pod to be evicted: %v", err)
}
Expand Down