Repository navigation
fix: remove stale containers holding project volumes on ddev delete, fixes #8777 - #8950
Merged
Merged
Conversation
…fixes ddev#8777 Stale `ddev-utilities` containers from an interrupted start keep the database volume mounted but carry an empty `com.ddev.site-name` label, so `ddev delete` could not find them. The volume removal failed, yet the project was unregistered and reported as deleted, leaving an orphaned volume. `Stop()` now removes DDEV-labeled containers that still mount a core volume before removing it, unregisters the project only after all core volumes are gone, and returns an error naming any held volume so `ddev delete` can be run again. The "volume in use" branch in `RemoveVolume()` compared the whole error string and never matched. It now matches on the Docker and Podman wording and prints container names.
|
Download this PR's build for your OS and architecture with: ddev utility download-ddev --pr 8950Or download the artifact for your OS and architecture directly:
See Testing a PR. |
stasadev
approved these changes
Oct 16, 2026
stasadev
left a comment
Member
There was a problem hiding this comment.
Looks good to me.
Thank you for such a simple reproduction.
|
🎉 This PR is included in the v1.25.5 release. |
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.
Short Summary (TL;DR)
ddev deletenow removes the stale utility containers that keep a project's database volume busy, and it no longer unregisters the project or reports success when a volume could not be removed.The Issue
ddev deleteorphans the database volume when a stale utility container holds it #8777When a
ddev startis interrupted, short-livedddev-utilitiescontainers stay behind with the database volume mounted. They carry an emptycom.ddev.site-namelabel, soddev deletecannot find them. The volume removal fails with a warning, but the project is unregistered anyway and "Project X was deleted" is printed. The volume is then orphaned and noddevcommand can reach it.How This PR Solves The Issue
Before removing each core volume,
Stop()removes every DDEV-labeled container that still mounts it, found with Docker'svolumefilter. Containers without thecom.ddev.platform=ddevlabel are left alone, so a container the user created is never removed.The project is unregistered only after all core volumes are gone. If one is still held,
Stop()returns an error that names the volume and says the project stays listed, soddev deletecan be run again after the cause is fixed.The "volume in use" branch in
RemoveVolume()compared the whole error string and never matched, so users saw truncated container IDs. It now matches on the wording Docker and Podman use, and prints container names with adocker rm -fhint.Manual Testing Instructions
To see the retry path, run the
docker runline again without the two--labelflags and runddev delete -Oy. Expect an error namingheld-mariadb, no "was deleted" line, and the project still inddev list.Automated Testing Overview
TestStopRemoveDataRemovesStaleUtilityContainersandTestStopRemoveDataKeepsProjectListedWhenVolumeIsHeldinpkg/ddevapp/delete_test.gocreate a project volume held by an exited container, with and without the DDEV label, and check the delete and the retry path.TestRemoveVolumeInUseNamesContainerinpkg/dockerutil/volumes_test.gochecks that a held volume produces the error with the container name.Release/Deployment Notes
ddev deletenow exits non-zero and keeps the project listed when a volume could not be removed. Before, it reported success in that case.