-
Notifications
You must be signed in to change notification settings - Fork 561
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
Fix issue in nerdctl rm. #57
Conversation
Signed-off-by: Shishir Mahajan <smahajan@roblox.com>
Issue: Currently (on master HEAD), if I have a
It will error out if it is not able to remove one of the containers e.g. In this case, it is not able to remove the The correct behavior should be to remove the containers it can ( This PR fixes this issue.
/cc @AkihiroSuda |
rm.go
Outdated
msg = "Stop" | ||
} | ||
|
||
_, err := fmt.Fprintf(clicontext.App.Writer, "Error response from daemon: You cannot remove a %v container %v. %s the container before attempting removal or force remove\n", status.Status, id, msg) |
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.
Not really "Error response from daemon". I don't think the error message needs to 100% correspond to Docker.
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.
I agree it doesn't need to be 100% matching to docker 🙂
I felt it just makes it easier for someone who is transitioning from docker CLI to nerdctl
Either way, let me know what do you want me to change it to? and I will update the message.
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.
I think we can just remove ""Error response from daemon: " part.
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.
Fixed.
rm.go
Outdated
@@ -144,9 +141,18 @@ func removeContainer(ctx context.Context, client *containerd.Client, id string, | |||
} | |||
default: | |||
if !force { | |||
return errors.Errorf("cannot remove a %v container %v", status.Status, id) | |||
var msg string | |||
if status.Status == containerd.Paused || status.Status == containerd.Running { |
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 we move these comparison to switch
?
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.
Fixed.
Signed-off-by: Shishir Mahajan <smahajan@roblox.com>
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.
Thanks
Signed-off-by: Shishir Mahajan smahajan@roblox.com