Repository navigation
feat: add ddev utility delete-volume to remove a project's Docker volume, fixes #6961 - #8756
Merged
Merged
Conversation
ddev utility delete-volume to remove a project's Docker volumeddev utility delete-volume to remove a project's Docker volume, fixes #6961
…olume, fixes ddev#6961 This PR adds `ddev utility delete-volume`, which deletes a Docker volume belonging to the current project by its short docker-compose name or full Docker name, or lets you pick one from an interactive list. - Fixes ddev#6961 Add-ons like ddev-solr create their own named Docker volumes, and there was no built-in way to remove one without reaching for raw `docker volume rm` and guessing at the actual volume name. The command resolves the requested name against the project's own rendered docker-compose config (`app.ComposeYaml.Volumes`), so it correctly handles both the short compose-file key (`solr`) and whatever actual Docker volume name an add-on gives it (`name:`/`external:` overrides included), instead of guessing a naming convention. If no name is given, it shows an interactive picker (the same `promptui` used by `ddev snapshot restore`), with the database volume sorted last since it's normally the most destructive one to lose. Shared volumes used by every project (`ddev-global-cache`, `ddev-ssh-agent_socket_dir`) are excluded, since deleting them would affect other projects, not just the current one. If the project is running, the command asks to stop it first, since Docker won't remove a volume that's still mounted by a container; both that and the final deletion prompt are skippable with `--yes`. 1. In a project with an add-on that declares its own volume (e.g. ddev-solr), run `ddev utility delete-volume` with no arguments and confirm you get an interactive list with the database volume listed last. 2. Run `ddev utility delete-volume <short-name>` and `ddev utility delete-volume <full-docker-name>` and confirm both resolve to the same volume. 3. Run `ddev utility delete-volume ddev-global-cache` and confirm it's refused. 4. Start the project, then delete one of its volumes; confirm you're prompted to stop the project first and that it does so before deleting. `TestDebugDeleteVolumeCmd` in `cmd/ddev/cmd/debug-delete-volume_test.go` covers: rejecting an unknown volume name (and listing known volumes in the error), rejecting a shared/global volume name, stopping a running project and deleting its volume by short name, and deleting by full Docker name. None.
rfay
force-pushed
the
20260827_delete_volume
branch
from
August 27, 2026 17:40
96d7f5c to
add64b0
Compare
|
Download this PR's build for your OS and architecture with: ddev utility download-ddev --pr 8756Or download the artifact for your OS and architecture directly:
See Testing a PR. |
stasadev
reviewed
Aug 27, 2026
stasadev
left a comment
Member
There was a problem hiding this comment.
This is great!
Two things I noticed that I'd like to improve:
- When I deleted the volume and ran
ddev utility delete-volumeagain, it still appeared in the list, even though it no longer exists. - It would also be great if autocompletion worked here:
ddev utility delete-volume <TAB>
…tion Addresses review feedback on ddev#8756 (review 5044336433): - Only list/match volumes that still exist in Docker, so a volume already deleted no longer shows up in the interactive picker or the "unknown name" error listing. - Add shell tab completion for the volume-name argument, sourced from the same existing-volumes list.
Member
Author
|
Done! Pretty fancy for an off-beat utility function :) |
stasadev
added a commit
to stasadev/ddev
that referenced
this pull request
Oct 7, 2026
…hand ## Short Summary (TL;DR) The all-project-types job is the only CI job that runs tests with `GOTEST_SHORT` unset, and it ran a hand-kept list that had fallen behind, so 16 tests that skip or shrink under `GOTEST_SHORT` never ran in full anywhere. The list is now generated from the tests themselves, so it can't fall behind again. ## The Issue Found while working on ddev#7904, which changes `TestDebugRebuildCmd`: CI logs show `--- SKIP: TestDebugRebuildCmd` in every job, because Buildkite and `test-reusable.yml` set `GOTEST_SHORT=16` and apache-fpm sets `5`. The list came from ddev#6693 and broke in three ways: - ddev#7027 renamed `TestComposerCreateCmd` to `TestComposerCreateProjectCmd`, so that entry has matched nothing since. - ddev#8028 added `GOTEST_SHORT` skips to `TestDebugRebuildCmd`, `TestDdevImportDB`, `TestDdevRestoreSnapshot`, `TestProcessHooks`, and `TestWebserverMariaMySQLDBClient`, and later PRs did the same for `TestEphemeralPortsReusedOnRestart` (ddev#7992), `TestRouterPortSubstitutionPersistsAcrossProjects` (ddev#8653), `TestSnapshotUncompressed` (ddev#8704), `TestDebugDeleteVolumeCmd` (ddev#8756), and `TestDdevExportDB` (ddev#8798), none of them updating the list. - `TestComposerVersionConfig`, `TestHttpsRedirection`, `TestMysqlCommand`, `TestDdevStartMultipleHostnames`, and `TestProjectAutocompletionForExecCmd` already did less under `GOTEST_SHORT` when ddev#6693 wrote the list, and weren't on it. ## How This PR Solves The Issue Tests use three `testcommon` helpers instead of reading `GOTEST_SHORT`: `SkipIfGotestShort(t)`, `IsGotestShort(t)`, and `UsesAllTestSites(t)`, a marker for tests that loop over every test site. `.github/workflows/all-project-types-tests.sh` finds the tests that call them and prints the `-run` pattern, and fails if a test other than `TestMain` reads `GOTEST_SHORT` itself. The pattern is anchored, so prefix matches such as every `TestCmdStart*` test or `TestAutocompleteServiceForServiceFlag` no longer ride along; like `TestAppdirAlreadyInUse` and `TestConfigValidate`, which also leave the list, they don't depend on `GOTEST_SHORT` and run in every job. The `GOTEST_SHORT` branches that ddev#8028 made unreachable in `TestComposerCreateProjectCmd` and `TestDdevAllDatabases` are removed. ## Manual Testing Instructions ```bash .github/workflows/all-project-types-tests.sh # Expect ^(TestAutocompletionForDescribeCmd|...|TestWriteDrushConfig)\b with the 42 tests below ``` Adding `if os.Getenv("GOTEST_SHORT") != "" { t.Skip() }` to any test makes the script print that file and line and exit non-zero. ## Automated Testing Overview In the all-project-types job, the "Compute TESTARGS" step of `prepare-testargs` should print a `-run '^(...)\b'` pattern with exactly these 42 tests, and the test log should show each of them running, none skipped because of `GOTEST_SHORT`: ```text TestAutocompletionForDescribeCmd TestAutocompletionForStartCmd TestAutocompletionForStopCmd TestAvailableUpdates TestCmdDescribe TestCmdDescribeAppFunction TestCmdDescribeAppUsingSitename TestCmdList TestCmdStart TestCmdStop TestComposerCreateProjectCmd TestComposerVersionConfig TestConfigDatabaseVersion TestDdevAllDatabases TestDdevExportDB TestDdevFullSiteSetup TestDdevImportDB TestDdevImportFiles TestDdevImportFilesCustomUploadDir TestDdevImportFilesDir TestDdevRestoreSnapshot TestDdevStartMultipleHostnames TestDdevUploadDirNoPackage TestDdevXdebugEnabled TestDdevXhprofPrependEnabled TestDdevXhprofXhguiEnabled TestDebugDeleteVolumeCmd TestDebugRebuildCmd TestEphemeralPortsReusedOnRestart TestGetApps TestGetAppsEmpty TestHardenedStart TestHttpsRedirection TestMysqlCommand TestPHPConfig TestPHPWebserverType TestProcessHooks TestProjectAutocompletionForExecCmd TestRouterPortSubstitutionPersistsAcrossProjects TestSnapshotUncompressed TestWebserverMariaMySQLDBClient TestWriteDrushConfig ``` Some of the 16 tests that never ran in full may fail after being skipped this long; this PR's run is where that should show up. 🤖 Developed with assistance from [Claude Code](https://claude.ai/code) Co-Authored-By: Claude Opus 5.5 <[email protected]>
stasadev
added a commit
to stasadev/ddev
that referenced
this pull request
Oct 8, 2026
…hand ## Short Summary (TL;DR) The all-project-types job is the only CI job that runs tests with `GOTEST_SHORT` unset, and it ran a hand-kept list that had fallen behind, so 16 tests that skip or shrink under `GOTEST_SHORT` never ran in full anywhere. The list is now generated from the tests themselves, so it can't fall behind again. ## The Issue Found while working on ddev#7904, which changes `TestDebugRebuildCmd`: CI logs show `--- SKIP: TestDebugRebuildCmd` in every job, because Buildkite and `test-reusable.yml` set `GOTEST_SHORT=16` and apache-fpm sets `5`. The list came from ddev#6693 and broke in three ways: - ddev#7027 renamed `TestComposerCreateCmd` to `TestComposerCreateProjectCmd`, so that entry has matched nothing since. - ddev#8028 added `GOTEST_SHORT` skips to `TestDebugRebuildCmd`, `TestDdevImportDB`, `TestDdevRestoreSnapshot`, `TestProcessHooks`, and `TestWebserverMariaMySQLDBClient`, and later PRs did the same for `TestEphemeralPortsReusedOnRestart` (ddev#7992), `TestRouterPortSubstitutionPersistsAcrossProjects` (ddev#8653), `TestSnapshotUncompressed` (ddev#8704), `TestDebugDeleteVolumeCmd` (ddev#8756), and `TestDdevExportDB` (ddev#8798), none of them updating the list. - `TestComposerVersionConfig`, `TestHttpsRedirection`, `TestMysqlCommand`, `TestDdevStartMultipleHostnames`, and `TestProjectAutocompletionForExecCmd` already did less under `GOTEST_SHORT` when ddev#6693 wrote the list, and weren't on it. ## How This PR Solves The Issue Tests use three `testcommon` helpers instead of reading `GOTEST_SHORT`: `SkipIfGotestShort(t)`, `IsGotestShort(t)`, and `UsesAllTestSites(t)`, a marker for tests that loop over every test site. `.github/workflows/all-project-types-tests.sh` finds the tests that call them and prints the `-run` pattern, and fails if a test other than `TestMain` reads `GOTEST_SHORT` itself. The pattern is anchored, so prefix matches such as every `TestCmdStart*` test or `TestAutocompleteServiceForServiceFlag` no longer ride along; like `TestAppdirAlreadyInUse` and `TestConfigValidate`, which also leave the list, they don't depend on `GOTEST_SHORT` and run in every job. The `GOTEST_SHORT` branches that ddev#8028 made unreachable in `TestComposerCreateProjectCmd` and `TestDdevAllDatabases` are removed. ## Manual Testing Instructions ```bash .github/workflows/all-project-types-tests.sh # Expect ^(TestAutocompletionForDescribeCmd|...|TestWriteDrushConfig)\b with the 42 tests below ``` Adding `if os.Getenv("GOTEST_SHORT") != "" { t.Skip() }` to any test makes the script print that file and line and exit non-zero. ## Automated Testing Overview In the all-project-types job, the "Compute TESTARGS" step of `prepare-testargs` should print a `-run '^(...)\b'` pattern with exactly these 42 tests, and the test log should show each of them running, none skipped because of `GOTEST_SHORT`: ```text TestAutocompletionForDescribeCmd TestAutocompletionForStartCmd TestAutocompletionForStopCmd TestAvailableUpdates TestCmdDescribe TestCmdDescribeAppFunction TestCmdDescribeAppUsingSitename TestCmdList TestCmdStart TestCmdStop TestComposerCreateProjectCmd TestComposerVersionConfig TestConfigDatabaseVersion TestDdevAllDatabases TestDdevExportDB TestDdevFullSiteSetup TestDdevImportDB TestDdevImportFiles TestDdevImportFilesCustomUploadDir TestDdevImportFilesDir TestDdevRestoreSnapshot TestDdevStartMultipleHostnames TestDdevUploadDirNoPackage TestDdevXdebugEnabled TestDdevXhprofPrependEnabled TestDdevXhprofXhguiEnabled TestDebugDeleteVolumeCmd TestDebugRebuildCmd TestEphemeralPortsReusedOnRestart TestGetApps TestGetAppsEmpty TestHardenedStart TestHttpsRedirection TestMysqlCommand TestPHPConfig TestPHPWebserverType TestProcessHooks TestProjectAutocompletionForExecCmd TestRouterPortSubstitutionPersistsAcrossProjects TestSnapshotUncompressed TestWebserverMariaMySQLDBClient TestWriteDrushConfig ``` Some of the 16 tests that never ran in full may fail after being skipped this long; this PR's run is where that should show up. 🤖 Developed with assistance from [Claude Code](https://claude.ai/code) Co-Authored-By: Claude Opus 5.5 <[email protected]>
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)
This PR adds
ddev utility delete-volume, which deletes a Docker volume belonging to the current project by its short docker-compose name or full Docker name, or lets you pick one from an interactive list.The Issue
Add-ons like ddev-solr create their own named Docker volumes, and there was no built-in way to remove one without reaching for raw
docker volume rmand guessing at the actual volume name.How This PR Solves The Issue
The command resolves the requested name against the project's own rendered docker-compose config (
app.ComposeYaml.Volumes), so it correctly handles both the short compose-file key (solr) and whatever actual Docker volume name an add-on gives it (name:/external:overrides included), instead of guessing a naming convention. If no name is given, it shows an interactive picker (the samepromptuiused byddev snapshot restore), with the database volume sorted last since it's normally the most destructive one to lose. Shared volumes used by every project (ddev-global-cache,ddev-ssh-agent_socket_dir) are excluded, since deleting them would affect other projects, not just the current one. If the project is running, the command asks to stop it first, since Docker won't remove a volume that's still mounted by a container; both that and the final deletion prompt are skippable with--yes.Manual Testing Instructions
ddev utility delete-volumewith no arguments and confirm you get an interactive list with the database volume listed last.ddev utility delete-volume <short-name>andddev utility delete-volume <full-docker-name>and confirm both resolve to the same volume.ddev utility delete-volume ddev-global-cacheand confirm it's refused.Automated Testing Overview
TestDebugDeleteVolumeCmdincmd/ddev/cmd/debug-delete-volume_test.gocovers: rejecting an unknown volume name (and listing known volumes in the error), rejecting a shared/global volume name, stopping a running project and deleting its volume by short name, and deleting by full Docker name.Release/Deployment Notes
None.