mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 07:27:21 +00:00
add pod util to verify pod is terminal
pods on phase succeeded or failed are guaranteed to have all containers stopped and to not ever regress
This commit is contained in:
@@ -301,6 +301,16 @@ func IsPodReady(pod *v1.Pod) bool {
|
||||
return IsPodReadyConditionTrue(pod.Status)
|
||||
}
|
||||
|
||||
// IsPodTerminal returns true if a pod is terminal, all containers are stopped and cannot ever regress.
|
||||
func IsPodTerminal(pod *v1.Pod) bool {
|
||||
return IsPodPhaseTerminal(pod.Status.Phase)
|
||||
}
|
||||
|
||||
// IsPhaseTerminal returns true if the pod's phase is terminal.
|
||||
func IsPodPhaseTerminal(phase v1.PodPhase) bool {
|
||||
return phase == v1.PodFailed || phase == v1.PodSucceeded
|
||||
}
|
||||
|
||||
// IsPodReadyConditionTrue returns true if a pod is ready; false otherwise.
|
||||
func IsPodReadyConditionTrue(status v1.PodStatus) bool {
|
||||
condition := GetPodReadyCondition(status)
|
||||
|
||||
Reference in New Issue
Block a user