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

podman kube play --replace should force removal of pods and containers #20457

Merged
merged 2 commits into from
Oct 30, 2023

Conversation

rhatdan
Copy link
Member

@rhatdan rhatdan commented Oct 23, 2023

Fixes: #20025

Does this PR introduce a user-facing change?

None

[NO NEW TESTS NEEDED]

@openshift-ci openshift-ci bot added release-note-none approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Oct 23, 2023
@github-actions github-actions bot added the kind/api-change Change to remote API; merits scrutiny label Oct 23, 2023
Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

Please split the doc changes into a separate commit.

Looking purely at the changes, I don't think it's sufficient to fix #20025? Please add a regression test to make sure it does. The problem in #20025 is that "external" containers are not being removed/replaced, so we could probably do a buildah from --name=$expected-name and use that name in a kube YAML to cause a name collision.

@@ -42,6 +42,8 @@ type PlayOptions struct {
LogDriver *string
// LogOptions for the container. For example: journald
LogOptions *[]string
// Replace - replace existing pods and containers
Replace *bool
Copy link
Member

Choose a reason for hiding this comment

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

That screams for tests. It seems kube play --replace is not tested on the remote clients or the tests are incomplete.

Copy link
Member Author

Choose a reason for hiding this comment

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

It was being ignored on remote, since it was never setup to be passed in to remote side.

pkg/domain/infra/abi/play.go Show resolved Hide resolved
@rhatdan rhatdan force-pushed the pod branch 2 times, most recently from d152b6e to 83a097c Compare October 25, 2023 11:38
StaticIPs: staticIPs,
StaticMACs: staticMACs,
IsRemote: true,
UseLongAnnotations: query.NoTrunc,
Username: username,
Userns: query.Userns,
Copy link
Member

Choose a reason for hiding this comment

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

I like the alpha ordering, but man, GitHub doesn't make it easy to review.

Copy link
Member

Choose a reason for hiding this comment

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

IMO such changes should be part of a separate commit. That'll reduce the noise.

@TomSweeneyRedHat
Copy link
Member

LGTM

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

Code LGTM

I'd prefer @edsantiago's blessing on the test.

StaticIPs: staticIPs,
StaticMACs: staticMACs,
IsRemote: true,
UseLongAnnotations: query.NoTrunc,
Username: username,
Userns: query.Userns,
Copy link
Member

Choose a reason for hiding this comment

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

IMO such changes should be part of a separate commit. That'll reduce the noise.

# Force removal of container
run_podman rm --force -t0 test_pod-test
# Create container external using buildah with same name
buildah from --name test_pod-test $IMAGE
Copy link
Member

Choose a reason for hiding this comment

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

This probably needs a run buildah and status checks.

Copy link
Member

Choose a reason for hiding this comment

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

Not really. buildah here is much better than run buildah.

Reason: run is tricky. It hides exit status and output. In this case here, if plain buildah fails, BATS will immediately fail and will show all stdout/stderr. If you run buildah, though, you then need to add cumbersome if $status blah checks, and then will miss stdout/stderr if you check in the wrong order.

run_podman play kube $PODMAN_TMPDIR/test.yaml
# Force removal of container
run_podman rm --force -t0 test_pod-test
# Create container external using buildah with same name
Copy link
Member

Choose a reason for hiding this comment

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

However, I do find container external confusing. Should that be external container?

@@ -411,6 +411,23 @@ _EOF
run_podman rmi -f userimage:latest
}

@test "podman kube play --replace external storage" {
Copy link
Member

Choose a reason for hiding this comment

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

Also, as a general rule, when a test is super-confusing (like this one, WTF is it supposed to test) I like to add header comments like "Regression test for #12345; an external container, such as from buildah, caused a "container name is already in use" failure.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

Comment on lines +414 to +417
# Ocassionaly a remnant storage container is left behind which causes
# podman play kube --replace to fail. This tests created a conflicting
# storage container name using buildah to make sure --replace, still
# functions proplery by removing the storage container.
Copy link
Member

Choose a reason for hiding this comment

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

Typos (Occasionally, properly) and unclear wording ("tests created"), but the former will be fixed some day on the next spellcheck PR, and the latter is not worth a repush. (But if you have to repush for other reasons, please fix).

LGTM

Copy link
Member

@vrothberg vrothberg 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 openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Oct 30, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 30, 2023

[APPROVALNOTIFIER] This PR is APPROVED

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

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-ci openshift-ci bot merged commit 4871182 into containers:main Oct 30, 2023
99 checks passed
@rhatdan
Copy link
Member Author

rhatdan commented Oct 30, 2023

Seems to work.

$ buildah from --name dan alpine
dan
$ podman run --name dan alpine echo hi
Error: creating container storage: the container name "dan" is already in use by d296206717c64cd5c2988f3aabcf89cf38e7a2010ea52f083c5fd63d7398fbeb. You have to remove that container to be able to reuse that name: that name is already in use
$ podman run --replace --name dan alpine echo hi
dan
hi

@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 Jan 29, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 29, 2024
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. kind/api-change Change to remote API; merits scrutiny 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. release-note-none
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kube down should be able to remove "external" storage containers
4 participants