Merge pull request #16177 from vrothberg/fix-16142

kill: wait for the container
This commit is contained in:
OpenShift Merge Robot 2022-10-14 10:25:01 -04:00 committed by GitHub
commit b712736bd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 1 deletions

View File

@ -244,7 +244,12 @@ func (c *Container) Kill(signal uint) error {
c.newContainerEvent(events.Kill) c.newContainerEvent(events.Kill)
return c.save() // Make sure to wait for the container to exit in case of SIGKILL.
if signal == uint(unix.SIGKILL) {
return c.waitForConmonToExitAndSave()
}
return nil
} }
// Attach attaches to a container. // Attach attaches to a container.

View File

@ -1325,7 +1325,10 @@ func (c *Container) stop(timeout uint) error {
c.newContainerEvent(events.Stop) c.newContainerEvent(events.Stop)
c.state.StoppedByUser = true c.state.StoppedByUser = true
return c.waitForConmonToExitAndSave()
}
func (c *Container) waitForConmonToExitAndSave() error {
conmonAlive, err := c.ociRuntime.CheckConmonRunning(c) conmonAlive, err := c.ociRuntime.CheckConmonRunning(c)
if err != nil { if err != nil {
return err return err

View File

@ -82,6 +82,7 @@ var _ = Describe("Podman attach", func() {
Expect(results.OutputToString()).To(ContainSubstring("test")) Expect(results.OutputToString()).To(ContainSubstring("test"))
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1)) Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
}) })
It("podman attach to the latest container", func() { It("podman attach to the latest container", func() {
session := podmanTest.Podman([]string{"run", "-d", "--name", "test1", ALPINE, "/bin/sh", "-c", "while true; do echo test1; sleep 1; done"}) session := podmanTest.Podman([]string{"run", "-d", "--name", "test1", ALPINE, "/bin/sh", "-c", "while true; do echo test1; sleep 1; done"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()