Repository navigation
Stop the aspire doctor DCP probe gracefully instead of killing it - #21919
Conversation
DCP matches the stop PATCH media type exactly and returns 415 for 'application/merge-patch+json; charset=utf-8', so doctor always fell back to killing the DCP process tree. Send the bare media type (as DcpKubernetesClient does) and, once DCP accepts the stop, wait for it to exit before falling back to a kill. Co-authored-by: Copilot <[email protected]>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21919Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21919" |
Tests selector2 / 101 PR test projects · 4 PR jobs, from 2 changed files. Selected PR test projects (2 / 101)
Selected PR jobs (4)
How these were chosen — grouped by what changed📦 affected project 🧪 Job reasons
Selection computed for commit |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the change to gracefully shut down the DCP probe.
No open issues 🎉
What changed in this PR
Updates aspire doctor to shut down its DCP probe gracefully rather than immediately killing it. This addresses stop-request rejection separately from the cancellation-cleanup work in #21917.
Changes:
- Sends the exact
application/merge-patch+jsonmedia type without a charset. - Waits up to five seconds after an accepted stop request before falling back to killing DCP.
- Adds a regression test covering the exact header and graceful shutdown without a kill.
| File | Description |
|---|---|
tests/Aspire.Cli.Tests/Utils/DcpConnectionHealthCheckTests.cs |
Adds a fake DCP HTTP server and graceful-shutdown regression test. |
src/Aspire.Cli/Utils/EnvironmentChecker/DcpConnectionChecker.cs |
Corrects the stop-request header and adds a bounded graceful-exit wait. |
Review effort: Balanced
#21919 added a test that predates the CertificateManager.Create and DcpConnectionChecker signature changes from #22553. Co-authored-by: Copilot App <[email protected]>
<!-- copilot-assessment:v1 --> ### Agent assessment Self-reported assessment, not an independent review. Assessed revision: `a4a7fdc6e14c767da40d1a8cac4598d40a29ed78` | Dimension | Assessment | Rationale | |---|---|---| | Change confidence | 8.5/10 | ↑ All 14 image-build harness scenarios pass on Linux (node 24), including new pre-deadline and cleanup Docker/plugin 255 cases, which fail without the fix.<br>↑ DcpConnectionHealthCheckTests builds; the repaired test passes locally.<br>↑ All 61 AzureAppServiceTests pass locally with updated snapshots.<br>↓ Two DcpConnectionHealthCheckTests string assertions fail locally only due to a Spanish UI culture.<br>↓ Post-push CI not yet inspected at time of assessment. | | Diagnosis confidence | 9/10 | ↑ docker/cli v28.0.4 propagates WaitStatus.ExitStatus() (-1 for signaled plugins, exit 255).<br>↑ CI log shows CS7036 at DcpConnectionHealthCheckTests.cs:208-209 matching the #22553 signatures. | | Evidence fit | 8.5/10 | ↑ Regression reproduces the reviewer's fallback-and-exit-0 symptom.<br>↓ Not validated against a real Buildx plugin kill. | <!-- /copilot-assessment --> ## Description Shared CLI E2E image builds can exhaust their 45-minute job downloading from a throttled Azure Ubuntu apt mirror without reaching the existing error-only fallback. Bound primary attempts so default-source fallback also runs for slow or stalled builds. Independent fix based on `main`; relates to #21828, which is unchanged and is not a dependency. No auto-merge or bypass requested. - Share orchestration across the reusable image workflow and cache warmer. Apply a five-minute primary limit to .NET, polyglot base, Java and Go. Four primary attempts plus four 30-second cleanup grace periods leave 23 minutes within the unchanged 45-minute cap for fallback, setup and artifact handling. - TERM the client's process group so Docker can cancel its BuildKit session. Retry exactly once after ordinary failure or deadline, preserving both attempts' output and fallback status. A dependency-free Node supervisor tracks deadline and external signals independently, including cancellation during cleanup. External cancellation and forced kills, including an independently killed client, fail without fallback. - Preserve original Ubuntu apt sources and restore them for empty mirror arguments, including inherited Java/Go layers. Leave third-party sources untouched. - Add behavioral regressions, test-selection routes, cache-warmer filters and docs. No action pins, package manifests or product code changed. - Treat Docker exit 255 (a CLI plugin such as Buildx killed by a signal) as unconfirmed cancellation, before or during deadline cleanup, so it fails without fallback. - Fix the `main` build break in `tests/Aspire.Cli.Tests/Utils/DcpConnectionHealthCheckTests.cs`: the test added by #21919 used the pre-#22553 `CertificateManager.Create` and `DcpConnectionChecker` signatures (CS7036). It now passes `TemporaryStorage` like neighboring tests. - Fix the `main` test break in `AzureAppServiceTests.UserDefinedSlotConfigNames_AreMergedWithGeneratedStickySettings`: the snapshots from #21457 predate the `resourceId`/`resourceLocation` outputs added by #21396. ### Two-attempt root-cause evidence Both jobs ran at #21828 head `1ab3ad1e302a110bdb4f69ad4e3ee2e05d646d9a` in [run 42151619597](https://github.com/microsoft/aspire/actions/runs/42151619597). Both have annotation `The job has exceeded the maximum execution time of 45m0s`. | Attempt | Image job | Started / completed (UTC, November 6) | Exact apt log | | --- | --- | --- | --- | | 1 | [127676748230](https://github.com/microsoft/aspire/actions/runs/42151619597/job/127676748230) | 02:41:00 / 03:26:22 | `#11 2272.6 Fetched 82.4 MB in 37min 49s (36.3 kB/s)` | | 2 | [127692798471](https://github.com/microsoft/aspire/actions/runs/42151619597/job/127692798471) | 03:29:03 / 04:14:24 | `#11 2492.6 Fetched 108 MB in 41min 29s (43.4 kB/s)` | Attempt 2 then downloaded from HTTPS GitHub at `#11 2497.2 Fetched 15.1 MB in 0s (80.1 MB/s)`, while another mirror download logged `#15 92.37 Fetched 4031 kB in 1min 29s (45.4 kB/s)`. Both also reported GHA cache-import HTTP 400, `Our services aren't available right now`. Cold apt downloads, not product tests, consumed the image job. Neither attempt reached product-test execution using these images. No third rerun was triggered. ### Local validation `.\restore.cmd`: passed, 0 errors and 18 dependency-advisory warnings. Original selector coverage passed across appropriate hosts: 299 Windows managed cases, 2 Windows native MSBuild graph cases and 79 Linux shell/Git cases: ```powershell dotnet test --project tests\Infrastructure.Tests\Infrastructure.Tests.csproj --no-launch-profile -- --filter-namespace "Infrastructure.Tests.TestTriggerMap" --filter-not-class "*.PrComparisonBaseTests" --filter-not-class "*.SelectTestsCliTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true" # Passed: 299 dotnet test --project tests\Infrastructure.Tests\Infrastructure.Tests.csproj --no-launch-profile -- --filter-method "*.NativeDashboardSharedHelpersSelectNativeValidationInEnforceMode" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true" # Passed: 2 dotnet test --project tests\Infrastructure.Tests\Infrastructure.Tests.csproj --no-launch-profile -- --filter-class "*.TestTriggerMapTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true" # Passed: 179 after the final routing change dotnet run --project tools\SelectTests -- --changed-files <generated-changed-files.txt> --explain # Passed: production graph/prefilter, 0 unattributed inputs. # Shared Docker shell helper correctly activates the existing ALL route. ``` Linux container, pinned .NET runtime, same built MTP assembly: ```bash /tmp/dotnet/dotnet /repo/artifacts/bin/Infrastructure.Tests/Debug/net11.0/Infrastructure.Tests.dll --filter-class "*.PrComparisonBaseTests" --filter-class "*.CliE2EImageBuildTests" --filter-class "*.SelectTestsCliTests" --filter-not-method "*.NativeDashboardSharedHelpersSelectNativeValidationInEnforceMode" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true" --results-directory /tmp/test-results # Original implementation: passed 88 (79 selector + 9 image cases). /tmp/dotnet/dotnet artifacts/bin/Infrastructure.Tests/Debug/net11.0/Infrastructure.Tests.dll --filter-class "*.CliE2EImageBuildTests" --filter-not-trait quarantined=true --filter-not-trait outerloop=true # Final b8274fc: passed all 13 expanded image cases. ``` The initial Windows run failed in 17 shell cases because it selected the broken System32 WSL bash shim, and 5 existing Git-fixture cleanup cases with `UnauthorizedAccessException`. The same cases passed on Linux. The 2 native graph cases passed on Windows; running the Windows SDK on Linux caused `BadImageFormatException`. Passing partitions cover every focused case without modifying unrelated tests. The 13 image cases cover success, ordinary failure, fallback failure, slow success, stall, forced kill, client cancellation, external cancellation before/during deadline cleanup, client SIGKILL during cleanup, all-image/.NET-only orchestration, and exact original apt-source restoration in real Ubuntu. Cleanup cancellation reproduces on 4bb054c as incorrect exit 0 plus fallback; the corrected supervisor exits 143 without fallback. Killed clients retain 137, never deadline 124. Real Docker/Buildx probe re-run after the supervisor change: ```bash build_with_mirror_retry 20s "real BuildKit cancellation probe" docker buildx build --progress plain --load -t mirror-fallback-probe ``` Passed: primary printed `PRIMARY_RUNNING`, then `#5 CANCELED` / `Canceled: context canceled`; fallback printed `FALLBACK_RUNNING` and loaded the image. BuildKit history recorded primary `Error` and fallback `Completed`. Process inspection before fallback and afterwards found only the BuildKit daemon, no surviving primary `RUN`/`sleep`. Temporary builder and image removed. `git diff --check`: passed. ### Actual final-head CI Head **b8274fc8e0377c70ada8aa9eecfbdbc4069c6ff7**, [run 42170803717](https://github.com/microsoft/aspire/actions/runs/42170803717): **image build and all four uploads passed; Infrastructure passed 2090/2090; all 116 selected CLI archive E2E jobs passed.** The downloaded Infrastructure TRX confirms all 13 new image cases passed. CLI unit tests passed on Linux, macOS and Windows. This is actual final-head evidence, not evidence from superseded runs. [Image job 127739541935](https://github.com/microsoft/aspire/actions/runs/42170803717/job/127739541935) ran 05:56:03–06:05:32 UTC. All four artifacts are present and unexpired: | Variant | Artifact ID | Size (bytes) | Uploaded UTC | | --- | --- | --- | --- | | .NET | 13481517063 | 696399767 | 06:04:42 | | Polyglot | 13480867983 | 391644472 | 06:04:54 | | Java | 13481671757 | 654944092 | 06:05:13 | | Go | 13481043964 | 583388699 | 06:05:30 | The primary mirror was healthy: `#11 4.388 Fetched 108 MB in 1s (114 MB/s)`. **No actual CI timeout/fallback occurred**; fallback evidence is deterministic/local BuildKit evidence, not a production CI claim. Representative actual consumers confirm all four artifacts load and execute tests: | Consumer job | Images loaded | Test outcome | | --- | --- | --- | | [Go starter 127743182589](https://github.com/microsoft/aspire/actions/runs/42170803717/job/127743182589) | .NET, polyglot, Go | 1 passed, 1 skipped | | [Java polyglot 127743185239](https://github.com/microsoft/aspire/actions/runs/42170803717/job/127743185239) | .NET, polyglot, Java | 1 passed | | [.NET smoke 127743188570](https://github.com/microsoft/aspire/actions/runs/42170803717/job/127743188570) | .NET, polyglot | 10 passed | **Required checks are not green; approval is still required.** Two failures outside the changed image infrastructure remain, with same-source main controls rather than blind reruns: - [Windows extension units 127739542026](https://github.com/microsoft/aspire/actions/runs/42170803717/job/127739542026): 4150 passed, 9 pending, 1 failed. `rejects when a POSIX process group remains alive after forced termination` passed its rejection/listener assertions but saw global fake-timer count 2 instead of 0. Test and process-helper blobs are identical to main 54b4929. [Main control 127718292677](https://github.com/microsoft/aspire/actions/runs/42164303520/job/127718292677) passed that exact case and all 4151 tests. The source of the two timers is not established; no extension edit or retry made. - [Windows Hosting-2 127739572340](https://github.com/microsoft/aspire/actions/runs/42170803717/job/127739572340): `ExecutableDoesNotExist` and `ExecutableWorkingDirectoryDoesNotExist` failed before scenario assertions because DCP's `docker.exe --version` dependency probe timed out. Test file and entire DCP source tree are identical to main 54b4929. [Main control 127718297752](https://github.com/microsoft/aspire/actions/runs/42164303520/job/127718297752) TRX passed the same cases in 6.005s and 2.854s. No product edit or retry made. All four review threads have been addressed. No merge or bypass performed; #21828 remains untouched and cannot consume this fix until integration. ### Security considerations The supervisor executes existing checked-in Docker commands, not new untrusted input. Separate-session process-group signaling avoids signaling the workflow shell and permits child cleanup. A forced kill cannot confirm remote BuildKit cancellation, so it fails closed without fallback. No threat model or separate security review has been performed. Fixes # (issue) ## Checklist - Is this feature complete? - [x] Yes. Ready to ship. - [ ] No. Follow-up changes expected. - Are you including unit tests for the changes and scenario tests if relevant? - [x] Yes - [ ] No - Did you add public API? - [ ] Yes - If yes, did you have an API Review for it? - [ ] Yes - [ ] No - Did you add `<remarks />` and `<code />` elements on your triple slash comments? - [ ] Yes - [ ] No - [x] No - Does the change make any security assumptions or guarantees? - [x] Yes - If yes, have you done a threat model and had a security review? - [ ] Yes - [x] No - [ ] No --------- Co-authored-by: IEvangelist <[email protected]> Co-authored-by: Copilot App <[email protected]> Co-authored-by: Adam Ratzman <[email protected]>
Description
What failed: the Linux VS Code E2E
deno-debuggertest attaches js-debug to a Deno resource and hits a TypeScript breakpoint flaked in runs 41354116968 and 41045515222. Each run starts with the extension'saspire doctorprobes, and those probes leave DCP killed with exit code 137.Failure stats (14d, attempt 1)
CIworkflow on microsoft/aspire, runs created 2026-10-25 06:28 → 2026-11-08 06:28 UTC, attempt 1 only. Denominator: attempt-1 jobs that ran (success or failure). Hits: the failed job's log matches the signature. Jobs that lost their runner, which have no log, are excluded. Main runs have no reruns, so their flake check is the next main run of the job.attaches js-debug to a Deno resource and hits a TypeScript breakpointfailing withFailed to apply E2E control revision … E2E control command failedFailing attempt-1 jobs, most recent first (3 of 3 log-verified hits):
ievangelist-contextual-sidebar-statesFailed to apply E2E control revision 1793915466106: E2E control command failed.afscrome-wslc-container-tests-on-windows-ciFailed to apply E2E control revision 1793571631482: E2E control command failed.mitchdenny-template-derived-defaultsFailed to apply E2E control revision 1793360300048: E2E control command failed.Verdict: WEAK. 3 hits, never on main, all passed on rerun. The signature is a generic E2E-control error matched only by message; nothing in the job log ties it to the DCP 415/kill path. Separately, 3 more failures of this test (
aspire new … exited with code 4) were all on one PR branch and are a different failure. The 415 bug is real and worth fixing; the flake link is unproven.Why:
DcpConnectionCheckersends its stopPATCH /admin/executionthroughStringContent(..., Encoding.UTF8, "application/merge-patch+json"), which putsContent-Type: application/merge-patch+json; charset=utf-8on the wire. DCP matches the media type exactly and answers 415. The stop is never accepted, so disposal always runsKill(entireProcessTree: true)on DCP. I reproduced this locally against a real DCP: the charset form returns 415, while the bare type returns 202 and DCP exits cleanly.Fix:
application/merge-patch+jsontype. This is the same headerDcpKubernetesClientalready sends for this PATCH.s_processExitTimeout(5s) for DCP to exit. Kill it only if it is still running after that.Refs #20839, which tracks the same test with an older signature, so this does not close it. This is separate from #21917, which covers cancellation cleanup in doctor.
Confidence
DcpConnectionHealthCheckTests.TestConnectionAsync_StopsDcpGracefullyInsteadOfKillingIt. A minimal fake DCP API server returns 415 unless the Content-Type is exactlyapplication/merge-patch+json. The test asserts that the doctor check passes, that it sends the exact media type and that the process is never killed.Expected: "application/merge-patch+json",Actual: "application/merge-patch+json; charset=utf-8".KillCountexpected 0, actual 1.DcpConnectionHealthCheckTests,EnvironmentCheckerTestsandDoctorCommandTestspass 47/47 locally on Linux.How we stop this recurring
The new test pins the exact stop media type and the graceful no-kill path. If doctor regresses to killing DCP, the CLI unit tests fail and the problem no longer surfaces only as a downstream E2E flake.
Checklist
🤖 Posted by AspireAgent (AI Agent)