diff options
author | Matthew Heon <matthew.heon@pm.me> | 2020-10-20 14:32:33 -0400 |
---|---|---|
committer | Matthew Heon <matthew.heon@pm.me> | 2020-10-21 13:31:40 -0400 |
commit | cddfe3983be63ee5193a19fb6669600f059a839f (patch) | |
tree | 92a74d3f25a7a2548d4cff9cb5986b424d38be5c /libpod/pod_status.go | |
parent | 36682115b0f3f5f7cfcc6bc4580e5a7435b9a4d8 (diff) | |
download | podman-cddfe3983be63ee5193a19fb6669600f059a839f.tar.gz podman-cddfe3983be63ee5193a19fb6669600f059a839f.tar.bz2 podman-cddfe3983be63ee5193a19fb6669600f059a839f.zip |
Add a Degraded state to pods
Make a distinction between pods that are completely running (all
containers running) and those that have some containers going,
but not all, by introducing an intermediate state between Stopped
and Running called Degraded. A Degraded pod has at least one, but
not all, containers running; a Running pod has all containers
running.
First step to a solution for #7213.
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'libpod/pod_status.go')
-rw-r--r-- | libpod/pod_status.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/libpod/pod_status.go b/libpod/pod_status.go index f4ccf308a..668d45ec7 100644 --- a/libpod/pod_status.go +++ b/libpod/pod_status.go @@ -10,10 +10,10 @@ func (p *Pod) GetPodStatus() (string, error) { if err != nil { return define.PodStateErrored, err } - return CreatePodStatusResults(ctrStatuses) + return createPodStatusResults(ctrStatuses) } -func CreatePodStatusResults(ctrStatuses map[string]define.ContainerStatus) (string, error) { +func createPodStatusResults(ctrStatuses map[string]define.ContainerStatus) (string, error) { ctrNum := len(ctrStatuses) if ctrNum == 0 { return define.PodStateCreated, nil @@ -43,8 +43,10 @@ func CreatePodStatusResults(ctrStatuses map[string]define.ContainerStatus) (stri } switch { - case statuses[define.PodStateRunning] > 0: + case statuses[define.PodStateRunning] == ctrNum: return define.PodStateRunning, nil + case statuses[define.PodStateRunning] > 0: + return define.PodStateDegraded, nil case statuses[define.PodStatePaused] == ctrNum: return define.PodStatePaused, nil case statuses[define.PodStateStopped] == ctrNum: |