-
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
Add --time option for podman * rm -f flag #11763
Conversation
Might make @edsantiago happy in #11762 |
571823e
to
ba902af
Compare
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.
Other than the mini nits, LGTM
test/e2e/checkpoint_test.go
Outdated
@@ -159,7 +159,7 @@ var _ = Describe("Podman checkpoint", func() { | |||
Expect(result).Should(Exit(2)) | |||
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1)) | |||
|
|||
result = podmanTest.Podman([]string{"rm", "-f", cid}) | |||
result = podmanTest.Podman([]string{"rm", "-t", 0, "-f", cid}) |
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.
0 -> "0"
in all _test.go files.
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 is why I shouldn't code late at night.
pkg/domain/infra/abi/containers.go
Outdated
if options.Force && options.Timeout != nil { | ||
// Ignore errors, ic.removeContainer will catch them | ||
parallelctr.ContainerOp(ctx, ctrs, func(c *libpod.Container) error { | ||
return c.StopWithTimeout(*options.Timeout) |
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 this be moved inside the other ContainerOp function below. I don't think it is necessary to stop all container before we start to remove them.
Also should we really ignore all errors?
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.
Moved
@Luap99 good idea. |
@rhatdan needs a rebase |
Yeah, my fault with the bats-cleanup PR. Sorry! And, thank you! |
@@ -193,6 +193,10 @@ func (ic *ContainerEngine) ContainerRm(ctx context.Context, namesOrIds []string, | |||
} | |||
reports := make([]*entities.RmReport, 0, len(ctrs)) | |||
for _, c := range ctrs { | |||
if opts.Force && opts.Timeout != nil { | |||
// Ignore errors, containers.Remove will catch them | |||
containers.Stop(ic.ClientCtx, c.ID, &containers.StopOptions{Timeout: opts.Timeout}) |
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.
Why are we doing this? Remove already stops containers if force is specified?
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 just strikes me as potentially buggy - we ignore all errors that could occur with stopping the container... Seems like it would be a lot safer to add a Timeout arg to the libpod RemoveContainer function?
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.
There is some nasty plumbing to do. We will still try to stop the container within the remove stage if it is not stopped, so I don't believe there is any risk.
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 allows us to stop them first without a timeout of 0.
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 can be removed now I think
bbaa835
to
3c7017e
Compare
This CI error actually looks real:
|
@mheon I expanded the PR to handle, pod, network and volume, and fully plumbed this into libpod. |
cmd/podman/volumes/rm.go
Outdated
@@ -43,6 +45,10 @@ func init() { | |||
flags := rmCommand.Flags() | |||
flags.BoolVarP(&rmOptions.All, "all", "a", false, "Remove all volumes") | |||
flags.BoolVarP(&rmOptions.Force, "force", "f", false, "Remove a volume by force, even if it is being used by a container") | |||
timeFlagName := "time" | |||
flags.UintVarP(&stopTimeout, timeFlagName, "t", containerConfig.Engine.StopTimeout, "Seconds to wait for pod stop before killing the container") |
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.
Is this message right? I'm not sure of it or my suggestion...
flags.UintVarP(&stopTimeout, timeFlagName, "t", containerConfig.Engine.StopTimeout, "Seconds to wait for pod stop before killing the container") | |
flags.UintVarP(&stopTimeout, timeFlagName, "t", containerConfig.Engine.StopTimeout, "Seconds to wait for the container to stop before removing the volume") |
@@ -15,6 +15,10 @@ Delete one or more Podman networks. | |||
The `force` option will remove all containers that use the named network. If the container is | |||
running, the container will be stopped and removed. | |||
|
|||
#### **--time**, **-t**=*time* | |||
|
|||
Time to wait before forcibly stopping the container. The --force option must be specified to use the --time option. |
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.
container or network?
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.
or maybe "the container that the network is attached to."
@@ -33,6 +33,10 @@ Stop running containers and delete all stopped containers before removal of pod. | |||
|
|||
Read pod ID from the specified file and remove the pod. Can be specified multiple times. | |||
|
|||
#### **--time**, **-t**=*time* | |||
|
|||
Time to wait before forcibly stopping the container. The --force option must be specified to use the --time option. |
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.
pod or container?
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.
or "containers within the pod".
@@ -28,6 +28,9 @@ If it is being used by containers, the containers will be removed first. | |||
|
|||
Print usage statement | |||
|
|||
#### **--time**, **-t**=*time* | |||
|
|||
Time to wait before forcibly stopping the container. The --force option must be specified to use the --time option. |
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 here if you take similar comments.
@@ -114,4 +114,4 @@ podman pod kill foobar | |||
######## | |||
# Remove all pods and their containers | |||
######## | |||
podman pod rm -fa | |||
podman pod rm -t 0 -fa |
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.
Maybe I missed it, but I don't recall seeing a -t value for anything other than zero. It would be nice to have at least a small handful with values other than zero.
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.
Added some.
b2e7372
to
b7df5f9
Compare
9571746
to
6fe5496
Compare
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.
There is still remote wiring to do, pkg/domain/infra/tunnel
does not set the timeout option for the network/volume rm bindings.
@@ -15,6 +15,10 @@ Delete one or more Podman networks. | |||
The `force` option will remove all containers that use the named network. If the container is | |||
running, the container will be stopped and removed. | |||
|
|||
#### **--time**, **-t**=*time* |
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.
#### **--time**, **-t**=*time* | |
#### **--time**, **-t**=*seconds* |
Please change this to seconds everywhere. A user has no idea what time means.
@@ -193,6 +193,10 @@ func (ic *ContainerEngine) ContainerRm(ctx context.Context, namesOrIds []string, | |||
} | |||
reports := make([]*entities.RmReport, 0, len(ctrs)) | |||
for _, c := range ctrs { | |||
if opts.Force && opts.Timeout != nil { | |||
// Ignore errors, containers.Remove will catch them | |||
containers.Stop(ic.ClientCtx, c.ID, &containers.StopOptions{Timeout: opts.Timeout}) |
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 can be removed now I think
Add --time flag to podman container rm Add --time flag to podman pod rm Add --time flag to podman volume rm Add --time flag to podman network rm Signed-off-by: Daniel J Walsh <[email protected]>
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
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Luap99, 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 |
/lgtm |
Add --time options to
podman container rm
podman pod rm
podman volume rm
podman network rm
Signed-off-by: Daniel J Walsh [email protected]