diff options
author | Matthew Heon <matthew.heon@gmail.com> | 2018-01-14 15:18:01 -0500 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-01-16 14:32:38 +0000 |
commit | 333f664da7ef96462d5e72aaa8a24a17c3e648b8 (patch) | |
tree | 253654826b56543702864c1a871e379e000042c8 /libpod | |
parent | a7ad6e75ab967a51ee8dcd9c8dbc81c949e21d21 (diff) | |
download | podman-333f664da7ef96462d5e72aaa8a24a17c3e648b8.tar.gz podman-333f664da7ef96462d5e72aaa8a24a17c3e648b8.tar.bz2 podman-333f664da7ef96462d5e72aaa8a24a17c3e648b8.zip |
When performing state-changing operations, don't exec runtime
If we start a container and it does not error, we can assume the
container is now running. Subsequent API calls will sync for us
to see if it died, so we can just set ContainerStateRunning
instead of launching the runtime to explicitly get state.
The same logic applies to pause and unpause.
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Closes: #223
Approved by: rhatdan
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/container.go | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/libpod/container.go b/libpod/container.go index 7b0852c07..226985d9f 100644 --- a/libpod/container.go +++ b/libpod/container.go @@ -823,10 +823,7 @@ func (c *Container) Start() error { logrus.Debugf("Started container %s", c.ID()) - // Update container's state as it should be ContainerStateRunning now - if err := c.runtime.ociRuntime.updateContainerStatus(c); err != nil { - return err - } + c.state.State = ContainerStateRunning return c.save() } @@ -1030,10 +1027,7 @@ func (c *Container) Pause() error { logrus.Debugf("Paused container %s", c.ID()) - // Update container's state as it should be ContainerStatePaused now - if err := c.runtime.ociRuntime.updateContainerStatus(c); err != nil { - return err - } + c.state.State = ContainerStatePaused return c.save() } @@ -1058,10 +1052,7 @@ func (c *Container) Unpause() error { logrus.Debugf("Unpaused container %s", c.ID()) - // Update container's state as it should be ContainerStateRunning now - if err := c.runtime.ociRuntime.updateContainerStatus(c); err != nil { - return err - } + c.state.State = ContainerStateRunning return c.save() } |