Skip to content

Fix empty DCP container host name breaking container OTLP endpoint - #21316

Closed
David Fowler (davidfowl) wants to merge 1 commit into
mainfrom
fix/dcp-empty-container-hostname
Closed

David Fowler (davidfowl) wants to merge 1 commit into
mainfrom
fix/dcp-empty-container-hostname

Conversation

@davidfowl

Copy link
Copy Markdown
Collaborator

Description

AddJavaContainerTests.AddJavaContainer_ExportsTelemetryToAspire failed on main CI (run 40248143715, Hosting.Java, windows-latest): expected http://:4317, actual http://. The expected value shows DCP reported an empty hostName, so DcpContainersInfo.ContainerHostName returned "" (HostName ?? ... only handles null) and container-facing OTLP URLs were built with an empty host. Empty HostName now falls back to the runtime default, same as null.

Whether DCP reports an empty hostName on that runner is inferred from the failure output; I could not confirm it from the logs.

Validation:

  • dotnet test --project tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj --no-launch-profile -- --filter-method "*.ContainerHostName_FallsBackToRuntimeDefaultWhenHostNameIsNullOrEmpty" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true" — not run: restore failed in the sandbox (dotnet-public feed download errors, NU1900/NU1905). Unverified locally; relying on PR CI. Windows not run.

Fixes # (issue)

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

… name

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

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 -- 21316

Or

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

@aspire-repo-bot
aspire-repo-bot Bot requested a balanced review from Copilot October 26, 2026 06:11
@github-actions github-actions Bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Oct 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Tests selector

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

Selected PR test projects (52 / 100)

Aspire.Cli.EndToEnd.Tests, Aspire.Hosting.Analyzers.Tests, Aspire.Hosting.Azure.EntraId.Tests, Aspire.Hosting.Azure.Kubernetes.Tests, Aspire.Hosting.Azure.Kusto.Tests, Aspire.Hosting.Azure.Provisioning.Tests, Aspire.Hosting.Azure.Tests, Aspire.Hosting.Blazor.Tests, Aspire.Hosting.Browsers.Tests, Aspire.Hosting.CodeGeneration.Go.Tests, Aspire.Hosting.CodeGeneration.Java.Tests, Aspire.Hosting.CodeGeneration.Python.Tests, Aspire.Hosting.CodeGeneration.Rust.Tests, Aspire.Hosting.CodeGeneration.TypeScript.Tests, Aspire.Hosting.Containers.Tests, Aspire.Hosting.DevTunnels.Tests, Aspire.Hosting.Docker.Tests, Aspire.Hosting.Dotnet.Tests, Aspire.Hosting.DotnetTool.Tests, Aspire.Hosting.EntityFrameworkCore.Tests, Aspire.Hosting.Foundry.Tests, Aspire.Hosting.Garnet.Tests, Aspire.Hosting.Go.Tests, Aspire.Hosting.Java.Tests, Aspire.Hosting.JavaScript.Tests, Aspire.Hosting.Kafka.Tests, Aspire.Hosting.Keycloak.Tests, Aspire.Hosting.Kubernetes.Tests, Aspire.Hosting.Maui.Tests, Aspire.Hosting.Milvus.Tests, Aspire.Hosting.MongoDB.Tests, Aspire.Hosting.MySql.Tests, Aspire.Hosting.Nats.Tests, Aspire.Hosting.OpenAI.Tests, Aspire.Hosting.Oracle.Tests, Aspire.Hosting.Orleans.Tests, Aspire.Hosting.PostgreSQL.Tests, Aspire.Hosting.Python.Tests, Aspire.Hosting.Qdrant.Tests, Aspire.Hosting.RabbitMQ.Tests, Aspire.Hosting.Radius.Tests, Aspire.Hosting.Redis.Tests, Aspire.Hosting.RemoteHost.Tests, Aspire.Hosting.Rust.Tests, Aspire.Hosting.Seq.Tests, Aspire.Hosting.SqlServer.Tests, Aspire.Hosting.Testing.Tests, Aspire.Hosting.Tests, Aspire.Hosting.Valkey.Tests, Aspire.Hosting.Yarp.Tests, Aspire.Playground.Tests, Aspire.Templates.Tests

