Repository navigation
fix: return removal failures from rm -f - #5289
Open
sarankumar1325 wants to merge 1 commit into
Open
sarankumar1325 wants to merge 1 commit into
sarankumar1325 wants to merge 1 commit into
Conversation
`nerdctl rm -f` logged every error from the container walker and exited 0, so a container whose task deletion failed was left behind while the command reported success. In force mode, only ignore requests that match no container, which keeps `rm -f` idempotent, and return any real removal failure. Fixes containerd#5288 Assisted-by: Grok Bot Signed-off-by: sarankumar1325 <120080287+sarankumar1325@users.noreply.github.com>
Member
So why not run containerd? |
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.
Fixes #5288
nerdctl rm -flogged every error from the container walker and then returnednil, so a container whose task deletion really failed was left in place while the command exited 0.This change keeps
rm -fidempotent for names or IDs that match no container (still logged, exit 0, same as before), but returns any real removal failure, so the exit status reflects it. Without-f, behaviour is unchanged.The walk loop moves into a small
removeAllhelper that takes the walk function as a parameter, so the force and non-force paths can be unit tested without a containerd daemon.Testing
go test ./pkg/cmd/container/(newTestRemoveAllcovers found, missing and failing requests, with and without force)go vet ./pkg/cmd/container/,golangci-lint run ./pkg/cmd/container/...,go build ./cmd/nerdctlAI disclosure: I used an AI coding assistant to help with this change (noted with an
Assisted-bytrailer). I reviewed the change and the tests myself.