summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorMatthew Heon <mheon@redhat.com>2018-11-28 12:48:58 -0500
committerMatthew Heon <mheon@redhat.com>2018-12-06 09:10:45 -0500
commit28bead8be8eb541cf0c78e6ee3a3963adc8d1d3a (patch)
tree4797664994d7a0639f40ab0526bbc0466d66a330 /cmd
parenta0c9be20617a871c6cb61f27516565af36338d7a (diff)
downloadpodman-28bead8be8eb541cf0c78e6ee3a3963adc8d1d3a.tar.gz
podman-28bead8be8eb541cf0c78e6ee3a3963adc8d1d3a.tar.bz2
podman-28bead8be8eb541cf0c78e6ee3a3963adc8d1d3a.zip
Add --sync flag to podman ps
The previous commit added support for --sync to podman rm to ensure state inconsistencies would not prevent containers from being removed. Add the flag to podman ps as well, so that all containers can be forcibly synced and all state inconsistencies resolved. Signed-off-by: Matthew Heon <mheon@redhat.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/ps.go5
-rw-r--r--cmd/podman/shared/container.go7
2 files changed, 12 insertions, 0 deletions
diff --git a/cmd/podman/ps.go b/cmd/podman/ps.go
index 0b03388a2..7a4a80769 100644
--- a/cmd/podman/ps.go
+++ b/cmd/podman/ps.go
@@ -200,6 +200,10 @@ var (
Usage: "Sort output by command, created, id, image, names, runningfor, size, or status",
Value: "created",
},
+ cli.BoolFlag{
+ Name: "sync",
+ Usage: "Sync container state with OCI runtime",
+ },
}
psDescription = "Prints out information about the containers"
psCommand = cli.Command{
@@ -260,6 +264,7 @@ func psCmd(c *cli.Context) error {
Size: c.Bool("size"),
Namespace: c.Bool("namespace"),
Sort: c.String("sort"),
+ Sync: c.Bool("sync"),
}
filters := c.StringSlice("filter")
diff --git a/cmd/podman/shared/container.go b/cmd/podman/shared/container.go
index d0e892961..90ce193f7 100644
--- a/cmd/podman/shared/container.go
+++ b/cmd/podman/shared/container.go
@@ -45,6 +45,7 @@ type PsOptions struct {
Sort string
Label string
Namespace bool
+ Sync bool
}
// BatchContainerStruct is the return obkect from BatchContainer and contains
@@ -126,6 +127,12 @@ func NewBatchContainer(ctr *libpod.Container, opts PsOptions) (PsContainerOutput
pso PsContainerOutput
)
batchErr := ctr.Batch(func(c *libpod.Container) error {
+ if opts.Sync {
+ if err := c.Sync(); err != nil {
+ return err
+ }
+ }
+
conState, err = c.State()
if err != nil {
return errors.Wrapf(err, "unable to obtain container state")