Skip to content

Parallelize binary builds and add BUILD_IMAGES allow-list#5081

Open
Prucek wants to merge 1 commit intoopenshift:mainfrom
Prucek:build-optimization
Open

Parallelize binary builds and add BUILD_IMAGES allow-list#5081
Prucek wants to merge 1 commit intoopenshift:mainfrom
Prucek:build-optimization

Conversation

@Prucek
Copy link
Copy Markdown
Member

@Prucek Prucek commented Apr 2, 2026

Summary

  • Parallelize go install calls in hack/install.sh — builds all binaries concurrently instead of sequentially
  • Add BUILD_IMAGES env var allow-list to build only specific binaries when needed

🤖 Generated with Claude Code

@openshift-ci-robot
Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: automatic mode

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 2, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 589d04da-441e-43fa-906e-759c9474f920

📥 Commits

Reviewing files that changed from the base of the PR and between cceccc7 and 459a2d6.

📒 Files selected for processing (1)
  • hack/install.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • hack/install.sh

Walkthrough

Add BUILD_IMAGES allow-list (comma-separated, parsed into a map) to hack/install.sh to control which ./cmd/... Go binaries are built (when set it supersedes SKIPPED_IMAGES); process ./cmd/ subdirectories in sorted order; run go install in parallel with a MAX_PARALLEL throttle (default 4); aggregate background build failures and exit nonzero if any fail.

Changes

Cohort / File(s) Summary
Build script enhancement
hack/install.sh
Add BUILD_IMAGES allow-list parsing into an associative map; when non-empty it takes precedence over SKIPPED_IMAGES; sort ./cmd/ subdirectories for deterministic discovery; run go install in background with configurable concurrency via MAX_PARALLEL (default 4), throttle by waiting when the PID queue hits the limit; collect PIDs, wait for each, detect any nonzero exits and return status 1 if any build fails.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

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

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

@Prucek
Copy link
Copy Markdown
Member Author

Prucek commented Apr 2, 2026

/hold

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 2, 2026
@openshift-ci openshift-ci bot requested review from danilo-gemoli and droslean April 2, 2026 13:53
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Apr 2, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Prucek

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 Apr 2, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@hack/install.sh`:
- Around line 67-82: The script currently tracks only PIDs (pids array) and
counts failures (failures array) so failing builds aren't named; change the
launch loop to record the mapping of PID to command (e.g., declare -A pid_to_cmd
and after starting each go install put pid_to_cmd[$!]="$command"), then in the
wait loop use that map to capture the failed command name (retrieve
pid_to_cmd[$pid]) and append the command name (not just PID) to failures;
finally, print the failing command names when reporting errors. Ensure an
associative array is declared before use and that you still collect PIDs in pids
for wait.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cc43bb98-9d32-4156-acc8-2061852a0a0a

📥 Commits

Reviewing files that changed from the base of the PR and between f56c667 and 322a603.

📒 Files selected for processing (1)
  • hack/install.sh

Comment thread hack/install.sh
Comment on lines +67 to +82
echo "Building ${command}..."
go install -v $RACE_FLAG -ldflags "-X 'sigs.k8s.io/prow/pkg/version.Name=${command}' -X 'sigs.k8s.io/prow/pkg/version.Version=${version}'" "./cmd/${command}/..." &
pids+=($!)
done

# Wait for all parallel builds and collect failures
for pid in "${pids[@]}"; do
if ! wait "$pid"; then
failures+=("$pid")
fi
done

if [[ ${#failures[@]} -gt 0 ]]; then
echo "ERROR: ${#failures[@]} build(s) failed"
exit 1
fi
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Failed builds are not identified by name, making debugging harder.

When a build fails, the error message only reports the count of failures. In CI logs with interleaved output from parallel builds, developers won't easily know which binary failed.

Consider tracking command names alongside PIDs for actionable error messages.

Suggested improvement
+declare -A pid_to_cmd
+
 for dir in $( find ./cmd/ -mindepth 1 -maxdepth 1 -type d -not \( -name '*ipi-deprovison*' \) | sort ); do
     command="$( basename "${dir}" )"
 
     # If BUILD_IMAGES is set, only build listed binaries
     if [[ ${`#build_images_map`[@]} -gt 0 ]]; then
       if [[ -z "${build_images_map[${command}]:-}" ]]; then
         continue
       fi
     elif [[ -n "${skipped_images_map[${command}]:-}" ]]; then
       echo "Skipping install for ${command} (in SKIPPED_IMAGES)"
       continue
     fi
 
     echo "Building ${command}..."
     go install -v $RACE_FLAG -ldflags "-X 'sigs.k8s.io/prow/pkg/version.Name=${command}' -X 'sigs.k8s.io/prow/pkg/version.Version=${version}'" "./cmd/${command}/..." &
-    pids+=($!)
+    pid=$!
+    pids+=($pid)
+    pid_to_cmd[$pid]="${command}"
 done
 
 # Wait for all parallel builds and collect failures
 for pid in "${pids[@]}"; do
     if ! wait "$pid"; then
-        failures+=("$pid")
+        failures+=("${pid_to_cmd[$pid]}")
     fi
 done
 
 if [[ ${`#failures`[@]} -gt 0 ]]; then
-    echo "ERROR: ${`#failures`[@]} build(s) failed"
+    echo "ERROR: ${`#failures`[@]} build(s) failed: ${failures[*]}"
     exit 1
 fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@hack/install.sh` around lines 67 - 82, The script currently tracks only PIDs
(pids array) and counts failures (failures array) so failing builds aren't
named; change the launch loop to record the mapping of PID to command (e.g.,
declare -A pid_to_cmd and after starting each go install put
pid_to_cmd[$!]="$command"), then in the wait loop use that map to capture the
failed command name (retrieve pid_to_cmd[$pid]) and append the command name (not
just PID) to failures; finally, print the failing command names when reporting
errors. Ensure an associative array is declared before use and that you still
collect PIDs in pids for wait.

@Prucek Prucek force-pushed the build-optimization branch from 322a603 to cceccc7 Compare April 2, 2026 14:12
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Prucek Prucek force-pushed the build-optimization branch from cceccc7 to 459a2d6 Compare April 2, 2026 14:33
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Apr 2, 2026

@Prucek: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/images 459a2d6 link true /test images
ci/prow/breaking-changes 459a2d6 link false /test breaking-changes

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

approved Indicates a PR has been approved by an approver from all required OWNERS files. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants