revert most of the changes, add comments
This commit is contained in:
parent
1f186fc662
commit
dbb24264aa
@ -1355,13 +1355,17 @@ func podNotPending(c clientset.Interface, podName, namespace string) wait.Condit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// waitForPodTerminatedInNamespace returns an error if it took too long for the pod
|
// waitForPodTerminatedInNamespace returns an error if it takes too long for the pod to terminate,
|
||||||
// to terminate or if the pod terminated with an unexpected reason.
|
// 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(c clientset.Interface, podName, reason, namespace string) error {
|
func waitForPodTerminatedInNamespace(c clientset.Interface, podName, reason, namespace string) error {
|
||||||
return WaitForPodCondition(c, namespace, podName, "terminated due to deadline exceeded", PodStartTimeout, func(pod *v1.Pod) (bool, error) {
|
return WaitForPodCondition(c, namespace, podName, "terminated due to deadline exceeded", PodStartTimeout, func(pod *v1.Pod) (bool, error) {
|
||||||
if pod.Status.Phase == v1.PodSucceeded || pod.Status.Phase == v1.PodFailed {
|
// Only consider Failed pods. Successful pods will be deleted and detected in
|
||||||
if reason == "" ||
|
// waitForPodCondition's Get call returning `IsNotFound`
|
||||||
strings.ToLower(strings.TrimSpace(pod.Status.Reason)) == strings.ToLower(strings.TrimSpace(reason)) {
|
if pod.Status.Phase == v1.PodFailed {
|
||||||
|
if pod.Status.Reason == reason { // short-circuit waitForPodCondition's loop
|
||||||
return true, nil
|
return true, nil
|
||||||
} else {
|
} else {
|
||||||
return true, fmt.Errorf("Expected pod %q in namespace %q to be terminated with reason %q, got reason: %q", podName, namespace, reason, pod.Status.Reason)
|
return true, fmt.Errorf("Expected pod %q in namespace %q to be terminated with reason %q, got reason: %q", podName, namespace, reason, pod.Status.Reason)
|
||||||
|
Loading…
Reference in New Issue
Block a user