Repository navigation
test(hosts): fix update-worker timeout flake blocking #576 - #577
Merged
Merged
Conversation
Contributor
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.
Fixes the
lib/hosts/update-worker.test.mjsflake that fails Verify on #576 (run 1 Ubuntu and run 2 macOS, both at :1127): a replacementhealth.jsonexists when the test expects none, in "a pending stop whose process identity changes retains recovery-required state and its claim".Root cause
A test-fixture timing race — no production code changed. The fixture's daemon delays its SIGTERM exit by 11 s, but the stop wait is 10 s, leaving only a ~1 s margin between the stop timing out (
stop_pending) and the daemon exiting:stopUpgradeProcessmutatesplan.current.identityto simulate a recycled/unverifiable identity, and the worker callsreconcilePendingStop.reconcilePendingStopreads the identity, finds it mismatched, and then re-checks aliveness: if the daemon is still alive it throws (recovery-required, no replacement — the expected path), but if the daemon has already exited it returns success ("a successful signal may outlast the stop wait").health.json— so:1127fails (true !== false).Under a loaded CI runner a slow identity read (macOS spawns
psfor it) or a stalled worker easily eats the 1 s margin. Proven locally: delaying the copied worker's identity read by 2 s flips the outcome deterministically — the test fails with state"failed"and"previous host release restored"instead of"running"withrecoveryRequired. The same 2 s delay with the fix below still passes.Fix (test file only)
unreconciled-stopfixture'sshutdownDelaygoes from 11 s to 60 s, so the daemon is certainly alive when reconciliation reads its identity. The test still ends at ~11 s (the identity mismatch fails reconciliation on its first read), and the after-hook SIGKILLs the lingering daemon.delayed-stop/stop-identity-exit-racetests keep 11 s on purpose: they need the daemon to exit for their own reconciliation path.No production defect was found: when the daemon really has exited, proceeding to relaunch the old release is the designed behaviour — the test's scenario is a live process with an unverifiable identity, and only the fixture's 1 s margin failed to guarantee that.
Verification
bun teston the fixed test: 3/3 pass under hostile umask0007(~11 s each, same as before).0007: both "pending stop" tests pass; "delayed-stop" 3/3; the pin-external-runner-swap test 3/3.lib/hosts/update-worker.test.mjs: 86 pass / 0 fail (post-fix run).npx tsc --noEmitandnpx eslint lib/hosts/update-worker.test.mjs: clean.Deliberately left out: the run-2 macOS
:1097failure (stop-identity-exit-race) and thepin-external-runner-swapdigest-mismatch note did not reproduce locally (both pass repeatedly here, including under umask0007), and the digest-mismatch error cannot come from the stop-identity-exit-race worker — its descriptor carries no release pin. Left for observation on the next CI run rather than bundling an unproven fix. The run-2 Ubuntulib/web-settings.test.mjs:363failure is a different area and untouched.Unblocks #576.
Summary by CodeRabbit