diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2018-12-06 08:11:51 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-06 08:11:51 -0800 |
commit | 99bbbeb746820716610317fedd8d3918951a9d7d (patch) | |
tree | 3dd47005274a71a81bea1fad5d1507a24e4a2f60 /libpod/container_api.go | |
parent | 5a07644646f0a42c04d496930c3e3ba4696301f2 (diff) | |
parent | e5335fd74c7ed6fe0fa55bf33afbdab23ed687f1 (diff) | |
download | podman-99bbbeb746820716610317fedd8d3918951a9d7d.tar.gz podman-99bbbeb746820716610317fedd8d3918951a9d7d.tar.bz2 podman-99bbbeb746820716610317fedd8d3918951a9d7d.zip |
Merge pull request #1887 from mheon/rm_sync
Add --sync option to podman rm
Diffstat (limited to 'libpod/container_api.go')
-rw-r--r-- | libpod/container_api.go | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/libpod/container_api.go b/libpod/container_api.go index bc92cae69..09bc46905 100644 --- a/libpod/container_api.go +++ b/libpod/container_api.go @@ -675,22 +675,27 @@ func (c *Container) Batch(batchFunc func(*Container) error) error { return err } -// Sync updates the current state of the container, checking whether its state -// has changed -// Sync can only be used inside Batch() - otherwise, it will be done -// automatically. -// When called outside Batch(), Sync() is a no-op +// Sync updates the status of a container by querying the OCI runtime. +// If the container has not been created inside the OCI runtime, nothing will be +// done. +// Most of the time, Podman does not explicitly query the OCI runtime for +// container status, and instead relies upon exit files created by conmon. +// This can cause a disconnect between running state and what Podman sees in +// cases where Conmon was killed unexpected, or runc was upgraded. +// Running a manual Sync() ensures that container state will be correct in +// such situations. func (c *Container) Sync() error { if !c.batched { - return nil + c.lock.Lock() + defer c.lock.Unlock() } // If runtime knows about the container, update its status in runtime // And then save back to disk if (c.state.State != ContainerStateUnknown) && - (c.state.State != ContainerStateConfigured) { + (c.state.State != ContainerStateConfigured) && + (c.state.State != ContainerStateExited) { oldState := c.state.State - // TODO: optionally replace this with a stat for the exit file if err := c.runtime.ociRuntime.updateContainerStatus(c, true); err != nil { return err } |