mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
Merge pull request #18237 from yifan-gu/refactor_getphase
Auto commit by PR queue bot
This commit is contained in:
commit
2ef2544faa
@ -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
|
||||||
stopped++
|
}
|
||||||
if containerStatus.State.Terminated.ExitCode == 0 {
|
|
||||||
succeeded++
|
switch {
|
||||||
} else {
|
case containerStatus.State.Running != nil:
|
||||||
failed++
|
running++
|
||||||
}
|
case containerStatus.State.Terminated != nil:
|
||||||
} else if containerStatus.State.Waiting != nil {
|
stopped++
|
||||||
if containerStatus.LastTerminationState.Terminated != nil {
|
if containerStatus.State.Terminated.ExitCode == 0 {
|
||||||
stopped++
|
succeeded++
|
||||||
} else {
|
|
||||||
waiting++
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
unknown++
|
failed++
|
||||||
}
|
}
|
||||||
} else {
|
case containerStatus.State.Waiting != nil:
|
||||||
|
if containerStatus.LastTerminationState.Terminated != nil {
|
||||||
|
stopped++
|
||||||
|
} else {
|
||||||
|
waiting++
|
||||||
|
}
|
||||||
|
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")
|
||||||
|
Loading…
Reference in New Issue
Block a user