mirror of https://github.com/k3s-io/k3s
Merge pull request #49662 from jeffvance/e2e-pod-delete
Automatic merge from submit-queue (batch tested with PRs 49651, 49707, 49662, 47019, 49747) improve detectability of deleted pods **What this PR does / why we need it**: Adds comment to `waitForPodTerminatedInNamespace` to better explain how it's implemented. ~~It improves pod deletion detection in the e2e framework as follows:~~ ~~1. the `waitForPodTerminatedInNamespace` func looks for pod.Status.Phase == _PodFailed_ or _PodSucceeded_ since both values imply that all containers have terminated.~~ ~~2. the `waitForPodTerminatedInNamespace` func also ignores the pod's Reason if the passed-in `reason` parm is "". Reason is not really relevant to the pod being deleted or not, but if the caller passes a non-blank `reason` then it will be lower-cased, de-blanked and compared to the pod's Reason (also lower-cased and de-blanked). The idea is to make Reason checking more flexible and to prevent a pod from being considered running when all of its containers have terminated just because of a Reason mis-match.~~ Releated to pr [49597](https://github.com/kubernetes/kubernetes/pull/49597) and issue [49529](https://github.com/kubernetes/kubernetes/issues/49529). **Release note**: ```release-note NONE ```pull/6/head
commit
ff4330c6eb
|
@ -1385,15 +1385,20 @@ 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) {
|
||||||
|
// Only consider Failed pods. Successful pods will be deleted and detected in
|
||||||
|
// waitForPodCondition's Get call returning `IsNotFound`
|
||||||
if pod.Status.Phase == v1.PodFailed {
|
if pod.Status.Phase == v1.PodFailed {
|
||||||
if pod.Status.Reason == reason {
|
if pod.Status.Reason == reason { // short-circuit waitForPodCondition's loop
|
||||||
return true, nil
|
return true, nil
|
||||||
} else {
|
} else {
|
||||||
return true, fmt.Errorf("Expected pod %v in namespace %v to be terminated with reason %v, got reason: %v", 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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false, nil
|
return false, nil
|
||||||
|
|
Loading…
Reference in New Issue