Skip to content
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

fix podman container exists and diff for storage containers #7908

Merged
merged 3 commits into from
Oct 19, 2020

Conversation

rhatdan
Copy link
Member

@rhatdan rhatdan commented Oct 3, 2020

Current these commands only check if a container exists in libpod. With
this fix, the commands will also check if they are in containers/storage.

This allows users to look at differences within a buildah or CRI-O container.

Currently buildah diff does not exists, so this helps out in that situation
as well as in CRI-O since the cri does not implement a diff command.

Signed-off-by: Daniel J Walsh [email protected]

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 3, 2020
@rhatdan
Copy link
Member Author

rhatdan commented Oct 3, 2020

@mrunalp PTAL
@containers/podman-maintainers PTAL

run_podman container exists myctr

# Create a container that podman does not know about
run buildah from $IMAGE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot guarantee having buildah in the test environment. I have a test for this (storage containers) in the works, but (sigh) it's in a side branch and I forgot to submit it last week. Basically it runs 'podman build', with a RUN sleep 15 but with PODMAN_TIMEOUT=5 so the build is likely to leave behind a buildah container. Unfortunately it also requires other changes to helpers.bash. May I submit that next week?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we need to do to make sure buildah is installed? It would seem a better solution especially as I add more container/storage features into podman,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in CI: go through the build-new-VMs dance. In Fedora/RHEL: add Requires: buildah to the -tests subpackage.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@edsantiago is this OK now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests would not pass if it was not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's OK in CI, but gating tests are failing because of missing buildah. On my list for today.

@mheon
Copy link
Member

mheon commented Oct 3, 2020 via email

@rhatdan
Copy link
Member Author

rhatdan commented Oct 4, 2020

Again, these will not happen by accident, you have to check by name if a container exists. I would be willing to add a flag to say we want a specific type, (But I would guess no one would ever use it, but by default we should do what human beings would expect).

@rhatdan rhatdan force-pushed the diff branch 2 times, most recently from da923e5 to 8509107 Compare October 5, 2020 00:49
@mheon
Copy link
Member

mheon commented Oct 5, 2020

It looks like Github managed to lose my response email, so pasting here:

My concern is that the exists command will answer true after a partially failed deletion, where we remove the container in the database but fail to remove it in c/storage. This has come up on a regular basis in Openstack. They use scripts to check that containers exist and work with them, recreating if necessary. I think what you are doing has real potential to break this workflow.

@rhatdan
Copy link
Member Author

rhatdan commented Oct 15, 2020

@edsantiago this tests just hit the timeout also "8 seconds"

@rhatdan
Copy link
Member Author

rhatdan commented Oct 15, 2020

@containers/podman-maintainers PTAL
This looks like it is ready to merge.

@rhatdan
Copy link
Member Author

rhatdan commented Oct 15, 2020

@mheon PTAL, this now does not do exists by default, you have to specify --external.

@mheon
Copy link
Member

mheon commented Oct 15, 2020

LGTM

@@ -12,10 +12,10 @@ var (
containerExistsDescription = `If the named container exists in local storage, podman container exists exits with 0, otherwise the exit code will be 1.`

existsCommand = &cobra.Command{
Use: "exists CONTAINER",
Use: "exists [flags] CONTAINER",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You've 'flags' here and 'options' in the man page, I think it should be options everywhere.

Suggested change
Use: "exists [flags] CONTAINER",
Use: "exists [options] CONTAINER",

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do this in a different PR. We exchange flags and options all over the place, and one of the tests is looking for flags.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grep -r Use.*'[flags' cmd | wc -l
82

@@ -2696,7 +2695,7 @@ _podman_ps() {
--pod -p
--quiet -q
--size -s
--storage
--external
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since you've another nit to fix, can you alphabetize this please? Also namespace on the line below.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to do this in a separate PR. Lets go through the entire contrib and alphabetize it all.


**--pod**, **-p**

Display the pods the containers are associated with

**--storage**
**--external**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alphabetize this option please

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -17,22 +17,30 @@ was an issue accessing the local storage.
**-h**, **--help**
Print usage statement

**--external**=*true|false*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move above help please

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@TomSweeneyRedHat
Copy link
Member

I'm fine with picking the man page nits in another PR. If @edsantiago thinks the testing end is gtg, then LGTM.

Current these commands only check if a container exists in libpod. With
this fix, the commands will also check if they are in containers/storage.

This allows users to look at differences within a buildah or CRI-O container.

Currently buildah diff does not exists, so this helps out in that situation
as well as in CRI-O since the cri does not implement a diff command.

Signed-off-by: Daniel J Walsh <[email protected]>
External containers are containers created outside of Podman.
For example Buildah and CRI-O Containers.

$ buildah from alpine
alpine-working-container
$ buildah run alpine-working-container touch /test
$ podman container exists --external alpine-working-container

$ podman container diff alpine-working-container
C /etc
A /test

Added --external flag to refer to external containers, rather then --storage.

Added --external for podman container exists and modified podman ps to use
--external rather then --storage.  It was felt that --storage would confuse
the user into thinking about changing the storage driver or options.

--storage is still supported through the use of aliases.

Finally podman contianer diff, does not require the --external flag, since it
there is little change of users making the mistake, and would just be a pain
for the user to remember the flag.

podman container exists --external is required because it could fool scripts
that rely on the existance of a Podman container, and there is a potential
for a partial deletion of a container, which could mess up existing users.

Signed-off-by: Daniel J Walsh <[email protected]>
@rhatdan
Copy link
Member Author

rhatdan commented Oct 16, 2020

@containers/podman-maintainers @saschagrunert This is ready to merge.

Copy link
Member

@saschagrunert saschagrunert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 19, 2020
@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rhatdan, saschagrunert

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit 7ffcab0 into containers:master Oct 19, 2020
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 24, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants