Skip to content

Commit

Permalink
Merge pull request kubernetes#113135 from soltysh/fix_storage_timeouts
Browse files Browse the repository at this point in the history
Wait for pod not running or gone in storage tests
  • Loading branch information
k8s-ci-robot authored Oct 18, 2022
2 parents 72ede5b + f2b9479 commit 8186ebd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions test/e2e/framework/pod/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,25 @@ func WaitForPodNameUnschedulableInNamespace(c clientset.Interface, podName, name
})
}

// WaitTimeoutForPodNoLongerRunningOrNotFoundInNamespace waits default amount of time (defaultPodDeletionTimeout)
// for the specified pod to stop running or disappear. Returns an error if timeout occurs first.
func WaitTimeoutForPodNoLongerRunningOrNotFoundInNamespace(c clientset.Interface, podName, namespace string) error {
return wait.PollImmediate(poll, defaultPodDeletionTimeout, func() (bool, error) {
pod, err := c.CoreV1().Pods(namespace).Get(context.TODO(), podName, metav1.GetOptions{})
if apierrors.IsNotFound(err) {
return true, nil
}
if err != nil {
return handleWaitingAPIError(err, true, "getting pod %s", podIdentifier(namespace, podName))
}
switch pod.Status.Phase {
case v1.PodFailed, v1.PodSucceeded:
return true, nil
}
return false, nil
})
}

// WaitForPodNameRunningInNamespace waits default amount of time (PodStartTimeout) for the specified pod to become running.
// Returns an error if timeout occurs first, or pod goes in to failed state.
func WaitForPodNameRunningInNamespace(c clientset.Interface, podName, namespace string) error {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/storage/ubernetes_lite_volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func PodsUseStaticPVsOrFail(f *framework.Framework, podCount int, image string)
e2epod.DeletePodOrFail(c, ns, config.pod.Name)
}
for _, config := range configs {
e2epod.WaitForPodNoLongerRunningInNamespace(c, config.pod.Name, ns)
e2epod.WaitTimeoutForPodNoLongerRunningOrNotFoundInNamespace(c, config.pod.Name, ns)
e2epv.PVPVCCleanup(c, ns, config.pv, config.pvc)
err = e2epv.DeletePVSource(config.pvSource)
framework.ExpectNoError(err)
Expand Down

0 comments on commit 8186ebd

Please sign in to comment.