🌱 test/e2e: cancel spec context on fast-fail to unblock waits#2116
Open
guettli wants to merge 3 commits into
Open
🌱 test/e2e: cancel spec context on fast-fail to unblock waits#2116guettli wants to merge 3 commits into
guettli wants to merge 3 commits into
Conversation
When logStatusContinuously detects a PermanentError or NoAvailableHost condition, it previously called Fail() from the goroutine. That records the Ginkgo failure and exits the goroutine, but the main It goroutine keeps blocking on WaitForControlPlaneToBeReady until the full 1200-second timeout. Fix: add a per-spec cancel function (specCancelFn, guarded by specCancelMu in caph.go) that the fail-fast goroutine can call alongside Fail(). Each It block creates a cancellable child context (specCtx), registers its cancel function via setSpecCancel, and passes specCtx to ApplyClusterTemplateAndWait. When the goroutine fires, specCtx is cancelled immediately and the wait aborts — saving up to 10+ minutes of CI time when hardware reboots fail. AfterEach still uses the original ctx so cleanup is unaffected. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> # Committing as: thomas.guettler@syself.com
No need for an intermediate fn variable — specCancelFn is a context.CancelFunc that does not touch specCancelMu, so calling it directly under the lock is safe and simpler. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> # Committing as: thomas.guettler@syself.com
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
The CI failure on #2113 CI Run was caused by a physical bare metal server failing to boot into rescue mode — completely unrelated to that PR's changes.
However, the failure revealed that the existing fail-fast mechanism in
logStatusContinuouslyisn't actually fast. When it detects aPermanentErroron aHetznerBareMetalHost, it callsFail()from the goroutine. That records the Ginkgo failure and exits the goroutine, but the mainItgoroutine keeps blocking onWaitForControlPlaneToBeReadyuntil the full 1200-second timeout — wasting ~10 minutes of CI time per occurrence.Fix
specCancelFn(protected byspecCancelMu) incaph.go, updated per-spec viasetSpecCancel/clearSpecCancel.CaphClusterDeploymentSpec'sItblock, create a cancellable child context (specCtx) and register its cancel. PassspecCtxtoApplyClusterTemplateAndWait.logStatusContinuously, callfn()(cancel the spec context) beforeFail()soWaitForControlPlaneToBeReadyaborts immediately.AfterEachstill uses the originalctx, so cleanup is unaffected.Result
When hardware reboots fail (PermanentError after ~10 min), the test now aborts within ~30 seconds of detection instead of waiting the full 1200-second timeout.
Test plan
🤖 Generated with Claude Code