pkg/containerutil: update restart.StatusLabel to Stopped when stopping container - #5156
Open
VedantMadane wants to merge 2 commits into
Open
pkg/containerutil: update restart.StatusLabel to Stopped when stopping container#5156VedantMadane wants to merge 2 commits into
VedantMadane wants to merge 2 commits into
Conversation
…g container (containerd#5153) When a container with a restart policy (such as --restart=always) is explicitly stopped or killed via nerdctl stop / nerdctl kill, update the containerd.io/restart.status label to containerd.Stopped so that containerd's restart monitor does not automatically restart the explicitly stopped container. Signed-off-by: Vedant Madane <6527493+VedantMadane@users.noreply.github.com>
Member
|
Can we have an integration test? |
…ll (containerd#5153) Add TestRunRestartAlwaysStop and TestRunRestartAlwaysKill to verify that containers created with --restart=always transition containerd.io/restart.status to stopped and remain exited after being stopped or killed. Signed-off-by: Vedant Madane <6527493+VedantMadane@users.noreply.github.com>
Contributor
Author
|
Added integration tests in \cmd/nerdctl/container/container_run_restart_linux_test.go\ (\TestRunRestartAlwaysStop\ and \TestRunRestartAlwaysKill) to verify that containers created with --restart=always\ transition \containerd.io/restart.status\ to \stopped\ and remain in \exited\ status when explicitly stopped or killed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #5153.
When running a container with --restart=always\ or --restart=unless-stopped, containerd's restart monitor daemon uses the \containerd.io/restart.status\ label to determine whether an exited container should be automatically restarted (when the label value is
unning).
Previously, while \containerutil.Start\ updated the
estart.StatusLabel\ to \containerd.Running\ on startup, \containerutil.Stop\ and \pkg/cmd/container.killContainer\ only updated \containerd.io/restart.explicitly-stopped\ without transitioning \containerd.io/restart.status\ to \containerd.Stopped. This caused containerd's restart monitor to still observe the status as
unning\ and restart the container after an explicit
erdctl stop\ or
erdctl kill.
This PR ensures \containerutil.Stop\ and \killContainer\ update
estart.StatusLabel\ to \containerd.Stopped\ when a container with a restart policy is stopped or killed, aligning with Docker and containerd restart behavior.
Checklist