From 333f664da7ef96462d5e72aaa8a24a17c3e648b8 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Sun, 14 Jan 2018 15:18:01 -0500 Subject: 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 Closes: #223 Approved by: rhatdan --- libpod/container.go | 15 +++------------ 1 file 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() } -- cgit v1.2.3-54-g00ecf