summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorMatthew Heon <mheon@redhat.com>2018-11-28 12:24:14 -0500
committerMatthew Heon <mheon@redhat.com>2018-12-06 09:10:45 -0500
commita0c9be20617a871c6cb61f27516565af36338d7a (patch)
treeef09e2cd5bda4a87fc6c8b3ac735cdf6615065b0 /libpod
parent75b19ca8abe1957f3c48035767960a6b20c10519 (diff)
downloadpodman-a0c9be20617a871c6cb61f27516565af36338d7a.tar.gz
podman-a0c9be20617a871c6cb61f27516565af36338d7a.tar.bz2
podman-a0c9be20617a871c6cb61f27516565af36338d7a.zip
Add --sync option to podman rm
With the changes made recently to ensure Podman does not hit the OCI runtime as often to sync state, we can find ourselves in a situation where the runtime's state does not match ours. Add a --sync flag to podman rm to ensure we can still remove containers when this happens. Signed-off-by: Matthew Heon <mheon@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_api.go22
1 files changed, 11 insertions, 11 deletions
diff --git a/libpod/container_api.go b/libpod/container_api.go
index bc92cae69..ee060ad6a 100644
--- a/libpod/container_api.go
+++ b/libpod/container_api.go
@@ -675,22 +675,22 @@ 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
- }
-
// 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
}