Skip to content

Commit

Permalink
Merge pull request #9214 from rhatdan/wait
Browse files Browse the repository at this point in the history
Fix invalid wait condition on kill
  • Loading branch information
openshift-merge-robot authored Feb 3, 2021
2 parents e8db5bb + d87f54f commit 301e54d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/api/handlers/compat/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ func KillContainer(w http.ResponseWriter, r *http.Request) {
return
}
if sig == 0 || syscall.Signal(sig) == syscall.SIGKILL {
var opts entities.WaitOptions
if _, err := containerEngine.ContainerWait(r.Context(), []string{name}, opts); err != nil {
if _, err := utils.WaitContainer(w, r); err != nil {

utils.Error(w, "Something went wrong.", http.StatusInternalServerError, err)
return
}
Expand Down
9 changes: 9 additions & 0 deletions test/python/docker/test_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ def test_stop_container(self):
top.reload()
self.assertIn(top.status, ("stopped", "exited"))

def test_kill_container(self):
top = self.client.containers.get(TestContainers.topContainerId)
self.assertEqual(top.status, "running")

# Kill a running container and validate the state
top.kill()
top.reload()
self.assertIn(top.status, ("stopped", "exited"))

def test_restart_container(self):
# Validate the container state
top = self.client.containers.get(TestContainers.topContainerId)
Expand Down

0 comments on commit 301e54d

Please sign in to comment.