Skip to content

Modifying build client to handle different build logics#5224

Draft
hector-vido wants to merge 1 commit into
openshift:mainfrom
hector-vido:buildclient-adjustment
Draft

Modifying build client to handle different build logics#5224
hector-vido wants to merge 1 commit into
openshift:mainfrom
hector-vido:buildclient-adjustment

Conversation

@hector-vido
Copy link
Copy Markdown
Contributor

@hector-vido hector-vido commented Jun 1, 2026

This is the first step to isolate image build logic inside buildClient , so it can handle different builds on different platforms like AWS, Shipwright, etc.

Summary

This PR introduces a build-type abstraction into ci-operator’s build client so the system can host multiple build-platform implementations. It isolates image build logic inside buildClient and wires configuration through to the client so ci-operator can choose platform-specific build behavior (current default: OpenShift).

What changed (practical effect)

  • Build client API: The BuildClient now exposes BuildType() and NewBuildClient requires an explicit buildType. The concrete buildClient stores the build type.
  • Configuration: ReleaseBuildConfiguration gains an optional build_type field (json:"build_type,omitempty"). The defaulting logic assigns "openshift" when no build_type is provided.
  • Build execution: The build orchestration in source.go was refactored so handleBuild performs retries and dispatches to platform-specific handlers (e.g., openshiftBuild). Unknown build types are treated as errors. openshiftBuild contains the existing OpenShift-specific create/wait/failure/logging flow.
  • Tests/defaults: Unit tests and defaults usage were updated to pass api.BuildTypeOpenshift and test helpers updated to implement BuildType().

Component impact

  • Affects ci-operator’s build step implementation (pkg/steps, pkg/api, pkg/defaults). Operators and job/config authors can now express a build_type in ReleaseBuildConfiguration; until additional implementations are added, behavior remains the same (OpenShift builds) but the codebase is prepared to support other platforms (AWS, Shipwright, etc.) without invasive changes.

Backwards compatibility and next steps

  • Backwards compatible: unspecified build_type continues to default to "openshift", so existing configs behave unchanged.
  • Next work: add platform-specific implementations and wiring (AWS, Shipwright, etc.) to take advantage of the new abstraction.

Notes for reviewers

  • API change: new config field and new constructor signature (NewBuildClient now requires buildType) — look for callers that must be updated.
  • High-level behavioral change: dispatch logic and retry/error handling moved into handleBuild/openshiftBuild; review failure/timeout semantics and metrics snapshots preserved in the OpenShift path.

@openshift-merge-bot
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

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Jun 1, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 1, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 1, 2026

📝 Walkthrough

Walkthrough

Adds a BuildType field and openshift constant to the release config, defaults BuildType to "openshift", requires a buildType argument when constructing BuildClient, extends BuildClient with BuildType(), and refactors build execution to dispatch by build type with an extracted openshift-specific build helper.

Changes

Build-type addition and build execution refactor

Layer / File(s) Summary
API: BuildType field and defaulting
pkg/api/types.go, pkg/api/config.go, pkg/defaults/defaults.go
Add BuildType to ReleaseBuildConfiguration, introduce BuildTypeOpenshift constant, default config.BuildType to BuildTypeOpenshift, and update FromConfig to pass the openshift build type to NewBuildClient.
BuildClient interface and constructor
pkg/steps/build_client.go
Add BuildType() string to BuildClient, store buildType on the concrete buildClient, and change NewBuildClient to accept and initialize the buildType parameter.
Build execution dispatch and openshift helper
pkg/steps/source.go
Refactor handleBuild to dispatch on buildClient.BuildType() and replace timeout-specific retry classification with wait.Interrupted(err) logic; extract openshiftBuild to perform create/wait/metrics/failure handling and best-effort log gathering.
Tests and fakes
pkg/defaults/defaults_test.go, pkg/steps/index_generator_test.go, pkg/steps/source_test.go
Update tests to construct NewBuildClient with api.BuildTypeOpenshift and add BuildType() string to fakeBuildClient test helper.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 13

