Conversation
…n undeploy fails
When the Docker daemon is unreachable, compose down fails and the stack
record becomes undeletable through the UI, leaving the user stuck.
Add a force=true query parameter to DELETE /stacks/{id} that, when set,
proceeds with stack record + file removal even if the underlying
undeploy step fails. Default behavior is unchanged.
The force flag is an explicit opt-in because silently force-deleting on
any docker failure could leak running containers; surfacing the choice
to the caller lets the user accept that risk only when they need to.
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.
closes #13178
Summary
When the Docker daemon is unreachable from the Portainer container (e.g. the socket is not mounted), compose down fails — and because that failure also blocks DataStore.Stack().Delete(), the broken stack becomes undeletable through the UI. The user is stuck with a stack record that points to nothing and cannot be cleaned up without fixing socket connectivity first.
This change adds a force=true query parameter to DELETE /stacks/{id} that, when set, proceeds with the Portainer-side cleanup (DB record, resource control, project files) even if the underlying undeploy step returns an error. Default behavior is unchanged: without force, the existing 500 response and record-preserved behavior is identical to today.
Why an explicit opt-in
Silently force-deleting on any docker failure could leak running containers — the daemon may have been only briefly unavailable, in which case unstop'd containers would remain after the Portainer record is gone. Surfacing the choice as a query parameter lets the caller accept that risk only when they need to.
Changes
Follow-up (not in this PR)
The frontend currently has no way to send force=true. A small UI follow-up to expose this as a confirmation option in the stack delete flow would make sense once the API shape is settled — happy to submit that as a separate PR after this one is reviewed.
Test plan