ci(#6216): retry transient errors in after-scenario cleanup hooks - #6217
Conversation
After-scenario cleanup operations (closing issues, deleting branches, deleting repos, clearing dummy scripts) now retry on transient API errors before falling back to log-and-continue. This prevents flaky merge queue ejections caused by transient GCP 503 or GitHub 5xx errors during cleanup, while non-transient errors (401, 404, 422) are still logged immediately without retry. Changes: - Add forge.IsTransient() to detect transient errors via a transientReporter interface, timeout detection, io.EOF checks, and ErrNonFastForward race conditions - Add IsTransient() method to GitHub, GitLab, and Jira APIError types (true for HTTP 429 and 500-504) - Wrap all API operations in CleanupScenario with a cleanupRetry helper that retries up to 3 times with exponential backoff for transient errors, then logs the final error and continues - Add comprehensive tests for forge.IsTransient, APIError.IsTransient, cleanupRetry helper, and end-to-end retry in CleanupScenario Closes #6216
|
🤖 Finished Review · ✅ Success · Started 11:02 PM UTC · Completed 11:18 PM UTC Commit: |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Looks good to me Previous runReviewFindingsMedium
Low
Labels: PR modifies forge error handling infrastructure (internal/forge/) and behaviour test cleanup hooks (pkg/behaviourtest/) |
|
/fs-fix |
|
🤖 Finished Fix · ✅ Success · Started 8:17 PM UTC · Completed 8:26 PM UTC Commit: |
…nup tests - Guard IsTransient against context.DeadlineExceeded (implements Timeout()→true but reflects caller intent, not server failure) and context.Canceled before the Timeout() interface check - Add test cases for both bare and wrapped context errors - Remove t.Parallel() from cleanup retry tests that mutate the package-level cleanupBaseDelay variable via speedUpCleanupRetries, preventing a data race the -race detector would flag Addresses review feedback on #6217
🔧 Fix agent — iteration 1 (human-triggered)Addressed both review findings: (1) added context.DeadlineExceeded/context.Canceled guard in IsTransient before the Timeout() check with corresponding test cases, (2) removed t.Parallel() from cleanup retry tests that mutate package-level state. All tests pass with -race detector. Fixed (2):
Tests: passedNext steps:
|
|
🤖 Finished Review · ✅ Success · Started 8:28 PM UTC · Completed 8:41 PM UTC Commit: |
|
🤖 Finished Retro · ✅ Success · Started 5:34 PM UTC · Completed 5:48 PM UTC Commit: |
Retro: PR #6217 — retry transient errors in after-scenario cleanup hooksTimeline
Total agent time: ~44 minutes. Total elapsed: ~7 days. Human latency dominated. What went well
Evidence for existing issues (not proposing new issues)
Proposals filedSee linked proposals below. Proposals filed
|
Summary
forge.IsTransient()transient error detection for forge API errors, timeouts, EOF, and race conditionsIsTransient()method to GitHub, GitLab, and JiraAPIErrortypes (HTTP 429 and 500–504)CleanupScenariowith acleanupRetryhelper: retries transient errors up to 3 times with exponential backoff, then logs and continuesContext
After-scenario cleanup hooks in the behaviour test suite perform API operations (closing issues/PRs, deleting branches/repos, clearing dummy scripts) that are not part of the test assertion itself. When these cleanup calls hit transient infrastructure errors (GCP IAM 503, GitHub 5xx), the cleanup fails and can leave orphaned resources. This change adds retry resilience to prevent transient errors from disrupting cleanup, while keeping non-transient errors visible through logging.
Also addresses the broader pattern described in #5774 (422 Tree SHA race) by detecting
ErrNonFastForwardas a transient error worthy of retry at the cleanup level.Testing
forge.IsTransient()covering all error types (nil, sentinels, transient reporter, timeout, EOF, non-transient)APIError.IsTransient()across all HTTP status codescleanupRetryhelper: immediate success, transient-then-success, exhausted retries, non-transient no-retryCleanupScenarioretries transientCloseIssueandCommitFileerrorsCloses #6216
Post-script verification
agent/6216-cleanup-transient-retry)fcd4702368c74d517911b177f7ee7eca1634865b..HEAD)