Skip to content

test(macos-docker-desktop): skip tests hitting a Docker Desktop connection reset - #8627

Merged
rfay merged 3 commits into
ddev:mainfrom
rfay:20260729_rfay_macos_dd_retry
Jul 30, 2026
Merged

rfay merged 3 commits into
ddev:mainfrom
rfay:20260729_rfay_macos_dd_retry

Conversation

@rfay

@rfay rfay commented Jul 29, 2026 •

Copy link
Copy Markdown
Member

The Issue

  • Related to intermittent failures in the buildkite macOS/arm64 Docker Desktop performance/test run (ddev-macos-arm64-mutagen pipeline), not tied to a single tracked issue number.

Several tests intermittently fail on macOS/arm64/Docker Desktop CI with a TCP-level connection reset rather than a bad HTTP response, e.g.:

Error: Get "http://127.0.0.1/README.md": read tcp 127.0.0.1:...->127.0.0.1:80: read: connection reset by peer

This happens immediately after the containers/router report healthy. It's a documented, still-unresolved class of bug in Docker Desktop for Mac's networking layer, where forwarded ports intermittently reset or refuse the first connection right after a container reports healthy, because the container's internal healthcheck can pass before the host-side port-forwarding path has fully caught up:

This is the same symptom already worked around elsewhere in this codebase (TestPHPOverrides, TestHttpsRedirection, TestInternalAndExternalAccessToURL, all of which skip on Apple Silicon/Lima/Colima/Rancher), but a broader analysis of ~300 recent ddev-macos-arm64-mutagen builds (via the Buildkite REST API) turned up 8 test functions across 4 files that hit this same reset and aren't guarded:

  • TestTraefikVirtualHost, TestCustomProjectTraefikConfig (pkg/ddevapp/traefik_test.go)
  • TestPHPConfig (pkg/ddevapp/config_test.go)
  • TestDdevFullSiteSetup, TestDdevStartMultipleHostnames (pkg/ddevapp/ddevapp_test.go)
  • TestDdevXhprofPrependEnabled, TestDdevXhprofXhguiEnabled (pkg/ddevapp/xhprof_xhgui_test.go)
  • TestCmdXHGui (cmd/ddev/cmd/xhgui_test.go)

An earlier version of this PR broadened pkg/testcommon/http.go's existing macOS retry floor to cover connection-reset errors, not just 5xx statuses, but that only covered TestTraefikVirtualHost (the one test using that retry helper) and added retry complexity to product test infrastructure for what's a single-platform CI flake. Given how many distinct tests hit this and that it's Docker Desktop/Apple Silicon-specific, a skip is the simpler, more consistent fix.

How This PR Solves The Issue

Reverts the retry-floor broadening in pkg/testcommon/http.go back to its original 5xx-only behavior, and instead adds a skip guard to each of the 8 affected tests, consistent with the existing skip pattern used by TestPHPOverrides/TestHttpsRedirection/TestInternalAndExternalAccessToURL:

if nodeps.IsAppleSilicon() && dockerutil.IsDockerDesktop() && nodeps.IsEnvFalse("DDEV_RUN_TEST_ANYWAY") {
    t.Skip("Skipping on Docker Desktop/Apple Silicon to ignore problems with 'connection reset by peer'")
}

Scoped to Docker Desktop + Apple Silicon specifically (rather than all Apple Silicon runtimes, which also covers Colima/Lima/Rancher where this hasn't been observed), with DDEV_RUN_TEST_ANYWAY=true as the existing escape hatch to force these tests to run anyway.

Manual Testing Instructions

  1. On a macOS/arm64 machine with Docker Desktop, run any of the 8 affected tests, e.g. go test -v -run TestTraefikVirtualHost ./pkg/ddevapp/ — it should skip with a message referencing DDEV_RUN_TEST_ANYWAY.
  2. Run the same test with DDEV_RUN_TEST_ANYWAY=true go test -v -run TestTraefikVirtualHost ./pkg/ddevapp/ to confirm it still executes normally.
  3. On Linux CI or non-Docker-Desktop providers, confirm these tests are unaffected (the guard only trips on Docker Desktop + Apple Silicon).

Automated Testing Overview

No new automated tests: this is a CI-flake mitigation, not new product behavior. Existing coverage for these 8 tests is unchanged on every platform except Docker Desktop/Apple Silicon, where they now skip instead of intermittently failing.

Release/Deployment Notes

Test-only change (pkg/testcommon, pkg/ddevapp, cmd/ddev/cmd test files), no impact on shipped ddev behavior. Reduces flakiness of macOS Docker Desktop CI/nightly runs at the cost of not running these 8 tests on that platform combination (they still run everywhere else, and can be forced with DDEV_RUN_TEST_ANYWAY=true).

@rfay
rfay requested a review from a team as a code owner July 29, 2026 17:52
@rfay rfay changed the title fix(testcommon): retry a transient macOS connection reset in local HTTP checks test(macos-docker-desktop): retry a transient macOS connection reset in local HTTP checks Jul 29, 2026
@github-actions

github-actions Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

@rfay
rfay force-pushed the 20260729_rfay_macos_dd_retry branch from aa04bcd to 7eee72c Compare July 29, 2026 22:01
@rfay rfay changed the title test(macos-docker-desktop): retry a transient macOS connection reset in local HTTP checks test(macos-docker-desktop): skip tests hitting a Docker Desktop connection reset Jul 29, 2026

@stasadev stasadev left a comment

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.

Looks good to me.

@rfay

rfay commented Jul 30, 2026

Copy link
Copy Markdown
Member Author

I think I'll add TestHardenedStart

rfay and others added 3 commits July 30, 2026 15:25
…TP checks

getLocalHTTPResponse already gave a single-shot request one extra try on
macOS for a brief php-fpm SIGBUS 502/503, but not for a TCP-level connection
reset/refusal - the failure mode seen when Docker Desktop's port forwarding
hasn't fully caught up right after a container reports healthy (see
docker/for-mac#5407). Broaden the existing retry
floor from "5xx status" to "any request error" so it also covers that case.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011hMVwyxzg1d9iYJq3hDKNX
…tead of retrying

Buildkite log analysis (ddev/ddev-macos-arm64-mutagen, last ~300 builds)
found 8 test functions across 4 files intermittently hit connection
reset by peer right after container start, all on Docker Desktop/Apple
Silicon - the port-forwarding race in
docker/for-mac#5407. Revert the prior retry-
based fix (only covered one of the eight) and instead skip each
affected test on Docker Desktop/Apple Silicon, consistent with the
existing skip pattern for this class of failure, with
DDEV_RUN_TEST_ANYWAY as the escape hatch.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011hMVwyxzg1d9iYJq3hDKNX
…t right after start

The prior commit (7eee72c) covered 8 test functions found by mining
Buildkite history. Auditing every test that calls a local-HTTP-check
helper immediately after app.Start()/Restart()/StartAndWait() turned up
13 more with the identical shape - a single-attempt HTTP request against
a container's forwarded port right after it reports healthy, vulnerable
to the same Docker Desktop/Apple Silicon port-forwarding race
(docker/for-mac#5407). Skip them the same way,
with DDEV_RUN_TEST_ANYWAY as the escape hatch.

Notably TestTraefikSimple - the test from the original failing log -
never actually got the fix in the prior commit; only TestTraefikVirtualHost
and TestCustomProjectTraefikConfig in that file did.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@rfay
rfay force-pushed the 20260729_rfay_macos_dd_retry branch from 78f95c1 to a38d97f Compare July 30, 2026 15:25
@rfay

rfay commented Jul 30, 2026

Copy link
Copy Markdown
Member Author

I added a few more. I think we overall have totally adequate test coverage, including macOS, so don't think this has a lot of risk.

@rfay
rfay merged commit 005aed2 into ddev:main Jul 30, 2026
50 of 54 checks passed
@rfay
rfay deleted the 20260729_rfay_macos_dd_retry branch July 30, 2026 18:46
rfay added a commit to rfay/ddev that referenced this pull request Oct 30, 2026
…after alias updates

## Short Summary (TL;DR)

After DDEV reconnects `ddev-router` to update its aliases, Docker Desktop on macOS can forward a router port to a stale target, so requests get `connection reset by peer`. DDEV now warns about it, and `TestGetWebContainerDirectURLsWithGenericWebserver` logs better diagnostics and tolerates the delay on Docker Desktop.

## The Issue

`TestGetWebContainerDirectURLsWithGenericWebserver` failed 15 times on `ddev-macos-arm64-mutagen` since 2026-10-08, counting retried jobs. That is about 7% of test jobs. Every failure came right after `Updating router network aliases in place`. Traefik had the route, but `127.0.0.1:443` or `:80` reset the connection and was still resetting 5s later.

The reset is a long-standing Docker Desktop problem. ddev#8627 skipped about 18 tests for it. This test started requesting router URLs in ddev#8903, after that skip.

`warnUnreachableRouterPorts` could not see it: it only looked for refused connections, and it only ran when the router was recreated.

## How This PR Solves The Issue

- `netutil.IsPortUnreachable` (formerly `IsPortRefused`) sends a minimal HTTP request. A refused connection, or one that closes or resets before any response, counts as unreachable.
- `warnUnreachableRouterPorts` also runs after the in-place alias update.
- `logRouterDiagnostics` logs the router's published ports and curls the URL from containers on `ddev_default` and the host network. It then polls the URL for up to 60s and logs how long recovery takes.
- On Docker Desktop, the test passes when the URL recovers within that time. Otherwise it fails as before.

## Manual Testing Instructions

```bash
ddev utility download-ddev --pr 9026
export PATH="$HOME/tmp/ddev-download-ddev/pr-9026:$PATH"
ddev start   # in a first project
ddev start   # in a second project with a new hostname
# Expect no "nothing answers on host port(s)" warning on a healthy provider
```

## Automated Testing Overview

`TestIsPortUnreachable` covers answering, refused, reset, and closed-without-answer listeners. In the Docker Desktop CI logs, look for `recovered after Ns` from `logRouterDiagnostics`. It shows whether polling is enough here and in `TestCmdLogs`, or whether these tests need the ddev#8627 skip.

🤖 Developed with assistance from [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants