test: fix flaky TestAddModuleWorkerViaAdminApi - #2605
Merged
Conversation
The test POSTs a full config to the admin /load endpoint, which swaps the HTTP listener for the new config, then immediately GETs the newly added worker. A request racing that swap can hit a reset connection (EOF) before the worker ever sees it, as seen on CI (#2604 CI run, and previously on #2412/#2381 per #2413 for the sibling autoscale tests). Retry only on connection-level errors, not on the request itself: once a request reaches the worker it always increments its counter, so retrying past that point would break the "requests:1" assertion.
dunglas
commented
Aug 15, 2026
Comment on lines
+356
to
+362
| for i := 0; i < 20; i++ { | ||
| getResp, err = http.Get(workerURL) | ||
| if err == nil { | ||
| break | ||
| } | ||
| time.Sleep(50 * time.Millisecond) | ||
| } |
Matches the existing retry idiom used elsewhere in this codebase (frankenphp_test.go, finishrequest_realserver_test.go, worker_internal_test.go, caddy/watcher_test.go, caddy/caddy_test.go) instead of a bespoke for-loop.
henderkes
approved these changes
Aug 16, 2026
alexandre-daubois
approved these changes
Aug 16, 2026
Member
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TestAddModuleWorkerViaAdminApiPOSTs a full config to the admin/loadendpoint, which swaps the HTTP listener for the new config, then immediately GETs the newly added worker. A request racing that listener swap can hit a reset connection (EOF) before the worker ever sees it — seen on CI in php/frankenphp#2604 (job 94991854286), and matches the same class of flake fixed for the sibling autoscale tests in #2413 (which references this test too, on #2412/#2381).Retry only on connection-level errors (
err != nilfromhttp.Get), not on the request/response itself: once a request actually reaches the worker it always increments its counter, so retrying past a successful connection would break therequests:1assertion.Test plan
./go.sh -C caddy test ./...passes./go.sh -C caddy test ./... -run TestAddModuleWorkerViaAdminApi -count=5passes