fix(acm): safe array expansion in fast-forward script#78956
fix(acm): safe array expansion in fast-forward script#78956dislbenn wants to merge 1 commit intoopenshift:mainfrom
Conversation
Fixes unbound variable error when arrays are empty with set -u.
Changed all array length checks from ${#ARRAY[@]} to ${#ARRAY[@]:-0}:
- SKIPPED_NO_ACCESS
- FAILED_FASTFORWARDS
- FAILED_TEKTON
- CLEANED_BRANCHES
Error occurred at line 1445 in periodic job run:
https://prow.ci.openshift.org/view/gs/test-platform-results/logs/periodic-ci-stolostron-acm-config-main-fast-forward/2052110513516580864
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
|
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)
WalkthroughA Bash script is modified to defensively handle potentially unset arrays by adding default value expansions ( ChangesSafe Array Expansion
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~4 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: |
|
@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. |
Fixes unbound variable error causing periodic job failure.
Problem
Periodic job
periodic-ci-stolostron-acm-config-main-fast-forwardfailed with:Failed run
Root Cause
Script uses
set -uo pipefail. Array length checks like${#ARRAY[@]}fail when arrays are empty withset -u.Fix
Use safe parameter expansion
${#ARRAY[@]:-0}for all array length checks:SKIPPED_NO_ACCESSFAILED_FASTFORWARDSFAILED_TEKTONCLEANED_BRANCHESTesting
Fix allows summary section to complete even when arrays are empty.
🤖 Generated with Claude Code
Overview
This PR fixes a recurring failure in the ACM (Advanced Cluster Management) CI infrastructure by addressing a Bash script error in the fast-forward synchronization workflow used for the
stolostron/acm-configrepository.Problem
The
ocm-ci-fastforward-multiplestep—a core part of the ACM configuration CI pipeline—was failing with an "unbound variable" error when attempting to report repository synchronization results. This occurred because the script usesset -uo pipefail(strict mode), which treats references to empty arrays as unset variables, causing the script to exit prematurely during the summary reporting phase.Solution
The fix applies safe parameter expansion (
${#ARRAY[@]:-0}) to array length checks in the summary reporting section. Specifically, four arrays used to track operation failures and skipped repositories are now guarded with default values:SKIPPED_NO_ACCESS— repositories that couldn't be processed due to access restrictionsFAILED_FASTFORWARDS— repositories where branch synchronization failedFAILED_TEKTON— repositories where Tekton configuration updates failedCLEANED_BRANCHES— branches that were cleaned upThis allows the summary to complete and report results correctly even when these arrays remain empty, which is a normal state when no failures occur.
Impact
This change enables the periodic ACM fast-forward job (
periodic-ci-stolostron-acm-config-main-fast-forward) to complete successfully. The fast-forward operation is responsible for keeping multiple ACM repository branches synchronized with upstream branches and maintaining consistency in build configuration files.