Skip to content

Commit

Permalink
Merge pull request #31150 from ncdc/handle-init-container-terminated-…
Browse files Browse the repository at this point in the history
…pod-running-condition

Automatic merge from submit-queue

Check init containers in PodContainerRunning

Sometimes when an init container runs and terminates quickly, 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.

See also #29952

@smarterclayton @fabianofranz
  • Loading branch information
Kubernetes Submit Queue committed Sep 19, 2016
2 parents 8afa8c7 + 8530ede commit 87b4078
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/client/unversioned/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,15 @@ func PodContainerRunning(containerName string) watch.ConditionFunc {
}
return s.State.Running != nil, nil
}
for _, s := range t.Status.InitContainerStatuses {
if s.Name != containerName {
continue
}
if s.State.Terminated != nil {
return false, ErrContainerTerminated
}
return s.State.Running != nil, nil
}
return false, nil
}
return false, nil
Expand Down

0 comments on commit 87b4078

Please sign in to comment.