Skip to content

ci(buildkite): cap windows-mutagen test timeout at 4h - #8644

Closed
rfay wants to merge 1 commit into
mainfrom
20260731_rfay_windows_mutagen_test_timeout
Closed

rfay wants to merge 1 commit into
mainfrom
20260731_rfay_windows_mutagen_test_timeout

Conversation

@rfay

@rfay rfay commented Aug 1, 2026

Copy link
Copy Markdown
Member

The Issue

No tracked issue — found via ad hoc investigation of ddev-windows-mutagen hangs.

The ddev-windows-mutagen Buildkite pipeline hung 3 times in the last 30 hours
(builds 6413,
6418,
6419), each time
running the full 6h go test -timeout before failing (6h15m-6h22m wall time),
rather than failing in a reasonable amount of time. All three hung in the same
place: TestRouterNotRebuiltOnHostnameChange, blocked writing a debug log
line to stdout deep into the run (thousands of lines and hours of successful
container/network/image operations in, not on first Docker use).

Pulling the Docker Desktop version out of each build's log (docker version
output near the start of the job) shows this pipeline ran cleanly on Docker
Desktop 4.77.0 → 4.78.0 → 4.79.0 across ~90 prior runs over 4+ months with zero
occurrences of this hang. The runner (tb-win11-10, which handles nearly all
ddev-windows-mutagen jobs) silently auto-updated to Docker Desktop 4.84.0
between build 6406 (Jul 28, passed, 4.79.0) and 6408 (Jul 29, 4.84.0).
Every build that has completed since that upgrade has hung — 3 for 3.

There's a matching, freshly-filed upstream report,
docker/desktop-feedback#560
(filed the same day as build 6419), describing Docker Desktop 4.84.0 on
Windows/WSL2 intermittently reporting its backend VM as reduced/stopped before
recovering minutes later — consistent with the backend appearing to not be
running when the runner was checked manually. No 4.84.x fix is available yet,
so this PR addresses the CI cost rather than the Docker Desktop bug itself.

How This PR Solves The Issue

Normal passing runs on this pipeline finish in ~160-220 minutes, so the
existing global TEST_TIMEOUT=6h (shared by every CI job via the Makefile)
gives a hang roughly 2x more runway than it needs before failing.

  • .buildkite/test.sh: threads TEST_TIMEOUT through to the make test
    invocation, defaulting to today's 6h so every other pipeline is unaffected.
  • .buildkite/windows10dockerforwindows.yml: overrides TEST_TIMEOUT to 4h
    for this pipeline only — comfortable margin above the observed ~220m normal
    max, while cutting wasted runner time on a hang from ~6h15m to ~4h15m.

This is a mitigation for the symptom (CI burning hours on a hang), not a fix
for the underlying Docker Desktop 4.84.0 backend issue, which needs to be
addressed separately (e.g. pinning/downgrading Docker Desktop on the runner
until Docker ships a fix).

Manual Testing Instructions

This only changes Buildkite CI configuration; there's no local user-facing
behavior to test. To verify:

  1. Confirm .buildkite/test.sh passes TEST_TIMEOUT through to make and
    defaults to 6h when unset (unchanged behavior for every pipeline besides
    ddev-windows-mutagen).
  2. Confirm .buildkite/windows10dockerforwindows.yml sets TEST_TIMEOUT: 4h.
  3. Watch the next few ddev-windows-mutagen runs: passing runs should be
    unaffected (~160-220m), and if the Docker Desktop 4.84.0 hang recurs, the
    job should now fail at ~4h instead of ~6h15m+.

Automated Testing Overview

No new automated tests — this is a CI configuration change (test-timeout
plumbing), not application logic.

Release/Deployment Notes

CI-only change; no user-facing impact. Does not fix the underlying Docker
Desktop 4.84.0 backend hang — only limits how much runner time each
occurrence wastes while that's investigated/resolved separately.

