-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show c/storage (Buildah/CRI-O) containers in ps #7290
Conversation
cmd/podman/containers/ps.go
Outdated
@@ -56,10 +57,10 @@ func init() { | |||
func listFlagSet(flags *pflag.FlagSet) { | |||
flags.BoolVarP(&listOpts.All, "all", "a", false, "Show all the containers, default is only running containers") | |||
flags.StringSliceVarP(&filters, "filter", "f", []string{}, "Filter output based on conditions given") | |||
flags.BoolVar(&listOpts.External, "external", true, "Show containers in storage not controlled by Podman") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think we should use --storage
here for consistency with podman rm --storage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am fine with this.
d25a551
to
aeef06e
Compare
ff2b7a7
to
985e7aa
Compare
libpod/runtime_ctr.go
Outdated
// StorageContainers returns a list of containers from containers/storage that | ||
// are not currently known to Podman. The list of containers passed in are all | ||
// of the containers known to Podman from the GetContainers() function. | ||
func (r *Runtime) StorageContainers() ([]*Container, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't make this return Libpod containers - having a bunch of semi-functional things wandering around calling themselves a libpod.Container is asking for trouble (they don't have valid locks, for example, we'll panic the moment someone tries to call a real Libpod function on one of them). I think we need a separate API for this, that returns something like []*StorageContainer - we can translate those into the PS container struct in pkg/domain, so the code in PS will remain unchanged.
docs/source/markdown/podman-ps.1.md
Outdated
|
||
Display containers that are not controlled by Podman but are stored in containers storage. These containers | ||
are generally created via other container technology such as Buildah or CRI-O and may depend on the | ||
same container images that Podman is using. These containers are denoted with a 'NA' in the COMMAND and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the 'NA' still apply? Your example shows 'Buildah`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, good catch.
docs/source/markdown/podman-ps.1.md
Outdated
@@ -32,12 +32,19 @@ all the containers information. By default it lists: | |||
|
|||
**--all**, **-a** | |||
|
|||
Show all the containers, default is only running containers | |||
Show all the containers including those created by other container technologies such as Buildah and CRI-O. The default displays only running containers created by Podman. Containers not created by Podman have an 'NA' status. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto 'NA' as to below.
libpod/runtime_ctr.go
Outdated
|
||
// We only have a store when doing all, storage or size, so skip this otherwise. | ||
if r.store == nil { | ||
return retCtrs, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be an error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure? All of the other checks ignore this issue and just return success?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having no store is something that we deliberately did ourselves - we should never be calling this in a case where the store is not set up, so returning an error seems correct
libpod/runtime_ctr.go
Outdated
return retCtrs, errors.Wrapf(err, "error reading list of all containers") | ||
} | ||
for _, container := range storeContainers { | ||
if _, err := r.state.Container(container.ID); err == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can use HasContainer
instead - is a lot faster
f1686ce
to
4cc6c75
Compare
@rhatdan gating issue, looks like a man page needs tweaking. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been wanting this feature for a long time, thank you!
I'd love to see tests, but that's hard: you need to interrupt a podman-build in just the right way. I'll see if I can figure it out for a followup PR.
/hold Possible bug. Will report in full in a few minutes, but I need time to investigate. Please do not merge yet. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logic bug. I happened to have leftover buildah containers on my system; as submitted, this PR was only showing them when I specified --all
but not with --storage
. Trivial fix.
(And, if you agree with my "non-running" doc change below, please include that too)
cmd/podman/containers/ps.go
Outdated
@@ -56,9 +57,9 @@ func init() { | |||
func listFlagSet(flags *pflag.FlagSet) { | |||
flags.BoolVarP(&listOpts.All, "all", "a", false, "Show all the containers, default is only running containers") | |||
flags.StringSliceVarP(&filters, "filter", "f", []string{}, "Filter output based on conditions given") | |||
flags.BoolVar(&listOpts.Storage, "storage", true, "Show containers in storage not controlled by Podman") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should default to false
@@ -68,7 +69,31 @@ func GetContainerLists(runtime *libpod.Runtime, options entities.ContainerListOp | |||
return nil, err | |||
} | |||
pss = append(pss, listCon) | |||
} | |||
|
|||
if options.All && options.Storage { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be ||
, not &&
'
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: rhatdan The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
I'd prefer it if we took the all flag out of the picture entirely, and only
gated this behind the storage flag.
…On Tue, Sep 1, 2020, 08:13 OpenShift CI Robot ***@***.***> wrote:
[APPROVALNOTIFIER] This PR is *APPROVED*
This pull-request has been approved by: *rhatdan
<#7290#>*
The full list of commands accepted by this bot can be found here
<https://go.k8s.io/bot-commands?repo=containers%2Fpodman>.
The pull request process is described here
<https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process>
Needs approval from an approver in each of these files:
- OWNERS <https://github.com/containers/podman/blob/master/OWNERS>
[rhatdan]
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#7290 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB3AOCBNKYMPN2TXLB6YYHLSDTQOLANCNFSM4P274LFA>
.
|
I was ambivalent at first -- it does significantly change the behavior of Disturbingly often I find myself in annoying situations where This still leaves the problem of removing those containers. |
I would really prefer the opposite, because I don't want people to see these containers and then try using them with other Podman commands. The output of This is really a no-win scenario - we can either show them and confuse people as to why they don't act like normal Podman containers, or not show them and confuse people as to why they see errors that their image is "in use". |
That's a good point. I defer to you in this matter. And I agree that it's a no-win. |
Proposed test: run a long build with a short timeout: @test "podman ps --storage" {
PODMAN_TIMEOUT=5 run_podman 124 build -t thiswillneverexist - <<EOF
FROM $IMAGE
RUN sleep 15
EOF
run_podman ps --storage
is "${lines[1]}" \
"[0-9a-f]\{12\} \+$IMAGE *buildah .* seconds ago .* storage .* ${PODMAN_TEST_IMAGE_NAME}-working-container" \
"podman ps --storage"
run_podman rm --storage -f "${lines[1]:0:12}"
} Requires minor surgery to |
We can discuss this next week, but I am preparing to make these containers first class within podman, IE allow podman ps -a to show them by default. Allow Users do not understand these and do not understand how to use them. If we make --storage the default and properly show that they are not libpod containers, I believe the user experience will be better for the users.
These containers are unknown by libpod but Podman should be able to deal with them. |
I second the thought of a post scrum chat on how ps should show the variety of containers next week, fwiw. |
Concur. I still have serious doubts (we can maybe get a few commands to work in an OK-ish way, but the vast majority of Podman will never work with these containers) |
Just a friendly ping to bump the issue up in the mailboxes. Let's chat in tomorrows water cooler. |
@vrothberg @giuseppe @mheon @baude @jwhonce @ashley-cui @QiWang19 This is less controversial now since the --format is defaulted to false. |
The `podman ps --all` command will now show containers that are under the control of other c/storage container systems and the new `ps --storage` option will show only containers that are in c/storage but are not controlled by libpod. In the below examples, the '*working-container' entries were created by Buildah. ``` podman ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 9257ef8c786c docker.io/library/busybox:latest ls /etc 8 hours ago Exited (0) 8 hours ago gifted_jang d302c81856da docker.io/library/busybox:latest buildah 30 hours ago storage busybox-working-container 7a5a7b099d33 localhost/tom:latest ls -alF 30 hours ago Exited (0) 30 hours ago hopeful_hellman 01d601fca090 localhost/tom:latest ls -alf 30 hours ago Exited (1) 30 hours ago determined_panini ee58f429ff26 localhost/tom:latest buildah 33 hours ago storage alpine-working-container podman ps --external CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES d302c81856da docker.io/library/busybox:latest buildah 30 hours ago external busybox-working-container ee58f429ff26 localhost/tom:latest buildah 33 hours ago external alpine-working-container ``` Signed-off-by: TomSweeneyRedHat <[email protected]> Signed-off-by: Daniel J Walsh <[email protected]>
I added more documentation to explain what these are to the podman build man page and tried to standardize on the term |
LGTM |
Restarted two tests (hopefully flakes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/hold cancel |
The
podman ps --all
command will now show containers thatare under the control of other c/storage container systems and
the new
ps --external
option will show only containers that arein c/storage but are not controlled by libpod.
In the below examples, the '*working-container' entries were created
by Buildah.
Signed-off-by: TomSweeneyRedHat [email protected]
Signed-off-by: Daniel J Walsh [email protected]