summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/compat/containers.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/api/handlers/compat/containers.go')
-rw-r--r--pkg/api/handlers/compat/containers.go29
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) {