fix(acm): safe array expansion in fast-forward script#78956
fix(acm): safe array expansion in fast-forward script#78956openshift-merge-bot[bot] merged 2 commits into
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 <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)
✅ Files skipped from review due to trivial changes (1)
WalkthroughThe Bash script ChangesArray initialization fix
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 |
|
/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. |
|
/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. |
Array declarations need initialization to prevent "bad substitution"
errors when using ${#array[@]} syntax. Changed declare -a to ARRAY=()
initialization for FAILED_FASTFORWARDS, FAILED_TEKTON, SKIPPED_NO_ACCESS.
Added missing CLEANED_BRANCHES initialization. Removed invalid :-0
default operators from array length checks.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: dislbenn <dbennett@redhat.com>
|
/pj-rehearse periodic-ci-stolostron-acm-config-main-fast-forward |
1 similar 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. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dislbenn, mark-nc, ngraham20 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/pj-rehearse ack |
|
@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. |
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 correcting a Bash script error in the fast-forward synchronization workflow used by the stolostron/acm-config CI job.
Problem
The periodic job periodic-ci-stolostron-acm-config-main-fast-forward was failing with "/bin/bash: line 1447: SKIPPED_NO_ACCESS: unbound variable". The fast-forward script runs with strict Bash options (set -uo pipefail), and checks like ${#ARRAY[@]} can cause an unbound-variable exit when arrays are unset under set -u.
Solution
The fast-forward step script (ci-operator/step-registry/ocm/ci/fastforward-multiple/ocm-ci-fastforward-multiple-commands.sh) now ensures the tracking arrays are defined before they are inspected. The arrays FAILED_FASTFORWARDS, FAILED_TEKTON, SKIPPED_NO_ACCESS, and CLEANED_BRANCHES are initialized as empty arrays (ARRAY=()) so length checks and summary reporting no longer trigger unbound-variable errors. The change also removed incorrect use of default operators in the earlier commit; overall the script now safely handles empty/unset arrays under set -u.
Impact
With these changes the periodic fast-forward job can complete its summary and finish successfully even when no failures occur. This stabilizes the stolostron/acm-config fast-forward workflow used by OpenShift CI to keep ACM repository branches and Tekton/config updates synchronized.