mirror of
https://github.com/containers/podman.git
synced 2025-08-06 11:32:07 +08:00
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
This commit is contained in:
@ -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()
|
||||
}
|
||||
|
Reference in New Issue
Block a user