Skip to content

Conversation

@ningmingxiao
Copy link
Contributor

@ningmingxiao ningmingxiao commented Sep 15, 2025

some people want to use nerdctl to restart container created by k8s, It is necessary to return an error to forbid user start/restart the container.
ping @AkihiroSuda @djdongjin Thanks

@ningmingxiao ningmingxiao changed the title fix:don't support restart and start container created by k8s fix:forbid to restart/start container created by k8s Sep 15, 2025
return fmt.Errorf("can't get container %s info ", found.Container.ID())
}
if _, ok := info.Labels[k8slabels.ContainerType]; ok {
return fmt.Errorf("can't restart container %s created by k8s", info.ID)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Printing a warning may suffice

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, thanks

}
if _, ok := info.Labels[k8slabels.ContainerType]; ok {
log.L.Warnf("can't restart container %s created by k8s", info.ID)
return nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return nil

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if remove return nerdctl will try to restart container created by k8s @AkihiroSuda

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and the user will learn that it is an unsupported operation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@ningmingxiao ningmingxiao force-pushed the forbid_restart_k8s branch 3 times, most recently from 790f239 to f3b8f14 Compare September 17, 2025 07:49
Signed-off-by: ningmingxiao <ning.mingxiao@zte.com.cn>
Copy link
Member

@ChengyuZhu6 ChengyuZhu6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@AkihiroSuda AkihiroSuda merged commit 895a9eb into containerd:main Sep 25, 2025
97 of 107 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants