diff options
author | Valentin Rothberg <vrothberg@redhat.com> | 2022-07-05 12:18:27 +0200 |
---|---|---|
committer | Valentin Rothberg <vrothberg@redhat.com> | 2022-07-05 12:32:02 +0200 |
commit | b9aa4755559d50d39bee3f571734a1e17c0f08b2 (patch) | |
tree | 0f1bb2ecf5809a7ca8a92b182a56afd22d8d8a1a /libpod | |
parent | 773eead54e2e0877e92d5871625a6cc32c582d30 (diff) | |
download | podman-b9aa4755559d50d39bee3f571734a1e17c0f08b2.tar.gz podman-b9aa4755559d50d39bee3f571734a1e17c0f08b2.tar.bz2 podman-b9aa4755559d50d39bee3f571734a1e17c0f08b2.zip |
Sync: handle exit file
Make sure `Sync()` handles state transitions and exit codes correctly.
The function was only being called when batching which could render
containers in an unusable state when running concurrently with other
state-altering functions/commands since the state must be re-read from
the database before acting upon it.
Fixes: #14761
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/container_api.go | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/libpod/container_api.go b/libpod/container_api.go index f35cce772..39303eef6 100644 --- a/libpod/container_api.go +++ b/libpod/container_api.go @@ -761,19 +761,8 @@ func (c *Container) Sync() error { defer c.lock.Unlock() } - // If runtime knows about the container, update its status in runtime - // And then save back to disk - if c.ensureState(define.ContainerStateCreated, define.ContainerStateRunning, define.ContainerStatePaused, define.ContainerStateStopped, define.ContainerStateStopping) { - oldState := c.state.State - if err := c.ociRuntime.UpdateContainerStatus(c); err != nil { - return err - } - // Only save back to DB if state changed - if c.state.State != oldState { - if err := c.save(); err != nil { - return err - } - } + if err := c.syncContainer(); err != nil { + return err } defer c.newContainerEvent(events.Sync) |