Skip to content

trigger-merge-queue: retry PR lookup to handle search-index lag#13157

Open
skoryk-oleksandr wants to merge 1 commit into
projectcalico:masterfrom
skoryk-oleksandr:fix/trigger-merge-queue-retry
Open

trigger-merge-queue: retry PR lookup to handle search-index lag#13157
skoryk-oleksandr wants to merge 1 commit into
projectcalico:masterfrom
skoryk-oleksandr:fix/trigger-merge-queue-retry

Conversation

@skoryk-oleksandr

@skoryk-oleksandr skoryk-oleksandr commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

The Trigger Merge Cat workflow queries repos/calico/commits/{sha}/pulls immediately after a push to master. 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 the OSS_MERGE trigger 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 reported success, 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 api transport error) produce the expected output.

Release note:
```release-note
None
```

Copilot AI review requested due to automatic review settings July 7, 2026 21:18
@skoryk-oleksandr skoryk-oleksandr requested a review from a team as a code owner July 7, 2026 21:18
@skoryk-oleksandr skoryk-oleksandr added docs-not-required Docs not required for this change release-note-not-required Change has no user-facing impact labels Jul 7, 2026
@marvin-tigera marvin-tigera added this to the Calico v3.33.0 milestone Jul 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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}/pulls lookup to reduce false “no PR” results.
  • Move ${{ github.repository }} and ${{ github.sha }} into step env: 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
@skoryk-oleksandr skoryk-oleksandr force-pushed the fix/trigger-merge-queue-retry branch from 886b39f to 8c7d2c4 Compare July 7, 2026 21:54
@skoryk-oleksandr skoryk-oleksandr changed the title trigger-merge-queue: retry PR lookup to handle search-index lag trigger-merge-queue: parse PR number from commit subject with API fallback Jul 7, 2026
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.
@skoryk-oleksandr skoryk-oleksandr force-pushed the fix/trigger-merge-queue-retry branch from 8c7d2c4 to 06fcaf4 Compare July 7, 2026 22:13
@skoryk-oleksandr skoryk-oleksandr changed the title trigger-merge-queue: parse PR number from commit subject with API fallback trigger-merge-queue: retry PR lookup to handle search-index lag Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs-not-required Docs not required for this change release-note-not-required Change has no user-facing impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants