Skip to content

Stop the aspire doctor DCP probe gracefully instead of killing it - #21919

Merged
Adam Ratzman (adamint) merged 1 commit into
mainfrom
aspireagent/dcp-doctor-graceful-stop
Nov 25, 2026
Merged

Adam Ratzman (adamint) merged 1 commit into
mainfrom
aspireagent/dcp-doctor-graceful-stop

Conversation

@davidfowl

@davidfowl David Fowler (davidfowl) commented Nov 8, 2026 •

Copy link
Copy Markdown
Collaborator

Description

What failed: the Linux VS Code E2E deno-debugger test attaches js-debug to a Deno resource and hits a TypeScript breakpoint flaked in runs 41354116968 and 41045515222. Each run starts with the extension's aspire doctor probes, and those probes leave DCP killed with exit code 137.

Failure stats (14d, attempt 1)

CI workflow 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.

Signature Deno test attaches js-debug to a Deno resource and hits a TypeScript breakpoint failing with Failed to apply E2E control revision … E2E control command failed
Job VS Code extension E2E (Linux, deno-debugger)
main pushes: hits / runs 0 / 153 (0.00%)
main pushes, 30d: hits / runs 0 / 265 (0.00%). The 16 days before the 14d window add 0 hits.
PR runs: hits / runs 3 / 814 (0.37%); 0 PR-caused excluded
Combined rate 3 / 967 = 0.31%
Flake check PR: 3/3 rerun hits passed on rerun (0 never rerun)
First / last hit 2026-10-30 / 2026-11-05
Still hitting main? Last main hit: never. 28 main runs since the last hit (2026-11-05), with 0 hits
Fix evidence Local: regression test fails before and passes 10/10 after (fake DCP server). No E2E repro. This PR's CI: Linux deno-debugger passed 1/1.

Failing attempt-1 jobs, most recent first (3 of 3 log-verified hits):

Date (UTC) Branch Job Signature excerpt
2026-11-05 21:25 ievangelist-contextual-sidebar-states VS Code extension E2E (Linux, deno-debugger) Failed to apply E2E control revision 1793915466106: E2E control command failed.
2026-11-01 21:51 afscrome-wslc-container-tests-on-windows-ci VS Code extension E2E (Linux, deno-debugger) Failed to apply E2E control revision 1793571631482: E2E control command failed.
2026-10-30 11:05 mitchdenny-template-derived-defaults VS Code extension E2E (Linux, deno-debugger) Failed 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: DcpConnectionChecker sends its stop PATCH /admin/execution through StringContent(..., Encoding.UTF8, "application/merge-patch+json"), which puts Content-Type: application/merge-patch+json; charset=utf-8 on the wire. DCP matches the media type exactly and answers 415. The stop is never accepted, so disposal always runs Kill(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:

  • Send the bare application/merge-patch+json type. This is the same header DcpKubernetesClient already sends for this PATCH.
  • When DCP accepts the stop, wait up to the existing 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

  • New regression test DcpConnectionHealthCheckTests.TestConnectionAsync_StopsDcpGracefullyInsteadOfKillingIt. A minimal fake DCP API server returns 415 unless the Content-Type is exactly application/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.
    • Before the fix: fails with Expected: "application/merge-patch+json", Actual: "application/merge-patch+json; charset=utf-8".
    • Content type fixed but no graceful wait: fails with KillCount expected 0, actual 1.
    • After the fix: passes 10/10 in a loop.
  • DcpConnectionHealthCheckTests, EnvironmentCheckerTests and DoctorCommandTests pass 47/47 locally on Linux.
  • Not run: the VS Code extension E2E suite, and Windows/macOS. I did not re-run against a real DCP 0.27.3 after re-implementing; the earlier real-DCP 415/202 repro used 0.27.2.

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

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No

🤖 Posted by AspireAgent (AI Agent)

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]>
@davidfowl David Fowler (davidfowl) added the agent:working An AI agent is actively working on this issue or PR label Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21919

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21919"

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Tests selector

2 / 101 PR test projects · 4 PR jobs, from 2 changed files.

Selected PR test projects (2 / 101)

Aspire.Cli.EndToEnd.Tests, Aspire.Cli.Tests

Selected PR jobs (4)

cli-starter-validation, extension-e2e, polyglot, typescript-api-compat


How these were chosen — grouped by what changed

📦 affected project Aspire.Cli
→ 1 test: Aspire.Cli.EndToEnd.Tests

🧪 tests/Aspire.Cli.Tests/Utils/DcpConnectionHealthCheckTests.cs (changed test)
→ 1 directly: Aspire.Cli.Tests

Job reasons

Job Triggered by
cli-starter-validation affected project Aspire.Cli
extension-e2e • src/Aspire.Cli/Utils/EnvironmentChecker/DcpConnectionChecker.cs
• affected project Aspire.Cli
polyglot affected project Aspire.Cli
typescript-api-compat affected project Aspire.Cli

Selection computed for commit 9b87e73.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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+json media 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

@adamint
Adam Ratzman (adamint) merged commit 01ae766 into main Nov 25, 2026
230 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 17.1 milestone Nov 25, 2026
Adam Ratzman (adamint) added a commit that referenced this pull request Nov 25, 2026
#21919 added a test that predates the CertificateManager.Create and DcpConnectionChecker signature changes from #22553.

Co-authored-by: Copilot App <[email protected]>
Adam Ratzman (adamint) added a commit that referenced this pull request Nov 25, 2026
<!-- 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants