trigger-merge-queue: retry PR lookup to handle search-index lag#13157
Open
skoryk-oleksandr wants to merge 1 commit into
Open
trigger-merge-queue: retry PR lookup to handle search-index lag#13157skoryk-oleksandr wants to merge 1 commit into
skoryk-oleksandr wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves reliability of the “Trigger Merge Cat” GitHub Actions workflow by making the PR-number lookup resilient to short-lived GitHub indexing lag that can occur immediately after merges to master.
Changes:
- Add a bounded retry loop (3 attempts, 5s delay) around the
commits/{sha}/pullslookup to reduce false “no PR” results. - Move
${{ github.repository }}and${{ github.sha }}into stepenv:and reference them via shell variables inside the script.
Comment on lines
40
to
44
| if [[ -n "$PR_NUMBER" && "$PR_NUMBER" =~ ^[0-9]+$ ]]; then | ||
| echo "number=${PR_NUMBER}" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "::notice::No associated PR found for ${{ github.sha }} -- skipping merge-queue dispatch" | ||
| echo "::notice::No associated PR found for ${SHA} after retries -- skipping merge-queue dispatch" | ||
| fi |
886b39f to
8c7d2c4
Compare
The commits/{sha}/pulls endpoint occasionally returns an empty array in
the first few seconds after a merge while GitHub's search index catches
up. When that happened the workflow silently skipped the merge-queue
dispatch, so freshly merged PRs were missing from the bot's OSS_MERGE
trigger path. Recent runs showed this happening on roughly every other
push.
Retry the lookup up to three times with a 5s sleep between attempts,
matching the same pattern used by cherry_pick_candidate.js.
8c7d2c4 to
06fcaf4
Compare
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.
The
Trigger Merge Catworkflow queriesrepos/calico/commits/{sha}/pullsimmediately after a push tomaster. That endpoint occasionally returns an empty array for the first few seconds after a merge while GitHub's search index catches up. When that happened, the workflow silently skipped the merge-queue dispatch and the downstream bot never got theOSS_MERGEtrigger for that PR.Sampling the last 30 runs showed the miss rate at roughly 50%: 15 dispatched, 15 exited with
::notice::No associated PR found. The workflow itself always reportedsuccess, so the failure was invisible from the Actions UI.Change
Retry the PR-number lookup up to 3 times with a 5s sleep between attempts. Same pattern used by
cherry_pick_candidate.js(which has a comment noting the same failure mode). Also moves `${{ github.repository }}` and `${{ github.sha }}` into `env:` and references them as shell variables, matching current security guidance for workflow steps.Testing
Static change to a workflow shell script; the effect can only be observed on live pushes. Locally verified that the retry loop is well-formed bash and that all four exit paths (immediate hit, hit on retry, all attempts return empty,
gh apitransport error) produce the expected output.Release note:
```release-note
None
```