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

--replace for containers and pods #6553

Merged
merged 3 commits into from
Jun 15, 2020

Conversation

vrothberg
Copy link
Member

@vrothberg vrothberg commented Jun 10, 2020

Add a --replace flag to podman {create,run} and podman pod create to allow for replacing and removing existing named containers and pods.

Use that flag in generate systemd to make the generated units more robust and remove named containers or pods even after a system crash.

Fixes: #5485

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 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-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 10, 2020
@vrothberg
Copy link
Member Author

@mheon @rhatdan PTAL

libpod/options.go Outdated Show resolved Hide resolved
@mheon
Copy link
Member

mheon commented Jun 10, 2020

Oh, can we force this to only be used when a name is explicitly specified? So error if podman run with --replace but no --name is given?

@vrothberg
Copy link
Member Author

vrothberg commented Jun 10, 2020

Oh, can we force this to only be used when a name is explicitly specified? So error if podman run with --replace but no --name is given?

I prefer to avoid a conflict as it will make the systemd generation easier (we don't have to look for a --name). If you feel strongly, I can make it work (approximate).

Add a `--replace` flag to the `container {create,run}` commands.
If another container with the same name already exists, it will
be replaced and removed.

Adding this flag is motivated by containers#5485 to make running Podman in systemd
units (or any other scripts/automation) more robust.  In case of a
crash, a container may not be removed by a sytemd unit anymore.  The
`--replace` flag allows for supporting crashes.

Signed-off-by: Valentin Rothberg <[email protected]>
Add a `--replace` flag to the `pod create` command.  If another pod with
the same name already exists, it will be replaced and removed.

Adding this flag is motivated by containers#5485 to make running Podman in systemd
units (or any other scripts/automation) more robust.  In case of a
crash, a pod may not be removed by a sytemd unit anymore.  The
`--replace` flag allows for supporting crashes.

Note that the `--replace` flag does not require the `--name` flag to be
set, so it can be set unconditionally in `podman generate systemd`.

Signed-off-by: Valentin Rothberg <[email protected]>
Use `--replace` for named containers and pods.  This will clean up
previous containers and podsthat may not have been removed after a
system crash.

Fixes: containers#5485
Signed-off-by: Valentin Rothberg <[email protected]>
@vrothberg vrothberg changed the title {create,run} --replace --replace for containers and pods Jun 15, 2020
@vrothberg
Copy link
Member Author

@mheon, I wired the flag into pod create and into the systemd units as well. The big --new pod PR was merged, so I could complete --replace.

@vrothberg
Copy link
Member Author

@giuseppe @rhatdan @TomSweeneyRedHat PTAL

@rhatdan
Copy link
Member

rhatdan commented Jun 15, 2020

LGTM

@mheon
Copy link
Member

mheon commented Jun 15, 2020

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 15, 2020
@openshift-merge-robot openshift-merge-robot merged commit 10c6c80 into containers:master Jun 15, 2020
@vrothberg vrothberg deleted the replace branch June 16, 2020 08:24
@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.

Problems with podman generate systemd
6 participants