containerd icon indicating copy to clipboard operation
containerd copied to clipboard

fix use nerdctl stop a container but restart strategy still active

Open ningmingxiao opened this issue 3 years ago • 12 comments

ningmingxiao avatar May 20 '22 10:05 ningmingxiao

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.

k8s-ci-robot avatar May 20 '22 10:05 k8s-ci-robot

@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

ningmingxiao avatar May 20 '22 10:05 ningmingxiao

Although for compatibility with docker, but it is no different from unless-stopped, I take a conservative view.

junnplus avatar May 27 '22 03:05 junnplus

How does Docker implement always and unless-stopped? Are they really same?

AkihiroSuda avatar May 27 '22 05:05 AkihiroSuda

How does Docker implement always and unless-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).

pacoxu avatar Jun 07 '22 06:06 pacoxu

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.

ningmingxiao avatar Feb 11 '23 03:02 ningmingxiao

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?

dmcgowan avatar Feb 13 '23 05:02 dmcgowan

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?

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

ningmingxiao avatar Feb 14 '23 04:02 ningmingxiao

ping @dmcgowan

ningmingxiao avatar Feb 16 '23 01:02 ningmingxiao

Do you have any suggestions for my pr? @AkihiroSuda

ningmingxiao avatar Feb 17 '23 01:02 ningmingxiao

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.

k8s-ci-robot avatar Jan 20 '24 03:01 k8s-ci-robot

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.

github-actions[bot] avatar May 17 '24 00:05 github-actions[bot]

This PR was closed because it has been stalled for 7 days with no activity.

github-actions[bot] avatar May 24 '24 00:05 github-actions[bot]