The ddev-windows-mutagen pipeline has hung 3 times in the last 30 hours
(builds 6413, 6418, 6419), each time hitting the global 6h go test
timeout and burning the full 6h15m-6h22m before failing. Normal passing
runs finish in ~160-220m, so 6h is far more slack than needed and turns
every hang into a multi-hour stall of the (mostly single) Windows
runner.

Thread TEST_TIMEOUT through test.sh's make invocation and override it
to 4h for this pipeline only, leaving the 6h default untouched for
every other CI job that uses the same script.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@rfay
rfay requested a review from a team as a code owner August 1, 2026 00:00
@rfay

rfay commented Aug 1, 2026

Copy link
Copy Markdown
Member Author

Update: reproduced live a 4th time, plus new evidence pointing at Docker Desktop itself

While this PR was open, ddev-windows-mutagen build 6419 was retried on main (same commit, same runner tb-win11-10) and hung again — a 4th occurrence in a row since the Docker Desktop 4.79.0 → 4.84.0 upgrade described below. The retry stalled in the exact same place as builds 6413, 6418, and the original 6419: TestRouterNotRebuiltOnHostnameChange, right as the second project (project2) starts its Mutagen sync (containers created/started, upload_dirs warning printed, then silence — no further output for 2+ hours before the retry was cancelled). This retry predates this PR's 4h timeout (it was still running against main's 6h default), so it would have burned the full 6h had it not been stopped manually.

New corroborating evidence found today:

  • docker/desktop-feedback#560, filed 2026-07-31 (same day as this hang): "Docker Desktop 4.84.0 intermittently misclassifies WSL 2.7.11 as update-required and starts abnormally slowly". The reporter observed the backend logging a reduced/stopped VM state and waiting on the init control API, with the engine not becoming ready for 2m16s–2m25s in one captured run — the same kind of backend-availability stall that would explain mutagen sync create (which talks to the Docker backend) hanging indefinitely on our runner.
  • Several other Docker Desktop 4.8x-series stability reports filed in the days immediately around our runner's 4.79.0 → 4.84.0 upgrade window (Jul 28–31):
  • This isn't Windows-only: our own macOS CI needed a similar workaround one day earlier. PR test(macos-docker-desktop): skip tests hitting a Docker Desktop connection reset #8627 (merged 2026-07-30, the day before this hang) skips several router/traefik tests on macOS + Apple Silicon + Docker Desktop specifically because of intermittent "connection reset by peer" errors talking to the Docker Desktop backend. Different symptom, same underlying theme: Docker Desktop's backend has been flaky across platforms in this exact window.

Checked for a ddev-side regression: reviewed upstream/main commits from the days surrounding the upgrade (2026-07-28 through 2026-08-01) touching pkg/ddevapp/mutagen.go, pkg/dockerutil, and the webserver container — nothing there looks related. The only overlapping change is efda04184 (tolerate a stale non-FIFO /var/tmp/logpipe on webserver container start), which is unrelated to the Windows host / Mutagen exec path. This looks like a Docker Desktop 4.84.0 regression on the Windows/WSL2 backend, not a ddev regression — this PR's timeout cap is a mitigation for the CI cost, not a fix for the underlying cause.

@rfay

rfay commented Aug 1, 2026

Copy link
Copy Markdown
Member Author

It's hung again on upstream/main https://buildkite.com/ddev/ddev-windows-mutagen/builds/6419#019fba98-533f-4022-b8e7-1afd1e4f15eb

After that one times out this PR will get a chance at it. It will be interesting to see if it's exactly the same.


You have Mutagen enabled and your 'php' project type doesn't have `upload_dirs` set.
--
  | For faster startup and less disk usage, set upload_dirs to where your user-generated files are stored.
  | If this is intended you can disable this warning with `ddev config --disable-upload-dirs-warning`.

@rfay

rfay commented Aug 1, 2026

Copy link
Copy Markdown
Member Author

