Commit 2ef2544f authored by k8s-merge-robot's avatar k8s-merge-robot

Merge pull request #18237 from yifan-gu/refactor_getphase

Auto commit by PR queue bot
parents dd0d1fb7 4ac61295
...@@ -3007,29 +3007,33 @@ func GetPhase(spec *api.PodSpec, info []api.ContainerStatus) api.PodPhase { ...@@ -3007,29 +3007,33 @@ func GetPhase(spec *api.PodSpec, info []api.ContainerStatus) api.PodPhase {
succeeded := 0 succeeded := 0
unknown := 0 unknown := 0
for _, container := range spec.Containers { for _, container := range spec.Containers {
if containerStatus, ok := api.GetContainerStatus(info, container.Name); ok { containerStatus, ok := api.GetContainerStatus(info, container.Name)
if containerStatus.State.Running != nil { if !ok {
running++ unknown++
} else if containerStatus.State.Terminated != nil { continue
}
switch {
case containerStatus.State.Running != nil:
running++
case containerStatus.State.Terminated != nil:
stopped++
if containerStatus.State.Terminated.ExitCode == 0 {
succeeded++
} else {
failed++
}
case containerStatus.State.Waiting != nil:
if containerStatus.LastTerminationState.Terminated != nil {
stopped++ stopped++
if containerStatus.State.Terminated.ExitCode == 0 {
succeeded++
} else {
failed++
}
} else if containerStatus.State.Waiting != nil {
if containerStatus.LastTerminationState.Terminated != nil {
stopped++
} else {
waiting++
}
} else { } else {
unknown++ waiting++
} }
} else { default:
unknown++ unknown++
} }
} }
switch { switch {
case waiting > 0: case waiting > 0:
glog.V(5).Infof("pod waiting > 0, pending") glog.V(5).Infof("pod waiting > 0, pending")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment