mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 02:09:56 +00:00
Merge pull request #29952 from fabianofranz/handle_container_terminated_pod_running_condition
Automatic merge from submit-queue Handle container terminated but pod still running in conditions Sometimes when you have a pod with more than one container, and the container runs and terminates really fast, `PodContainerRunning` can go into a state where the pod indicates it's still running, but the container is already terminated. Handle that condition by returning `ErrContainerTerminated` when it happens.
This commit is contained in:
commit
c2340870c6
@ -121,6 +121,10 @@ func DeploymentHasDesiredReplicas(c ExtensionsInterface, deployment *extensions.
|
|||||||
// 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")
|
||||||
|
|
||||||
|
// ErrContainerTerminated is returned by PodContainerRunning in the intermediate
|
||||||
|
// state where the pod indicates it's still running, but its container is already terminated
|
||||||
|
var ErrContainerTerminated = fmt.Errorf("container terminated")
|
||||||
|
|
||||||
// PodRunning returns true if the pod is running, false if the pod has not yet reached running state,
|
// PodRunning returns true if the pod is running, false if the pod has not yet reached running state,
|
||||||
// returns ErrPodCompleted if the pod has run to completion, or an error in any other case.
|
// returns ErrPodCompleted if the pod has run to completion, or an error in any other case.
|
||||||
func PodRunning(event watch.Event) (bool, error) {
|
func PodRunning(event watch.Event) (bool, error) {
|
||||||
@ -217,6 +221,9 @@ func PodContainerRunning(containerName string) watch.ConditionFunc {
|
|||||||
if s.Name != containerName {
|
if s.Name != containerName {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if s.State.Terminated != nil {
|
||||||
|
return false, ErrContainerTerminated
|
||||||
|
}
|
||||||
return s.State.Running != nil, nil
|
return s.State.Running != nil, nil
|
||||||
}
|
}
|
||||||
return false, nil
|
return false, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user