❌ Failed checks (1 warning, 12 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Go Error Handling ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Test Coverage For New Features ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Stable And Deterministic Test Names ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Test Structure And Quality ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Microshift Test Compatibility ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Single Node Openshift (Sno) Test Compatibility ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Topology-Aware Scheduling Compatibility ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Ote Binary Stdout Contract ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Ipv6 And Disconnected Network Test Compatibility ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
No-Weak-Crypto ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Container-Privileges ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
No-Sensitive-Data-In-Logs ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: introducing build-type awareness to the BuildClient to support different build implementations.
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.

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

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

Warning

Review ran into problems

🔥 Problems

Linked repositories: Couldn't analyze openshift/ci-docs - clone failed: Clone operation failed: Stream initialization permanently failed: Received unknown message on Sandbox stream


Linked repositories: Couldn't analyze openshift/release-controller - clone failed: Clone operation failed: Stream initialization permanently failed: Received unknown message on Sandbox stream


Linked repositories: Couldn't analyze openshift/release - clone failed: Clone operation failed: Stream initialization permanently failed: Received unknown message on Sandbox stream


Linked repositories: Couldn't analyze openshift/ci-chat-bot - clone failed: Clone operation failed: Stream initialization permanently failed: Received unknown message on Sandbox stream


Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Jun 1, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hector-vido

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 Jun 1, 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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/steps/build_client.go`:
- Around line 16-19: The exported constant names are misspelled/inconsistent:
rename BuiltTypeOpenshift and BuilTypeAWSCodeBuild to BuildTypeOpenshift and
BuildTypeAWSCodeBuild respectively, update all usages (including the caller in
defaults.go and the Build() dispatch) to the new identifiers, and run
tests/compile to ensure no remaining references to the old names remain.
- Around line 41-51: The test failures come from calling NewBuildClient with the
old 6-arg signature; update each test call (e.g., in
pkg/defaults/defaults_test.go, pkg/steps/source_test.go,
pkg/steps/index_generator_test.go) to pass the new buildType as the second
argument to NewBuildClient and shift the remaining parameters right so the
restClient, nodeArchitectures, manifestToolDockerCfg, localRegistryDNS, and
metricsAgent match the new signature used in the NewBuildClient function.
🪄 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: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: a3d85046-4e20-4c0d-9b63-9f2391f2bb2c

📥 Commits

Reviewing files that changed from the base of the PR and between 8c13338 and 3579519.

📒 Files selected for processing (2)
  • pkg/defaults/defaults.go
  • pkg/steps/build_client.go

Comment thread pkg/steps/build_client.go Outdated
Comment thread pkg/steps/build_client.go
@hector-vido hector-vido force-pushed the buildclient-adjustment branch from 3579519 to 3d53579 Compare June 3, 2026 11:03
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

🧹 Nitpick comments (1)
pkg/api/types.go (1)

78-78: ⚡ Quick win

Add a doc comment for BuildType on ReleaseBuildConfiguration.

Line 78 introduces an exported API field without documenting purpose/allowed values/default behavior. Add a short field comment to keep config API self-describing.

As per coding guidelines: "**/*.go: Go documentation on Classes/Functions/Fields should be written properly".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/api/types.go` at line 78, Add a concise Go doc comment above the exported
BuildType field on the ReleaseBuildConfiguration struct explaining what the
field represents, the allowed values (e.g., "debug", "release", "optimized" or
whatever applies), and any default behavior when omitted; update the comment to
be a single-line field comment starting with BuildType so Go tooling picks it up
and keep phrasing brief and self-describing for API consumers.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/defaults/defaults.go`:
- Line 63: The code is hardcoding api.BuildTypeOpenshift when constructing the
build client; change the call to steps.NewBuildClient to pass the configured
build type from cfg (e.g., cfg.BuildType) instead of api.BuildTypeOpenshift,
ensuring the value you pass matches the expected parameter type for
steps.NewBuildClient (cast to api.BuildType if necessary) so alternate build
implementations configured at runtime are respected.

---

Nitpick comments:
In `@pkg/api/types.go`:
- Line 78: Add a concise Go doc comment above the exported BuildType field on
the ReleaseBuildConfiguration struct explaining what the field represents, the
allowed values (e.g., "debug", "release", "optimized" or whatever applies), and
any default behavior when omitted; update the comment to be a single-line field
comment starting with BuildType so Go tooling picks it up and keep phrasing
brief and self-describing for API consumers.
🪄 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: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 7067a433-9827-4b0c-9e30-c6cee8061db3

📥 Commits

Reviewing files that changed from the base of the PR and between 3579519 and 3d53579.

📒 Files selected for processing (5)
  • pkg/api/config.go
  • pkg/api/types.go
  • pkg/defaults/defaults.go
  • pkg/steps/build_client.go
  • pkg/steps/source.go

Comment thread pkg/defaults/defaults.go
@hector-vido hector-vido force-pushed the buildclient-adjustment branch from 3d53579 to af741f2 Compare June 3, 2026 11:19
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.

🧹 Nitpick comments (1)
pkg/api/types.go (1)

78-78: ⚡ Quick win

Document the exported BuildType field.

Please add a field comment describing supported values/default behavior for BuildType, since this is part of the user-facing config API.

Suggested diff
-	BuildType string `json:"build_type,omitempty"`
+	// BuildType selects the build implementation. Defaults to "openshift".
+	BuildType string `json:"build_type,omitempty"`

As per coding guidelines, "**/*.go: Go documentation on Classes/Functions/Fields should be written properly".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/api/types.go` at line 78, Add a Go doc comment for the exported BuildType
field on the relevant struct (BuildType string `json:"build_type,omitempty"`)
that describes the supported values (e.g., possible enum strings), the default
behavior when omitted, and any validation/semantic meaning; place the comment
immediately above the BuildType field so it appears in generated docs and
follows Go doc conventions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@pkg/api/types.go`:
- Line 78: Add a Go doc comment for the exported BuildType field on the relevant
struct (BuildType string `json:"build_type,omitempty"`) that describes the
supported values (e.g., possible enum strings), the default behavior when
omitted, and any validation/semantic meaning; place the comment immediately
above the BuildType field so it appears in generated docs and follows Go doc
conventions.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Enterprise

Run ID: 1d0f9413-0683-4e1f-a066-afe8035b0abf

📥 Commits

Reviewing files that changed from the base of the PR and between 3d53579 and af741f2.

📒 Files selected for processing (8)
  • pkg/api/config.go
  • pkg/api/types.go
  • pkg/defaults/defaults.go
  • pkg/defaults/defaults_test.go
  • pkg/steps/build_client.go
  • pkg/steps/index_generator_test.go
  • pkg/steps/source.go
  • pkg/steps/source_test.go

Comment thread pkg/steps/source.go
}

func handleBuild(ctx context.Context, client BuildClient, podClient kubernetes.PodClient, build buildapi.Build) error {
func handleBuild(ctx context.Context, buildClient BuildClient, podClient kubernetes.PodClient, build buildapi.Build) error {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

But this handles only openshift builds already. I don't see any point of check the type in this layer. You should do it before this and don't make any changes here at all.

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/work-in-progress Indicates that a PR should not merge because it is a work in progress.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants