diff options
author | Matej Vasek <mvasek@redhat.com> | 2021-02-01 20:13:04 +0100 |
---|---|---|
committer | Matej Vasek <mvasek@redhat.com> | 2021-02-03 22:10:27 +0100 |
commit | 4a219aa234ff4ed3cd9d139ca88d8d5da6406493 (patch) | |
tree | d7011e94569f586babaf59304a5db041cf33fd9f /pkg/api/handlers/compat | |
parent | fc385806dfe1d13a7d4e4bdaeea93a22a55bd3d4 (diff) | |
download | podman-4a219aa234ff4ed3cd9d139ca88d8d5da6406493.tar.gz podman-4a219aa234ff4ed3cd9d139ca88d8d5da6406493.tar.bz2 podman-4a219aa234ff4ed3cd9d139ca88d8d5da6406493.zip |
Implement Docker wait conditions
Signed-off-by: Matej Vasek <mvasek@redhat.com>
Diffstat (limited to 'pkg/api/handlers/compat')
-rw-r--r-- | pkg/api/handlers/compat/containers.go | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/pkg/api/handlers/compat/containers.go b/pkg/api/handlers/compat/containers.go index 86508f938..9c0893a80 100644 --- a/pkg/api/handlers/compat/containers.go +++ b/pkg/api/handlers/compat/containers.go @@ -23,10 +23,8 @@ import ( "github.com/docker/docker/api/types/container" "github.com/docker/go-connections/nat" "github.com/docker/go-units" - "github.com/gorilla/mux" "github.com/gorilla/schema" "github.com/pkg/errors" - "github.com/sirupsen/logrus" ) func RemoveContainer(w http.ResponseWriter, r *http.Request) { @@ -233,8 +231,11 @@ func KillContainer(w http.ResponseWriter, r *http.Request) { return } if sig == 0 || syscall.Signal(sig) == syscall.SIGKILL { - if _, err := utils.WaitContainer(w, r); err != nil { - + opts := entities.WaitOptions{ + Condition: []define.ContainerStatus{define.ContainerStateExited, define.ContainerStateStopped}, + Interval: time.Millisecond * 250, + } + if _, err := containerEngine.ContainerWait(r.Context(), []string{name}, opts); err != nil { utils.Error(w, "Something went wrong.", http.StatusInternalServerError, err) return } @@ -245,26 +246,8 @@ func KillContainer(w http.ResponseWriter, r *http.Request) { } func WaitContainer(w http.ResponseWriter, r *http.Request) { - var msg string // /{version}/containers/(name)/wait - exitCode, err := utils.WaitContainer(w, r) - if err != nil { - if errors.Cause(err) == define.ErrNoSuchCtr { - logrus.Warnf("container not found %q: %v", utils.GetName(r), err) - return - } - logrus.Warnf("failed to wait on container %q: %v", mux.Vars(r)["name"], err) - return - } - - utils.WriteResponse(w, http.StatusOK, handlers.ContainerWaitOKBody{ - StatusCode: int(exitCode), - Error: struct { - Message string - }{ - Message: msg, - }, - }) + utils.WaitContainerDocker(w, r) } func LibpodToContainer(l *libpod.Container, sz bool) (*handlers.Container, error) { |