mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 07:27:21 +00:00
Merge pull request #21602 from ncdc/port-forward-kubectl-timeout-flake
Fix kubectl timeout test flake in e2e/portforward
This commit is contained in:
@@ -76,6 +76,9 @@ const (
|
||||
// TODO: Make this 30 seconds once #4566 is resolved.
|
||||
podStartTimeout = 5 * time.Minute
|
||||
|
||||
// How long to wait for the pod to no longer be running
|
||||
podNoLongerRunningTimeout = 30 * time.Second
|
||||
|
||||
// If there are any orphaned namespaces to clean up, this test is running
|
||||
// on a long lived cluster. A long wait here is preferably to spurious test
|
||||
// failures caused by leaked resources from a previous test run.
|
||||
@@ -799,6 +802,22 @@ func waitTimeoutForPodRunningInNamespace(c *client.Client, podName string, names
|
||||
})
|
||||
}
|
||||
|
||||
// Waits default amount of time (podNoLongerRunningTimeout) for the specified pod to stop running.
|
||||
// Returns an error if timeout occurs first.
|
||||
func waitForPodNoLongerRunningInNamespace(c *client.Client, podName string, namespace string) error {
|
||||
return waitTimeoutForPodNoLongerRunningInNamespace(c, podName, namespace, podNoLongerRunningTimeout)
|
||||
}
|
||||
|
||||
func waitTimeoutForPodNoLongerRunningInNamespace(c *client.Client, podName string, namespace string, timeout time.Duration) error {
|
||||
return waitForPodCondition(c, namespace, podName, "no longer running", timeout, func(pod *api.Pod) (bool, error) {
|
||||
if pod.Status.Phase == api.PodSucceeded || pod.Status.Phase == api.PodFailed {
|
||||
Logf("Found pod '%s' with status '%s' on node '%s'", podName, pod.Status.Phase, pod.Spec.NodeName)
|
||||
return true, nil
|
||||
}
|
||||
return false, nil
|
||||
})
|
||||
}
|
||||
|
||||
// waitForPodNotPending returns an error if it took too long for the pod to go out of pending state.
|
||||
func waitForPodNotPending(c *client.Client, ns, podName string) error {
|
||||
return waitForPodCondition(c, ns, podName, "!pending", podStartTimeout, func(pod *api.Pod) (bool, error) {
|
||||
|
||||
Reference in New Issue
Block a user