mirror of
https://github.com/containers/podman
synced 2024-10-21 01:34:37 +00:00
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>
This commit is contained in:
parent
a0c9be2061
commit
28bead8be8
|
@ -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")
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -2038,6 +2038,7 @@ _podman_ps() {
|
|||
--quiet -q
|
||||
--size -s
|
||||
--namespace --ns
|
||||
--sync
|
||||
"
|
||||
_complete_ "$options_with_args" "$boolean_options"
|
||||
}
|
||||
|
|
|
@ -103,6 +103,13 @@ Valid filters are listed below:
|
|||
|
||||
Print usage statement
|
||||
|
||||
**--sync**
|
||||
|
||||
Force a sync of container state with the OCI runtime.
|
||||
In some cases, a container's state in the runtime can become out of sync with Podman's state.
|
||||
This will update Podman's state based on what the OCI runtime reports.
|
||||
Forcibly syncing is much slower, but can resolve inconsistent state issues.
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
```
|
||||
|
|
|
@ -26,7 +26,7 @@ to run containers such as CRI-O, the last started container could be from either
|
|||
|
||||
**--sync**
|
||||
|
||||
Force a sync of container state with the OCI runtime before attempting to remove.
|
||||
Force a sync of container state with the OCI runtime before attempting to remove the container.
|
||||
In some cases, a container's state in the runtime can become out of sync with Podman's state,
|
||||
which can cause Podman to refuse to remove containers because it believes they are still running.
|
||||
A sync will resolve this issue.
|
||||
|
|
Loading…
Reference in a new issue