Skip to content

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

Open
dislbenn wants to merge 1 commit intoopenshift:mainfrom
dislbenn:fix-acm-fastforward-array-refs
Open

fix(acm): safe array expansion in fast-forward script#78956
dislbenn wants to merge 1 commit intoopenshift: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 addressing a Bash script error in the fast-forward synchronization workflow used for the stolostron/acm-config repository.

Problem

The ocm-ci-fastforward-multiple step—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 uses set -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 restrictions
  • FAILED_FASTFORWARDS — repositories where branch synchronization failed
  • FAILED_TEKTON — repositories where Tekton configuration updates failed
  • CLEANED_BRANCHES — branches that were cleaned up

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

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]>
@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: 12ec9746-8581-4340-a553-613d20173932

📥 Commits

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

📒 Files selected for processing (1)
  • ci-operator/step-registry/ocm/ci/fastforward-multiple/ocm-ci-fastforward-multiple-commands.sh

Walkthrough

A Bash script is modified to defensively handle potentially unset arrays by adding default value expansions (${array[@]:-0}) in array length checks, preventing errors under bash's nounset mode.

Changes

Safe Array Expansion

Layer / File(s) Summary
Defensive Array Guards
ci-operator/step-registry/ocm/ci/fastforward-multiple/ocm-ci-fastforward-multiple-commands.sh
Array length checks in skipped repositories count, conditionals, and failure reporting blocks are updated to use ${#ARRAY[@]:-0} syntax instead of ${#ARRAY[@]}, preventing unset variable errors. Affected sections: skipped count display, skipped repositories conditional, fast-forward failures, Tekton file creation failures, and cleaned branches guard.

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 'fix(acm): safe array expansion in fast-forward script' accurately describes the main change: using safe parameter expansion to prevent unbound variable errors in array length checks within a Bash 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 applies to Ginkgo test names in Go code. This PR modifies only a Bash shell script and YAML configuration files—no Go test files exist. The check is not applicable.
Test Structure And Quality ✅ Passed Check not applicable. PR modifies a Bash CI script, not Ginkgo tests. Custom check requires reviewing Go testing framework patterns that do not exist in this PR.
Microshift Test Compatibility ✅ Passed This PR modifies a Bash CI script and does not add any Ginkgo e2e tests. The custom check is not applicable - it requires new Ginkgo test additions to evaluate.
Single Node Openshift (Sno) Test Compatibility ✅ Passed Custom check not applicable. PR modifies only a Bash shell script for CI operations, not Ginkgo e2e tests. The SNO compatibility check applies to new/modified e2e tests only.
Topology-Aware Scheduling Compatibility ✅ Passed Custom check not applicable. PR modifies a Bash CI automation script with no scheduling constraints, Kubernetes manifests, or operator code changes.
Ote Binary Stdout Contract ✅ Passed This custom check is not applicable to the PR. The check validates OTE binary stdout contracts in Go test code, but the PR only modifies a Bash CI automation script for array expansion safety.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed Not applicable. PR modifies only a Bash shell script for CI operator infrastructure, not Ginkgo e2e tests. Custom check applies only to new Ginkgo tests.

✏️ 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
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 6, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: dislbenn
Once this PR has been reviewed and has the lgtm label, please assign eemurphy for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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-merge-bot
Copy link
Copy Markdown
Contributor

[REHEARSALNOTIFIER]
@dislbenn: the pj-rehearse plugin accommodates running rehearsal tests for the changes in this PR. Expand 'Interacting with pj-rehearse' for usage details. The following rehearsable tests have been affected by this change:

Test name Repo Type Reason
periodic-ci-stolostron-acm-config-main-fast-forward N/A periodic Registry content changed

Prior to this PR being merged, you will need to either run and acknowledge or opt to skip these rehearsals.

Interacting with pj-rehearse

Comment: /pj-rehearse to run up to 5 rehearsals
Comment: /pj-rehearse skip to opt-out of rehearsals
Comment: /pj-rehearse {test-name}, with each test separated by a space, to run one or more specific rehearsals
Comment: /pj-rehearse more to run up to 10 rehearsals
Comment: /pj-rehearse max to run up to 25 rehearsals
Comment: /pj-rehearse auto-ack to run up to 5 rehearsals, and add the rehearsals-ack label on success
Comment: /pj-rehearse list to get an up-to-date list of affected jobs
Comment: /pj-rehearse abort to abort all active rehearsals
Comment: /pj-rehearse network-access-allowed to allow rehearsals of tests that have the restrict_network_access field set to false. This must be executed by an openshift org member who is not the PR author

Once you are satisfied with the results of the rehearsals, comment: /pj-rehearse ack to unblock merge. When the rehearsals-ack label is present on your PR, merge will no longer be blocked by rehearsals.
If you would like the rehearsals-ack label removed, comment: /pj-rehearse reject to re-block merging.

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 6, 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant