mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 12:15:52 +00:00
e2e framework: better error messages when pod has failed or completed
Getting a message about "pod ran to completion" is confusing when the pod hasn't been able to start at all. The failed state now has a different message. To address the previous ambiguity, the success state is described as "ran to completion successfully".
This commit is contained in:
parent
178f246bbc
commit
0bd901afea
@ -41,7 +41,11 @@ import (
|
|||||||
|
|
||||||
// errPodCompleted is returned by PodRunning or PodContainerRunning to indicate that
|
// errPodCompleted is returned by PodRunning or PodContainerRunning to indicate that
|
||||||
// the pod has already reached completed state.
|
// the pod has already reached completed state.
|
||||||
var errPodCompleted = fmt.Errorf("pod ran to completion")
|
var errPodCompleted = fmt.Errorf("pod ran to completion successfully")
|
||||||
|
|
||||||
|
// errPodFailed is returned by PodRunning or PodContainerRunning to indicate that
|
||||||
|
// the pod has already reached a permanent failue state.
|
||||||
|
var errPodFailed = fmt.Errorf("pod failed permanently")
|
||||||
|
|
||||||
// LabelLogOnPodFailure can be used to mark which Pods will have their logs logged in the case of
|
// LabelLogOnPodFailure can be used to mark which Pods will have their logs logged in the case of
|
||||||
// a test failure. By default, if there are no Pods with this label, only the first 5 Pods will
|
// a test failure. By default, if there are no Pods with this label, only the first 5 Pods will
|
||||||
|
@ -403,7 +403,9 @@ func WaitTimeoutForPodRunningInNamespace(c clientset.Interface, podName, namespa
|
|||||||
switch pod.Status.Phase {
|
switch pod.Status.Phase {
|
||||||
case v1.PodRunning:
|
case v1.PodRunning:
|
||||||
return true, nil
|
return true, nil
|
||||||
case v1.PodFailed, v1.PodSucceeded:
|
case v1.PodFailed:
|
||||||
|
return false, errPodFailed
|
||||||
|
case v1.PodSucceeded:
|
||||||
return false, errPodCompleted
|
return false, errPodCompleted
|
||||||
}
|
}
|
||||||
return false, nil
|
return false, nil
|
||||||
@ -441,7 +443,10 @@ func WaitForPodNoLongerRunningInNamespace(c clientset.Interface, podName, namesp
|
|||||||
func WaitTimeoutForPodReadyInNamespace(c clientset.Interface, podName, namespace string, timeout time.Duration) error {
|
func WaitTimeoutForPodReadyInNamespace(c clientset.Interface, podName, namespace string, timeout time.Duration) error {
|
||||||
return WaitForPodCondition(c, namespace, podName, "running and ready", timeout, func(pod *v1.Pod) (bool, error) {
|
return WaitForPodCondition(c, namespace, podName, "running and ready", timeout, func(pod *v1.Pod) (bool, error) {
|
||||||
switch pod.Status.Phase {
|
switch pod.Status.Phase {
|
||||||
case v1.PodFailed, v1.PodSucceeded:
|
case v1.PodFailed:
|
||||||
|
e2elog.Logf("The phase of Pod %s is %s which is unexpected, pod status: %#v", pod.Name, pod.Status.Phase, pod.Status)
|
||||||
|
return false, errPodFailed
|
||||||
|
case v1.PodSucceeded:
|
||||||
e2elog.Logf("The phase of Pod %s is %s which is unexpected, pod status: %#v", pod.Name, pod.Status.Phase, pod.Status)
|
e2elog.Logf("The phase of Pod %s is %s which is unexpected, pod status: %#v", pod.Name, pod.Status.Phase, pod.Status)
|
||||||
return false, errPodCompleted
|
return false, errPodCompleted
|
||||||
case v1.PodRunning:
|
case v1.PodRunning:
|
||||||
|
Loading…
Reference in New Issue
Block a user