Skip to content

fix(acm): safe array expansion in fast-forward script#78956

Merged
openshift-merge-bot[bot] merged 2 commits into
openshift:mainfrom
dislbenn:fix-acm-fastforward-array-refs
May 8, 2026
Merged

fix(acm): safe array expansion in fast-forward script#78956
openshift-merge-bot[bot] merged 2 commits into
openshift:mainfrom
dislbenn:fix-acm-fastforward-array-refs

Conversation

@dislbenn
Copy link
Copy Markdown
Contributor

@dislbenn dislbenn commented May 6, 2026

Fixes unbound variable error causing periodic job failure.

Problem

Periodic job periodic-ci-stolostron-acm-config-main-fast-forward failed with:

/bin/bash: line 1447: SKIPPED_NO_ACCESS: unbound variable

Failed run

Root Cause

Script uses set -uo pipefail. Array length checks like ${#ARRAY[@]} fail when arrays are empty with set -u.

Fix

Use safe parameter expansion ${#ARRAY[@]:-0} for all array length checks:

  • SKIPPED_NO_ACCESS
  • FAILED_FASTFORWARDS
  • FAILED_TEKTON
  • CLEANED_BRANCHES

Testing

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.

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>
@openshift-ci openshift-ci Bot requested a review from dgoodwin May 6, 2026 21:39
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 6, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 8c79b6af-68ef-4105-8b09-510fd70eccd3

📥 Commits

Reviewing files that changed from the base of the PR and between 43e834d and 8b45401.

📒 Files selected for processing (1)
  • ci-operator/step-registry/ocm/ci/fastforward-multiple/ocm-ci-fastforward-multiple-commands.sh
✅ Files skipped from review due to trivial changes (1)
  • ci-operator/step-registry/ocm/ci/fastforward-multiple/ocm-ci-fastforward-multiple-commands.sh

Walkthrough

The Bash script ci-operator/step-registry/ocm/ci/fastforward-multiple/ocm-ci-fastforward-multiple-commands.sh now explicitly initializes tracking arrays (FAILED_FASTFORWARDS, FAILED_TEKTON, SKIPPED_NO_ACCESS, CLEANED_BRANCHES) to empty arrays instead of using declare -a, preventing unbound-variable failures under set -u.

Changes

Array initialization fix

Layer / File(s) Summary
Initialization
ci-operator/step-registry/ocm/ci/fastforward-multiple/ocm-ci-fastforward-multiple-commands.sh
Replaces declare -a array declarations with explicit empty-array assignments (e.g., FAILED_FASTFORWARDS=()) so arrays exist when set -u is enabled.
Usage / Reporting
ci-operator/step-registry/ocm/ci/fastforward-multiple/ocm-ci-fastforward-multiple-commands.sh
Existing final-summary and listing logic that checks array lengths or iterates arrays now operate on defined arrays, avoiding nounset errors.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~4 minutes

🚥 Pre-merge checks | ✅ 12
✅ Passed checks (12 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the main change: initializing arrays safely to prevent unbound variable errors in the fast-forward script.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed The custom check for Ginkgo test names applies only to Go test files. This PR modifies only a bash script with no test title definitions, making the check not applicable.
Test Structure And Quality ✅ Passed Custom check is for Ginkgo test code quality, but PR only modifies a bash shell script for CI operations. No Ginkgo tests present—check not applicable.
Microshift Test Compatibility ✅ Passed This PR modifies only a bash shell script to fix array initialization issues. No Ginkgo e2e tests or Go test code is added, so the MicroShift Test Compatibility check is not applicable.
Single Node Openshift (Sno) Test Compatibility ✅ Passed This PR modifies a bash CI operator script, not Ginkgo e2e tests. The custom check applies only to new Ginkgo e2e test additions, which are not present in this PR. Check is not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed PR modifies a bash CI/CD script only, with no Kubernetes manifests or scheduling constraints. Check not applicable.
Ote Binary Stdout Contract ✅ Passed PR modifies only a bash shell script. The OTE Binary Stdout Contract check applies to Go test binaries with JSON stdout. This bash script is not a test binary and is not subject to this check.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No Ginkgo e2e tests are present. The PR only modifies a bash shell script (ocm-ci-fastforward-multiple-commands.sh) for CI operations, not test code. The custom check is not applicable.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci openshift-ci Bot requested a review from xueqzhan May 6, 2026 21:39
@dislbenn
Copy link
Copy Markdown
Contributor Author

dislbenn commented May 7, 2026

/pj-rehearse periodic-ci-stolostron-acm-config-main-fast-forward

@openshift-merge-bot
Copy link
Copy Markdown
Contributor

@dislbenn: now processing your pj-rehearse request. Please allow up to 10 minutes for jobs to trigger or cancel.

@dislbenn
Copy link
Copy Markdown
Contributor Author

dislbenn commented May 7, 2026

/pj-rehearse periodic-ci-stolostron-acm-config-main-fast-forward

@openshift-merge-bot
Copy link
Copy Markdown
Contributor

@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>
@dislbenn
Copy link
Copy Markdown
Contributor Author

dislbenn commented May 7, 2026

/pj-rehearse periodic-ci-stolostron-acm-config-main-fast-forward

1 similar comment
@dislbenn
Copy link
Copy Markdown
Contributor Author

dislbenn commented May 7, 2026

/pj-rehearse periodic-ci-stolostron-acm-config-main-fast-forward

@openshift-merge-bot
Copy link
Copy Markdown
Contributor

@dislbenn: now processing your pj-rehearse request. Please allow up to 10 minutes for jobs to trigger or cancel.

Copy link
Copy Markdown
Contributor

@ngraham20 ngraham20 left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label May 7, 2026
Copy link
Copy Markdown
Contributor

@mark-nc mark-nc left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 8, 2026

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 8, 2026
@dislbenn
Copy link
Copy Markdown
Contributor Author

dislbenn commented May 8, 2026

/pj-rehearse ack

@openshift-merge-bot
Copy link
Copy Markdown
Contributor

@dislbenn: now processing your pj-rehearse request. Please allow up to 10 minutes for jobs to trigger or cancel.

@openshift-merge-bot openshift-merge-bot Bot added the rehearsals-ack Signifies that rehearsal jobs have been acknowledged label May 8, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 8, 2026

@dislbenn: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions 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.

@openshift-merge-bot openshift-merge-bot Bot merged commit 9705dea into openshift:main May 8, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. rehearsals-ack Signifies that rehearsal jobs have been acknowledged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants