diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-03-11 14:36:50 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-11 14:36:50 -0400 |
commit | 9bc27118b52442f941666b48eb07102a541ada16 (patch) | |
tree | 2d48ca4a710b423faac21bedd1aea709e3bc9189 | |
parent | dbb3de990bc11f838150a3c3d2f056a9693556f7 (diff) | |
parent | 846ed00684b959c7d31af4df8c3e723b45287936 (diff) | |
download | podman-9bc27118b52442f941666b48eb07102a541ada16.tar.gz podman-9bc27118b52442f941666b48eb07102a541ada16.tar.bz2 podman-9bc27118b52442f941666b48eb07102a541ada16.zip |
Merge pull request #5372 from sujil02/podstatus
Update start stop api to use pod status function.
-rw-r--r-- | pkg/api/handlers/libpod/pods.go | 39 |
1 files changed, 4 insertions, 35 deletions
diff --git a/pkg/api/handlers/libpod/pods.go b/pkg/api/handlers/libpod/pods.go index ee697b6b7..f93c8f8d5 100644 --- a/pkg/api/handlers/libpod/pods.go +++ b/pkg/api/handlers/libpod/pods.go @@ -172,7 +172,6 @@ func PodStop(w http.ResponseWriter, r *http.Request) { errors.Wrapf(err, "Failed to parse parameters for %s", r.URL.String())) return } - allContainersStopped := true name := utils.GetName(r) pod, err := runtime.LookupPod(name) if err != nil { @@ -180,26 +179,12 @@ func PodStop(w http.ResponseWriter, r *http.Request) { return } - // TODO we need to implement a pod.State/Status in libpod internal so libpod api - // users don't have to run through all containers. - podContainers, err := pod.AllContainers() + status, err := pod.GetPodStatus() if err != nil { utils.Error(w, "Something went wrong", http.StatusInternalServerError, err) return } - - for _, con := range podContainers { - containerState, err := con.State() - if err != nil { - utils.Error(w, "Something went wrong", http.StatusInternalServerError, err) - return - } - if containerState == define.ContainerStateRunning { - allContainersStopped = false - break - } - } - if allContainersStopped { + if status != define.PodStateRunning { utils.WriteResponse(w, http.StatusNotModified, "") return } @@ -218,34 +203,18 @@ func PodStop(w http.ResponseWriter, r *http.Request) { func PodStart(w http.ResponseWriter, r *http.Request) { runtime := r.Context().Value("runtime").(*libpod.Runtime) - allContainersRunning := true name := utils.GetName(r) pod, err := runtime.LookupPod(name) if err != nil { utils.PodNotFound(w, name, err) return } - - // TODO we need to implement a pod.State/Status in libpod internal so libpod api - // users don't have to run through all containers. - podContainers, err := pod.AllContainers() + status, err := pod.GetPodStatus() if err != nil { utils.Error(w, "Something went wrong", http.StatusInternalServerError, err) return } - - for _, con := range podContainers { - containerState, err := con.State() - if err != nil { - utils.Error(w, "Something went wrong", http.StatusInternalServerError, err) - return - } - if containerState != define.ContainerStateRunning { - allContainersRunning = false - break - } - } - if allContainersRunning { + if status == define.PodStateRunning { utils.WriteResponse(w, http.StatusNotModified, "") return } |