Selected PR jobs (4)

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


How these were chosen — grouped by what changed

⚠️ 46 of the 52 selected test projects come from a single change — src/Aspire.Hosting/Dcp/IDcpDependencyCheckService.cs.

🔧 src/Aspire.Hosting/Dcp/IDcpDependencyCheckService.cs (changed source)
→ 46 via the project graph

show 46

Aspire.Hosting.Analyzers.Tests (2 hops), Aspire.Hosting.Azure.EntraId.Tests (2 hops), Aspire.Hosting.Azure.Kubernetes.Tests (2 hops), Aspire.Hosting.Azure.Kusto.Tests (2 hops), Aspire.Hosting.Azure.Provisioning.Tests (3 hops), Aspire.Hosting.Azure.Tests, Aspire.Hosting.Browsers.Tests (2 hops), Aspire.Hosting.CodeGeneration.Go.Tests, Aspire.Hosting.CodeGeneration.Java.Tests, Aspire.Hosting.CodeGeneration.Python.Tests, Aspire.Hosting.CodeGeneration.Rust.Tests, Aspire.Hosting.CodeGeneration.TypeScript.Tests, Aspire.Hosting.Containers.Tests (2 hops), Aspire.Hosting.DevTunnels.Tests (2 hops), Aspire.Hosting.Docker.Tests (2 hops), Aspire.Hosting.DotnetTool.Tests (2 hops), Aspire.Hosting.EntityFrameworkCore.Tests (2 hops), Aspire.Hosting.Foundry.Tests (2 hops), Aspire.Hosting.Garnet.Tests (2 hops), Aspire.Hosting.Go.Tests (2 hops), Aspire.Hosting.Java.Tests (2 hops), Aspire.Hosting.JavaScript.Tests (2 hops), Aspire.Hosting.Kafka.Tests (2 hops), Aspire.Hosting.Keycloak.Tests (2 hops), Aspire.Hosting.Kubernetes.Tests (2 hops), Aspire.Hosting.Maui.Tests, Aspire.Hosting.Milvus.Tests (2 hops), Aspire.Hosting.MongoDB.Tests (2 hops), Aspire.Hosting.MySql.Tests (2 hops), Aspire.Hosting.Nats.Tests (2 hops), Aspire.Hosting.OpenAI.Tests (2 hops), Aspire.Hosting.Oracle.Tests (2 hops), Aspire.Hosting.Orleans.Tests (2 hops), Aspire.Hosting.PostgreSQL.Tests (2 hops), Aspire.Hosting.Python.Tests (2 hops), Aspire.Hosting.Qdrant.Tests (2 hops), Aspire.Hosting.RabbitMQ.Tests (2 hops), Aspire.Hosting.Redis.Tests (2 hops), Aspire.Hosting.RemoteHost.Tests, Aspire.Hosting.Rust.Tests (2 hops), Aspire.Hosting.Seq.Tests (2 hops), Aspire.Hosting.SqlServer.Tests (2 hops), Aspire.Hosting.Testing.Tests (2 hops), Aspire.Hosting.Valkey.Tests (2 hops), Aspire.Hosting.Yarp.Tests (2 hops), Aspire.Playground.Tests

🧪 tests/Aspire.Hosting.Tests/Dcp/DcpDependencyCheckTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Tests
→ 3 via the project graph: Aspire.Hosting.Blazor.Tests, Aspire.Hosting.Dotnet.Tests, Aspire.Hosting.Radius.Tests

📦 affected project Aspire.Hosting.Dotnet
→ 2 tests: Aspire.Cli.EndToEnd.Tests, Aspire.Templates.Tests

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

Job reasons

Job Triggered by
cli-starter-validation affected project Aspire.Hosting.JavaScript
extension-e2e • src/Aspire.Hosting/Dcp/IDcpDependencyCheckService.cs
• affected project Aspire.Hosting
polyglot • affected project Aspire.Hosting
• affected project Aspire.Hosting.Azure.Provisioning.KeyVault
typescript-api-compat affected project Aspire.Hosting

