fix use nerdctl stop a container but restart strategy still active
Hi @ningmingxiao. Thanks for your PR.
I'm waiting for a containerd member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.
Once the patch is verified, the new status will be reflected by the ok-to-test label.
I understand the commands that are listed here.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
@AkihiroSuda @junnplus I use nerdctl run -d --restart=always busybox sh -c "top" nerdctl stop containerid, this container always restart.but docker doesn't restart it
Although for compatibility with docker, but it is no different from unless-stopped, I take a conservative view.
How does Docker implement always and unless-stopped? Are they really same?
How does Docker implement
alwaysandunless-stopped? Are they really the same?
https://github.com/moby/moby/blob/b6dab55339382e2b6df0678a511a75c146daa45b/restartmanager/restartmanager.go#L128-L136
If a container is canceled, the canceled will be set to true.
https://github.com/moby/moby/blob/b6dab55339382e2b6df0678a511a75c146daa45b/restartmanager/restartmanager.go#L62-L64
If the container's canceled is true, ShouldRestart will return false, nil, ErrRestartCanceled no matter what restart policy the container is set
https://github.com/moby/moby/blob/b6dab55339382e2b6df0678a511a75c146daa45b/restartmanager/restartmanager.go#L85-L95).
Can you update the commit (and PR body) to explain what this change is and why its needed? Is there an issue open that describes the problem?
I use nerdctl with --restart=always to run a container,then use nerdctl stop it,but this container still auto start.
I use nerdctl with --restart=always to run a container,then use nerdctl stop it,but this container still auto start.
Why not use unless-stopped though? I understand trying to replicate some other behavior, but changing unless-stopped to be the same as always was not the original intent. Accepting this change would require deprecating unless-stopped to keep the options clean (which I don't think is what is expected here). There is value in using always a policy and using stop as a way to force a restart.
Is there another way we can give nerdctl more control of the behavior here while keeping always and unless-stopped with separate behavior?
I use nerdctl with --restart=always to run a container,then use nerdctl stop it,but this container still auto start.
Why not use
unless-stoppedthough? I understand trying to replicate some other behavior, but changingunless-stoppedto be the same asalwayswas not the original intent. Accepting this change would require deprecatingunless-stoppedto keep the options clean (which I don't think is what is expected here). There is value in usingalwaysa policy and using stop as a way to force a restart.Is there another way we can give nerdctl more control of the behavior here while keeping
alwaysandunless-stoppedwith separate behavior?
always and unless-stopped almost the same,except container with restart=always will auto start with daemon if container is not runing,so I add a func to start container wtih restart=always when containerd start
ping @dmcgowan
Do you have any suggestions for my pr? @AkihiroSuda
PR needs rebase.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
This PR is stale because it has been open 90 days with no activity. This PR will be closed in 7 days unless new comments are made or the stale label is removed.
This PR was closed because it has been stalled for 7 days with no activity.