summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/compat/containers.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-02-05 04:41:41 -0500
committerGitHub <noreply@github.com>2021-02-05 04:41:41 -0500
commit42d4652fed759904bb51a5d3420724dc25009494 (patch)
treee75db0e16733dfbf688168293042e972f2b1c1c0 /pkg/api/handlers/compat/containers.go
parent4a0ae01261f2aa90c37d95b7cc4415682e96dead (diff)
parent05444cb2ccf29515e6cb8f2711c64213b7cb3325 (diff)
downloadpodman-42d4652fed759904bb51a5d3420724dc25009494.tar.gz
podman-42d4652fed759904bb51a5d3420724dc25009494.tar.bz2
podman-42d4652fed759904bb51a5d3420724dc25009494.zip
Merge pull request #9048 from matejvasek/apiv2_wait
Fix Docker APIv2 container wait endpoint
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) {