Selection computed for commit 96235c7.

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

The narrow fallback change preserves non-empty host behavior and includes focused regression coverage, with no unresolved review findings.

No open issues 🎉

What changed in this PR

Fixes container-facing OTLP URL construction when DCP reports an empty host name by using the existing runtime-specific fallback.

Changes:

  • Treats empty host names like null while preserving non-empty values.
  • Adds regression coverage for Docker and Podman defaults and custom host names.

Tests were not executed locally; validation remains dependent on PR CI.

File Description
tests/​Aspire.Hosting.Tests/​Dcp/​DcpDependencyCheckTests.cs Adds focused host-name fallback tests.
src/​Aspire.Hosting/​Dcp/​IDcpDependencyCheckService.cs Applies runtime defaults to empty host names and documents the fallback.

Review effort: Balanced

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed the fallback change, container-facing URL consumers, and regression coverage. No issues found. Focused DcpDependencyCheckTests run: 9 passed, 0 failed.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

Copy link
Copy Markdown
Collaborator Author

Recurrence evidence: AddJavaContainer_ExportsTelemetryToAspire failed again on main (run 40279576972, Hosting.Java windows-latest) with the same Expected: http://:4317 / Actual: http://, so it fails consistently on Windows and this fix targets it.

Copy link
Copy Markdown
Collaborator Author

Closing as superseded: the identical !string.IsNullOrEmpty(HostName) fallback in DcpContainersInfo.ContainerHostName, with equivalent tests, landed on main in #21432 (merge d85136b). Rebasing this PR would leave an empty diff. Thanks James Newton-King (@JamesNK) for the review.

🤖 Posted by AspireAgent (AI Agent)

David Fowler (davidfowl) added a commit that referenced this pull request Nov 10, 2026
)

## What failed


`Aspire.Hosting.Java.Tests.AddJavaContainerTests.AddJavaContainer_ExportsTelemetryToAspire`
failed in `Hosting.Java (windows-latest)` on attempt 1 with:

```
System.AggregateException : One or more errors occurred while resolving resource configuration. (Application orchestrator dependency check returned an error: The operation has timed out. ... dcp.info.os-executor Context expired, stopping process... {"Command": "C:\\Windows\\system32\\docker.exe", "Args": ["--version"]}
  at Aspire.Hosting.Dcp.DcpDependencyCheck.GetDcpInfoAsync(...)
  at Aspire.Hosting.ApplicationModel.HostUrl...GetValueAsync(...)
```

