Add opt-in volume cleanup to aspire stop - #20195
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 20195Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 20195" |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟡 Changes recommended
Container creation proceeds after the volume-readiness wait times out, even when volumes remain unready.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds opt-in persistent-volume deletion to aspire stop --force while preserving volumes by default.
Changes:
- Adds and validates
--volumes, forwarding it to DCP cleanup. - Registers named volumes as DCP resources and coordinates container startup.
- Adds unit, runtime, E2E, and localization coverage.
File summaries
| File | Description |
|---|---|
tests/Aspire.Hosting.Tests/WithVolumeTests.cs |
Tests named-volume preparation and deduplication. |
tests/Aspire.Hosting.Tests/DistributedApplicationTests.cs |
Verifies DCP volume readiness. |
tests/Aspire.Cli.Tests/Commands/StopCommandTests.cs |
Tests CLI validation, forwarding, and warnings. |
tests/Aspire.Cli.EndToEnd.Tests/StopForceTests.cs |
Covers volume preservation, deletion, and adoption. |
src/Aspire.Hosting/Dcp/DcpNameGenerator.cs |
Generates stable DCP volume identifiers. |
src/Aspire.Hosting/Dcp/DcpExecutor.cs |
Creates volumes before containers. |
src/Aspire.Hosting/Dcp/ContainerCreator.cs |
Produces DCP resources for named volumes. |
src/Aspire.Cli/Commands/StopCommand.cs |
Implements the --volumes option. |
src/Aspire.Cli/Commands/DcpWorkloadCleanupService.cs |
Forwards volume cleanup to DCP. |
src/Aspire.Cli/Resources/StopCommandStrings.resx |
Adds user-facing CLI strings. |
src/Aspire.Cli/Resources/StopCommandStrings.Designer.cs |
Exposes generated resource properties. |
src/Aspire.Cli/Resources/xlf/StopCommandStrings.cs.xlf |
Updates Czech localization resources. |
src/Aspire.Cli/Resources/xlf/StopCommandStrings.de.xlf |
Updates German localization resources. |
src/Aspire.Cli/Resources/xlf/StopCommandStrings.es.xlf |
Updates Spanish localization resources. |
src/Aspire.Cli/Resources/xlf/StopCommandStrings.fr.xlf |
Updates French localization resources. |
src/Aspire.Cli/Resources/xlf/StopCommandStrings.it.xlf |
Updates Italian localization resources. |
src/Aspire.Cli/Resources/xlf/StopCommandStrings.ja.xlf |
Updates Japanese localization resources. |
src/Aspire.Cli/Resources/xlf/StopCommandStrings.ko.xlf |
Updates Korean localization resources. |
src/Aspire.Cli/Resources/xlf/StopCommandStrings.pl.xlf |
Updates Polish localization resources. |
src/Aspire.Cli/Resources/xlf/StopCommandStrings.pt-BR.xlf |
Updates Portuguese localization resources. |
src/Aspire.Cli/Resources/xlf/StopCommandStrings.ru.xlf |
Updates Russian localization resources. |
src/Aspire.Cli/Resources/xlf/StopCommandStrings.tr.xlf |
Updates Turkish localization resources. |
src/Aspire.Cli/Resources/xlf/StopCommandStrings.zh-Hans.xlf |
Updates Simplified Chinese resources. |
src/Aspire.Cli/Resources/xlf/StopCommandStrings.zh-Hant.xlf |
Updates Traditional Chinese resources. |
Review details
Files not reviewed (1)
- src/Aspire.Cli/Resources/StopCommandStrings.Designer.cs: Generated file
- Files reviewed: 23/24 changed files
- Comments generated: 1
- Review effort level: Balanced
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Tests selector51 / 99 PR test projects · 4 PR jobs, from 25 changed files. Selected PR test projects (51 / 99)
Selected PR jobs (4)
How these were chosen — grouped by what changed
🔧 show 45
🧪 📦 affected project 🔧 🧪 🧪 🧪 🧪 Job reasons
Selection computed for commit |
There was a problem hiding this comment.
🔵 Needs a closer look
The supported DCP minimum still includes versions that cannot record volume ownership, causing requested cleanup to silently preserve volumes.
Review details
Files not reviewed (1)
- src/Aspire.Cli/Resources/StopCommandStrings.Designer.cs: Generated file
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
src/Aspire.Hosting/Dcp/ContainerCreator.cs:144
- This now relies on DCP's workload ownership records, but
DcpVersion.MinimumVersionInclusivestill permits DCP 0.23.3. DCP 0.25.13 and earlier create this persistent volume without recording ownership, so an otherwise supported 13.6 AppHost using an overridden older DCP will later runstop --force --volumessuccessfully while leaving the Aspire-created volume behind. Require DCP 0.26.0+ (where volume ownership/cleanup was added), or explicitly gate this feature on that capability.
- Files reviewed: 24/25 changed files
- Comments generated: 0 new
- Review effort level: Balanced
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
PR Testing ReportPR Information
Artifact Version Verification
The installed dogfood CLI version contains the PR head's short commit SHA, Changes AnalyzedChange Categories
Files Changed
Test Environment
Test Scenarios ExecutedScenario 1: Artifact baseline smokeObjective: Verify the matching PR CLI can generate, start, and stop a fresh empty C# AppHost. Coverage Type: Baseline happy path Steps:
Evidence:
Scenario 2: Default force cleanup preserves a DCP-owned volumeObjective: Verify existing Coverage Type: Compatibility/boundary Steps:
Evidence:
Scenario 3: Opt-in cleanup removes a DCP-owned volumeObjective: Verify Coverage Type: Feature happy path Steps:
Evidence:
Scenario 4: Pre-existing volume is adopted and preservedObjective: Verify DCP mounts a pre-existing named Docker volume but does not claim ownership or remove it during opt-in cleanup. Coverage Type: Ownership boundary Steps:
Evidence:
Observed mount: Scenario 5:
|
| Scenario | Status | Notes |
|---|---|---|
| Artifact baseline smoke | ✅ Passed | PR CLI generated, started, and stopped a fresh AppHost |
| Default force cleanup | ✅ Passed | DCP-owned volume preserved without --volumes |
| Opt-in volume cleanup | ✅ Passed | DCP-owned volume removed with --force --volumes |
| Pre-existing volume adoption | ✅ Passed | Exact volume mounted and preserved during cleanup |
| Invalid option combination | ✅ Passed | Rejected before cleanup with exit code 1 |
| Unready volume states | ✅ Passed | 4 focused source tests passed |
Overall Result
✅ PR VERIFIED
The PR artifact matches the current head commit and all approved scenarios passed. The behavior preserves volumes by default, deletes only DCP-owned volumes when explicitly requested, preserves adopted pre-existing volumes, and rejects unsafe option usage. No test containers or volumes remain after the run.
2f175f2
into
main
|
The CI build failed due to test failure(s) that appear unrelated to the PR changes. These may be flaky tests. Suspected flaky test(s):
Suggested actions:
You can re-run the failed jobs from the workflow run page. |
Description
aspire stop --forcecan clean up persistent containers and networks, but there was no supported way to also remove persistent volumes created for the AppHost. This adds explicit, opt-in volume cleanup while preserving volumes by default.Users can pass
--volumestogether with--force. Aspire forwards the request todcp cleanup --volumes, and Aspire.Hosting now creates DCPContainerVolumeresources for named mounts so DCP can track ownership. Container creation waits for those volumes to become ready, shared named volumes are deduplicated, and anonymous volumes and bind mounts are unchanged. Volumes that existed before the AppHost started are adopted for mounting but are not recorded as DCP-owned, so cleanup leaves them intact.Non-bundle .NET AppHosts older than Aspire.Hosting 13.6 receive a compatibility warning because they do not create the DCP volume ownership records required for cleanup.
User-facing usage
Preserve volumes while removing other persistent resources:
Also remove persistent volumes created by Aspire:
The new option is shown in command help as:
Validation included the complete
StopCommandTestsandWithVolumeTestsclasses, a container-runtime test verifying the DCP volume reachesReady, and a CLI end-to-end scenario covering default preservation, opt-in deletion, and adoption and preservation of a pre-existing volume.Fixes #19569
Checklist
<remarks />and<code />elements on your triple slash comments?