From a0c9be20617a871c6cb61f27516565af36338d7a Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Wed, 28 Nov 2018 12:24:14 -0500 Subject: 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 --- cmd/podman/rm.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'cmd/podman') diff --git a/cmd/podman/rm.go b/cmd/podman/rm.go index 7c0569b78..224df4543 100644 --- a/cmd/podman/rm.go +++ b/cmd/podman/rm.go @@ -20,6 +20,10 @@ var ( Usage: "Force removal of a running container. The default is false", }, LatestFlag, + cli.BoolFlag{ + Name: "sync", + Usage: "Sync container state with OCI runtime before removing", + }, cli.BoolFlag{ Name: "volumes, v", Usage: "Remove the volumes associated with the container (Not implemented yet)", @@ -73,6 +77,12 @@ func rmCmd(c *cli.Context) error { for _, container := range delContainers { con := container f := func() error { + if c.Bool("sync") { + if err := con.Sync(); err != nil { + return err + } + } + return runtime.RemoveContainer(ctx, con, c.Bool("force")) } -- cgit v1.2.3-54-g00ecf