Runs:
[41873115695](https://github.com/microsoft/aspire/actions/runs/41873115695)
(main, 11-04) and
[42181390567](https://github.com/microsoft/aspire/actions/runs/42181390567)
(PR, 11-06). This is rank 5 in the unowned-flakes list on
#21600.

## Why

The test builds a run-mode app and resolves the container's environment.
`OTEL_EXPORTER_OTLP_ENDPOINT` is a `HostUrl`, and in run mode `HostUrl`
asks `IDcpDependencyCheckService` for the container host name. The real
service runs `dcp info` under the 25s
`DcpOptions.DependencyCheckTimeout`. On busy Windows runners, DCP's
`docker --version` probe inside `dcp info` sometimes takes longer than
that (the shared infra cause tracked in #21771), so the
test fails before it reaches its assertion.
`WithJvmArgs_AppliesToAContainerToo` in the same class goes through the
same path.

The test only needs a container host name from DCP. It doesn't need DCP
itself. Its old assertion also compared the env var against a second
call to that same live service, so it couldn't catch `HostUrl` ignoring
the host name DCP reports.

## How it's fixed

Test-only change. Both tests register a deterministic
`IDcpDependencyCheckService` (the existing
`TestDcpDependencyCheckService` from `Aspire.Hosting.TestUtilities`,
which now grants `InternalsVisibleTo` to `Aspire.Hosting.Java.Tests`
like the Go and Dotnet test projects).
`AddJavaContainer_ExportsTelemetryToAspire` now reports
`host.wslc.internal` (the runtime-specific case from
#21244) and asserts the exact
`http://host.wslc.internal:4317`. The test still builds the app and goes
through the real `HostUrl` and `DcpOptions` path. No timeouts, retries
or assertions were relaxed.

**Related:** #21316 (closed without merging) targeted an
earlier failure of this same test, a different root cause: DCP reported
an empty container host name, which produced `http://:4317`.
#21432 fixed that cause on main on 10-30. This PR fixes
the remaining `dcp info` timeout signature, which neither PR covers.

## Confidence

- **Before** (main `2f471dc6`, `DcpPublisher__CliPath` pointing at a
fake `dcp` whose `info` hangs for 60s): **3/3 runs fail**. Both tests
fail after about 30s with the same `Application orchestrator dependency
check returned an error: The operation has timed out` message as CI.
- **After**, same hanging `dcp`: **10/10 runs pass** (14/14 tests, about
1s).
- **After**, real DCP 0.27.3 (Linux x64): **20/20 runs pass**.
- **Regression check:** if `HostUrl` is changed to ignore DCP's host
name (always `host.docker.internal`), the new test fails with `Expected:
"http://host.wslc.internal:4317"`, `Actual:
"http://host.docker.internal:4317"`. The old assertion would still pass
on any runner where DCP reports `host.docker.internal`.
- **Main uncertainty:** the underlying Windows `docker --version`
slowness isn't fixed here. It can still affect tests that actually start
DCP, and #21771 tracks it.

**How we stop this recurring:** unit tests that only need a value from
DCP (such as the container host name) should register a deterministic
`IDcpDependencyCheckService` instead of running the real `dcp info`.

## Failure stats (14d, attempt 1)

Source: a scan of every CI (`ci.yml`) run created 10-09 → 11-08 13:00Z,
using attempt-1 `Hosting.Java` jobs and their logs.

- **Exact test / signature:**
`Aspire.Hosting.Java.Tests.AddJavaContainerTests.AddJavaContainer_ExportsTelemetryToAspire`
failing with `Application orchestrator dependency check returned an
error: The operation has timed out ... docker.exe --version` (Windows).
- **Main:** 1/161 runs where the `Hosting.Java` job ran (0.6%). **PR:**
1/471 (0.2%). Including the sibling
`WithJvmArgs_AppliesToAContainerToo`, which has the same signature and
is fixed here, PR is 2/471 (0.4%).
- **Rerun-pass:** 1 of 1 rerun (the other hits were not re-run).
- **Last hit:** 11-06 07:31Z. Runs:
[42181390567](https://github.com/microsoft/aspire/actions/runs/42181390567)
(PR),
[42134705233](https://github.com/microsoft/aspire/actions/runs/42134705233)
(PR, sibling test),
[41873115695](https://github.com/microsoft/aspire/actions/runs/41873115695)
(main).
- **30d main hits (this signature):** 1/280. The other 30d failures of
this test were `Strings differ` (WSLc and empty host name), fixed by
#21254 and #21432. None has appeared
since #21432 merged on 10-30 15:51Z. One more hit,
[41194713391](https://github.com/microsoft/aspire/actions/runs/41194713391)
(DCP `CliPath` validation on both OSes), is branch-caused and excluded.
- **Local:** before the fix, 0/3 passed with a hanging `dcp info`. After
the fix, 10/10 passed with a hanging `dcp info` and 20/20 with real DCP.
The mutation check fails as expected.
- **PR CI:** CI run
[42491774241](https://github.com/microsoft/aspire/actions/runs/42491774241)
passed on attempt 1, including `Hosting.Java` on Windows and Ubuntu.
- **Verdict: MODERATE.** The hit count is low (3 including the sibling),
but one hit is on main, the CI error reproduces exactly in a
deterministic local test, and the same probe timeout hits other tests
(#21771).

## 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
  - [x] No
- Does the change make any security assumptions or guarantees?
  - [ ] Yes
  - [x] No

**🤖 Posted by AspireAgent (AI Agent)**

Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants