fix: prevent duplicate Tekton file PRs in multi-fastforward#79634
fix: prevent duplicate Tekton file PRs in multi-fastforward#79634dislbenn wants to merge 1 commit into
Conversation
Script was creating duplicate PRs for Tekton files already merged to main. Root cause: Script checked for existing files on PR branch instead of default branch, then created PRs even when main already had all files. Fixes: 1. Check default branch for existing files BEFORE touching PR branch. If all requested versions exist on default branch, delete stale PR branch and exit. 2. Reset PR branch to default branch when files are needed. Prevents accumulating stale version files (e.g., acm-217) on PR branch. Impact: Stops spam PRs like stolostron/siteconfig#1106 where acm-50/51 files already exist on main. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Central YAML (inherited) Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
WalkthroughThis PR refines the ChangesTekton File and PR Branch Handling
🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 12✅ Passed checks (12 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: dislbenn The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
[REHEARSALNOTIFIER]
Prior to this PR being merged, you will need to either run and acknowledge or opt to skip these rehearsals. Interacting with pj-rehearseComment: Once you are satisfied with the results of the rehearsals, comment: |
|
/pj-rehearse periodic-ci-stolostron-acm-config-main-fast-forward |
|
@dislbenn: now processing your pj-rehearse request. Please allow up to 10 minutes for jobs to trigger or cancel. |
|
@dislbenn: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Summary
Fixes duplicate PR spam for Tekton files already merged to main (e.g., stolostron/siteconfig#1106).
Problem
The
ocm-ci-fastforward-multiplescript was creating duplicate PRs for Tekton files that were already on the default branch. For example, siteconfig repo kept getting PRs to add acm-50 and acm-51 files even though they were already merged to main.Root cause: Script checked for existing files on the PR branch instead of the default branch. When a stale PR branch existed with old files (e.g., acm-217), the script would:
files_created=false)Changes
Fix 1: Check default branch first (lines 547-599)
Fix 2: Reset PR branch to default when needed (lines 605-627)
Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
This PR fixes a bug in the OpenShift CI infrastructure's
ocm-ci-fastforward-multiplescript that was generating duplicate pull requests for Tekton workflow files already merged to the default branch.Root Cause: The script was checking whether Tekton files existed on the PR branch instead of the target repository's default branch. When a stale PR branch lingered with outdated files, the script would detect those old files, skip creating new ones, but still generate a PR—resulting in duplicate PRs for changes already merged.
The Solution: The fix implements three key safeguards:
Early existence check on default branch (lines 546–599): Before attempting any file creation, the script now verifies whether all requested Tekton file versions already exist on the default branch. If they do, it cleans up by closing any lingering PR associated with the stale branch, deletes that remote branch, and exits early—preventing the creation of unnecessary duplicate PRs.
Branch reset to remove stale content (lines 609–627): When a PR branch already exists on the remote, the script now hard-resets it to
origin/${default_branch}instead of just checking out the existing branch and attempting DCO sign-off amendments. This eliminates stale versions and prevents the accumulation of old content.PR creation guard (lines 809–820): When handling the case where a PR branch exists remotely but no PR exists, the script now fetches the default branch and uses
git diff --quietto verify the branch actually contains changes relative to the default branch. It only creates a PR if substantive changes are present.These changes ensure the Tekton file fastforward process remains idempotent and prevents infrastructure PRs from proliferating when changes have already been merged to the main branch.