Next steps on this:

  • Manually run the hangling test on tb-win11-10 and see what happens
  • Manually run a set of related tests including the hang-er
  • Downgrade Docker Desktop and then manually run

@rfay

rfay commented Aug 1, 2026

Copy link
Copy Markdown
Member Author

@rfay

rfay commented Aug 1, 2026

Copy link
Copy Markdown
Member Author

I don't think this is a useful approach.

@rfay rfay closed this Aug 1, 2026
rfay added a commit that referenced this pull request Aug 2, 2026
 #8644

## The Issue

- Fixes #8644

`ddev-windows-mutagen` hung for the full 6h `go test -timeout` in three
consecutive runs (6418, 6419, 6421), always inside
`TestRouterNotRebuiltOnHostnameChange`, blocked writing a debug log line to
stdout. #8644 mitigated the symptom by capping the pipeline's timeout at 4h,
attributing the hangs to a Docker Desktop 4.84.0 backend regression on the
Windows runner (cross-referencing docker/desktop-feedback#560).

The test wraps `app2.Start()`/`app2.Restart()` in `util.CaptureUserOut()`.
That helper redirects output to an `os.Pipe()` that isn't drained until
`getOutput()` is called - i.e. only after `Start()`/`Restart()` returns. With
`DDEV_DEBUG=true` (set for all CI runs), a full `app.Start()` can emit enough
debug output to fill that pipe before it returns, deadlocking the write. This
is a known, longstanding Windows limitation of `CaptureUserOut()`:
`TestDdevLogs` has skipped Windows for the identical reason since 2018.
`TestRouterNotRebuiltOnHostnameChange` (added in 6e7e416, merged
2026-07-30) just reintroduced the same hazard without a Windows guard.

## How This PR Solves The Issue

- `pkg/ddevapp/router_test.go`: skip `TestRouterNotRebuiltOnHostnameChange`
  on Windows, following the same pattern (and referencing the same root
  cause) as the existing `TestDdevLogs` Windows skip.

## Manual Testing Instructions

1. On Windows, run
   `go test -v -run TestRouterNotRebuiltOnHostnameChange ./pkg/ddevapp/...`
   and confirm it's skipped rather than hanging.
2. `make staticrequired` passes.

## Automated Testing Overview

No new tests added; `TestRouterNotRebuiltOnHostnameChange` is now skipped on
Windows where `CaptureUserOut()` remains unsafe around a full
`Start()`/`Restart()`.

## Release/Deployment Notes

No user-facing behavior change; the skip only affects CI.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
rfay added a commit that referenced this pull request Aug 2, 2026
rfay added a commit to rfay/ddev that referenced this pull request Aug 8, 2026
…ontainer, for ddev#8644

## The Issue

- For ddev#8644

When a standard router port (say 443) is busy at router creation time, the
router is created bound to an ephemeral substitute (say 33000). The router
binds substitutes as `33000:33000`, so the container carries no trace of
which standard port the ephemeral port stands in for. If the original
occupant of 443 then goes away, a later `ddev start` of another project sees
443 as free and expects the router to bind it directly - a port the running
router does not have - so `PortsMatch()` fails and the router is recreated
unnecessarily. That recreation churn is what made
`TestRouterNotRebuiltOnHostnameChange` fail on macos-orbstack and exposed
the CaptureUserOut() hang on Windows.

## How This PR Solves The Issue

Record the substitution decision on the object whose lifetime bounds its
validity: the router container itself.

- `generateRouterCompose()` writes a `com.ddev.router-port-substitutions`
  Docker label (e.g. `443=33000`) onto the router, merging the previous
  router's label with substitutions decided by the current process and
  dropping entries whose ephemeral port the new router no longer binds.
- `GetAvailableRouterPort()` consults the label (plus the in-process map)
  when the proposed port looks free on the host: if the running router still
  has the previously-substituted ephemeral port bound, it keeps using the
  substitute instead of handing out the now-free standard port, avoiding the
  spurious recreation.

Because the record lives on the container, it works across separate ddev
invocations, not just within one process, and disappears naturally when the
router is recreated or removed (`ddev poweroff` returns projects to their
configured ports). The map is only consulted when the proposed port is
free; when it is still busy, allocation goes through
`AllocateAvailablePortForRouter()` as before, which honors
`EphemeralRouterPortsAssigned` and gives concurrent projects distinct
ephemeral ports.

Also rewords the "Port X is busy" message to "Port X is not available",
since with this change the substitute can be reported when the port is no
longer busy, and updates the matching troubleshooting docs example.

## Manual Testing Instructions

1. Occupy ports 80/443 (or whatever your configured router ports are) with
   a throwaway listener.
2. `ddev start` project1; note the "Port X is not available, using Y
   instead" message and `docker inspect ddev-router` showing the
   `com.ddev.router-port-substitutions` label.
3. Kill the listener so the standard port is free again.
4. `ddev start` project2 (a separate ddev process); the router is not
   recreated ("ddev-router already running, pushing new config...") and
   project2 adopts the same substitute port.
5. `ddev poweroff && ddev start`: projects return to the standard ports.

## Automated Testing Overview

- New unit tests (`TestParseFormatRouterPortSubstitutions`,
  `TestKnownRouterPortSubstitutions`) cover label serialization, malformed
  input, and label/in-process merging.
- Existing `TestRouterNotRebuiltOnHostnameChange` exercises the
  router-recreation logic with the new label in place (passes locally).

## Release/Deployment Notes

Ephemeral port substitutions become sticky for the life of the router
container: once a project is substituted onto an ephemeral port, it keeps
that port even after the conflicting process goes away, until the router is
recreated (e.g. `ddev poweroff`). Routers created by earlier DDEV versions
have no label, so the first start after upgrade behaves as before; the
label appears at the next router recreation.

Co-Authored-By: Claude Fable 5 <[email protected]>
rfay added a commit to rfay/ddev that referenced this pull request Aug 11, 2026
…ontainer, for ddev#8644

## The Issue

- For ddev#8644

When a standard router port (say 443) is busy at router creation time, the
router is created bound to an ephemeral substitute (say 33000). The router
binds substitutes as `33000:33000`, so the container carries no trace of
which standard port the ephemeral port stands in for. If the original
occupant of 443 then goes away, a later `ddev start` of another project sees
443 as free and expects the router to bind it directly - a port the running
router does not have - so `PortsMatch()` fails and the router is recreated
unnecessarily. That recreation churn is what made
`TestRouterNotRebuiltOnHostnameChange` fail on macos-orbstack and exposed
the CaptureUserOut() hang on Windows.

## How This PR Solves The Issue

Record the substitution decision on the object whose lifetime bounds its
validity: the router container itself.

- `generateRouterCompose()` writes a `com.ddev.router-port-substitutions`
  Docker label (e.g. `443=33000`) onto the router, merging the previous
  router's label with substitutions decided by the current process and
  dropping entries whose ephemeral port the new router no longer binds.
- `GetAvailableRouterPort()` consults the label (plus the in-process map)
  when the proposed port looks free on the host: if the running router still
  has the previously-substituted ephemeral port bound, it keeps using the
  substitute instead of handing out the now-free standard port, avoiding the
  spurious recreation.

Because the record lives on the container, it works across separate ddev
invocations, not just within one process, and disappears naturally when the
router is recreated or removed (`ddev poweroff` returns projects to their
configured ports). The map is only consulted when the proposed port is
free; when it is still busy, allocation goes through
`AllocateAvailablePortForRouter()` as before, which honors
`EphemeralRouterPortsAssigned` and gives concurrent projects distinct
ephemeral ports.

Also rewords the "Port X is busy" message to "Port X is not available",
since with this change the substitute can be reported when the port is no
longer busy, and updates the matching troubleshooting docs example.

## Manual Testing Instructions

1. Occupy ports 80/443 (or whatever your configured router ports are) with
   a throwaway listener.
2. `ddev start` project1; note the "Port X is not available, using Y
   instead" message and `docker inspect ddev-router` showing the
   `com.ddev.router-port-substitutions` label.
3. Kill the listener so the standard port is free again.
4. `ddev start` project2 (a separate ddev process); the router is not
   recreated ("ddev-router already running, pushing new config...") and
   project2 adopts the same substitute port.
5. `ddev poweroff && ddev start`: projects return to the standard ports.

## Automated Testing Overview

- New unit tests (`TestParseFormatRouterPortSubstitutions`,
  `TestKnownRouterPortSubstitutions`) cover label serialization, malformed
  input, and label/in-process merging.
- Existing `TestRouterNotRebuiltOnHostnameChange` exercises the
  router-recreation logic with the new label in place (passes locally).

## Release/Deployment Notes

Ephemeral port substitutions become sticky for the life of the router
container: once a project is substituted onto an ephemeral port, it keeps
that port even after the conflicting process goes away, until the router is
recreated (e.g. `ddev poweroff`). Routers created by earlier DDEV versions
have no label, so the first start after upgrade behaves as before; the
label appears at the next router recreation.

Co-Authored-By: Claude Fable 5 <[email protected]>
rfay added a commit to rfay/ddev that referenced this pull request Aug 13, 2026
…ontainer, for ddev#8644

## The Issue

- For ddev#8644

When a standard router port (say 443) is busy at router creation time, the
router is created bound to an ephemeral substitute (say 33000). The router
binds substitutes as `33000:33000`, so the container carries no trace of
which standard port the ephemeral port stands in for. If the original
occupant of 443 then goes away, a later `ddev start` of another project sees
443 as free and expects the router to bind it directly - a port the running
router does not have - so `PortsMatch()` fails and the router is recreated
unnecessarily. That recreation churn is what made
`TestRouterNotRebuiltOnHostnameChange` fail on macos-orbstack and exposed
the CaptureUserOut() hang on Windows.

## How This PR Solves The Issue

Record the substitution decision on the object whose lifetime bounds its
validity: the router container itself.

- `generateRouterCompose()` writes a `com.ddev.router-port-substitutions`
  Docker label (e.g. `443=33000`) onto the router, merging the previous
  router's label with substitutions decided by the current process and
  dropping entries whose ephemeral port the new router no longer binds.
- `GetAvailableRouterPort()` consults the label (plus the in-process map)
  when the proposed port looks free on the host: if the running router still
  has the previously-substituted ephemeral port bound, it keeps using the
  substitute instead of handing out the now-free standard port, avoiding the
  spurious recreation.

Because the record lives on the container, it works across separate ddev
invocations, not just within one process, and disappears naturally when the
router is recreated or removed (`ddev poweroff` returns projects to their
configured ports). The map is only consulted when the proposed port is
free; when it is still busy, allocation goes through
`AllocateAvailablePortForRouter()` as before, which honors
`EphemeralRouterPortsAssigned` and gives concurrent projects distinct
ephemeral ports.

Also rewords the "Port X is busy" message to "Port X is not available",
since with this change the substitute can be reported when the port is no
longer busy, and updates the matching troubleshooting docs example.

## Manual Testing Instructions

1. Occupy ports 80/443 (or whatever your configured router ports are) with
   a throwaway listener.
2. `ddev start` project1; note the "Port X is not available, using Y
   instead" message and `docker inspect ddev-router` showing the
   `com.ddev.router-port-substitutions` label.
3. Kill the listener so the standard port is free again.
4. `ddev start` project2 (a separate ddev process); the router is not
   recreated ("ddev-router already running, pushing new config...") and
   project2 adopts the same substitute port.
5. `ddev poweroff && ddev start`: projects return to the standard ports.

## Automated Testing Overview

- New unit tests (`TestParseFormatRouterPortSubstitutions`,
  `TestKnownRouterPortSubstitutions`) cover label serialization, malformed
  input, and label/in-process merging.
- Existing `TestRouterNotRebuiltOnHostnameChange` exercises the
  router-recreation logic with the new label in place (passes locally).

## Release/Deployment Notes

Ephemeral port substitutions become sticky for the life of the router
container: once a project is substituted onto an ephemeral port, it keeps
that port even after the conflicting process goes away, until the router is
recreated (e.g. `ddev poweroff`). Routers created by earlier DDEV versions
have no label, so the first start after upgrade behaves as before; the
label appears at the next router recreation.

Co-Authored-By: Claude Fable 5 <[email protected]>
rfay added a commit to rfay/ddev that referenced this pull request Aug 13, 2026
…ontainer, for ddev#8644

## The Issue

- For ddev#8644

When a standard router port (say 443) is busy at router creation time, the
router is created bound to an ephemeral substitute (say 33000). The router
binds substitutes as `33000:33000`, so the container carries no trace of
which standard port the ephemeral port stands in for. If the original
occupant of 443 then goes away, a later `ddev start` of another project sees
443 as free and expects the router to bind it directly - a port the running
router does not have - so `PortsMatch()` fails and the router is recreated
unnecessarily. That recreation churn is what made
`TestRouterNotRebuiltOnHostnameChange` fail on macos-orbstack and exposed
the CaptureUserOut() hang on Windows.

## How This PR Solves The Issue

Record the substitution decision on the object whose lifetime bounds its
validity: the router container itself.

- `generateRouterCompose()` writes a `com.ddev.router-port-substitutions`
  Docker label (e.g. `443=33000`) onto the router, merging the previous
  router's label with substitutions decided by the current process and
  dropping entries whose ephemeral port the new router no longer binds.
- `GetAvailableRouterPort()` consults the label (plus the in-process map)
  when the proposed port looks free on the host: if the running router still
  has the previously-substituted ephemeral port bound, it keeps using the
  substitute instead of handing out the now-free standard port, avoiding the
  spurious recreation.

Because the record lives on the container, it works across separate ddev
invocations, not just within one process, and disappears naturally when the
router is recreated or removed (`ddev poweroff` returns projects to their
configured ports). The map is only consulted when the proposed port is
free; when it is still busy, allocation goes through
`AllocateAvailablePortForRouter()` as before, which honors
`EphemeralRouterPortsAssigned` and gives concurrent projects distinct
ephemeral ports.

Also rewords the "Port X is busy" message to "Port X is not available",
since with this change the substitute can be reported when the port is no
longer busy, and updates the matching troubleshooting docs example.

## Manual Testing Instructions

1. Occupy ports 80/443 (or whatever your configured router ports are) with
   a throwaway listener.
2. `ddev start` project1; note the "Port X is not available, using Y
   instead" message and `docker inspect ddev-router` showing the
   `com.ddev.router-port-substitutions` label.
3. Kill the listener so the standard port is free again.
4. `ddev start` project2 (a separate ddev process); the router is not
   recreated ("ddev-router already running, pushing new config...") and
   project2 adopts the same substitute port.
5. `ddev poweroff && ddev start`: projects return to the standard ports.

## Automated Testing Overview

- New unit tests (`TestParseFormatRouterPortSubstitutions`,
  `TestKnownRouterPortSubstitutions`) cover label serialization, malformed
  input, and label/in-process merging.
- Existing `TestRouterNotRebuiltOnHostnameChange` exercises the
  router-recreation logic with the new label in place (passes locally).

## Release/Deployment Notes

Ephemeral port substitutions become sticky for the life of the router
container: once a project is substituted onto an ephemeral port, it keeps
that port even after the conflicting process goes away, until the router is
recreated (e.g. `ddev poweroff`). Routers created by earlier DDEV versions
have no label, so the first start after upgrade behaves as before; the
label appears at the next router recreation.

Co-Authored-By: Claude Fable 5 <[email protected]>
rfay added a commit that referenced this pull request Aug 14, 2026
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.

1 participant