Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kill: wait for the container #16177

Merged
merged 1 commit into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion libpod/container_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,12 @@ func (c *Container) Kill(signal uint) error {

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.
Expand Down
3 changes: 3 additions & 0 deletions libpod/container_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,10 @@ func (c *Container) stop(timeout uint) error {

c.newContainerEvent(events.Stop)
c.state.StoppedByUser = true
return c.waitForConmonToExitAndSave()
}

func (c *Container) waitForConmonToExitAndSave() error {
conmonAlive, err := c.ociRuntime.CheckConmonRunning(c)
if err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions test/e2e/attach_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ var _ = Describe("Podman attach", func() {
Expect(results.OutputToString()).To(ContainSubstring("test"))
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
})

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could have cheated on the test checker. :^)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:-D this came from looking at test failures

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.WaitWithDefaultTimeout()
Expand Down