summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libpod/container_api.go2
-rw-r--r--libpod/container_internal.go8
-rw-r--r--libpod/runtime_ctr.go7
3 files changed, 9 insertions, 8 deletions
diff --git a/libpod/container_api.go b/libpod/container_api.go
index cd020e429..ef9c3f006 100644
--- a/libpod/container_api.go
+++ b/libpod/container_api.go
@@ -187,7 +187,7 @@ func (c *Container) StopWithTimeout(timeout uint) error {
c.state.State == define.ContainerStateExited {
return define.ErrCtrStopped
}
- defer c.newContainerEvent(events.Stop)
+
return c.stop(timeout)
}
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index 3114e00c0..aba9c5b93 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -1108,7 +1108,13 @@ func (c *Container) stop(timeout uint) error {
}
// Wait until we have an exit file, and sync once we do
- return c.waitForExitFileAndSync()
+ if err := c.waitForExitFileAndSync(); err != nil {
+ return err
+ }
+
+ c.newContainerEvent(events.Stop)
+
+ return nil
}
// Internal, non-locking function to pause a container
diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go
index e57ab4634..47d49f6aa 100644
--- a/libpod/runtime_ctr.go
+++ b/libpod/runtime_ctr.go
@@ -394,14 +394,9 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, force bool,
// Check that the container's in a good state to be removed
if c.state.State == config2.ContainerStateRunning {
- if err := c.ociRuntime.stopContainer(c, c.StopTimeout()); err != nil {
+ if err := c.stop(c.StopTimeout()); err != nil {
return errors.Wrapf(err, "cannot remove container %s as it could not be stopped", c.ID())
}
-
- // Need to update container state to make sure we know it's stopped
- if err := c.waitForExitFileAndSync(); err != nil {
- return err
- }
}
// Check that all of our exec sessions have finished