Skip to content

MGMT-20398: Force status on bmh after install - #10606

Open
pastequo wants to merge 2 commits into
openshift:masterfrom
pastequo:fix/force-status-on-bmh-after-install
Open

MGMT-20398: Force status on bmh after install#10606
pastequo wants to merge 2 commits into
openshift:masterfrom
pastequo:fix/force-status-on-bmh-after-install

Conversation

@pastequo

@pastequo pastequo commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Note: I updated the BMO go mod dependency to have the new flag, which in turns required a new go-client. So I had to remove the go replace directives, which leads to extra large vendoring changes

If upgrading all that raise trouble, I should still be able to implement the fix without upgrading bmh mod, by hardcoding the annotation (probably)

List all the issues related to this PR

  • New Feature
  • Enhancement
  • Bug fix
  • Tests
  • Documentation
  • CI/CD

What environments does this code impact?

  • Automation (CI, tools, etc)
  • Cloud
  • Operator Managed Deployments
  • None

How was this code tested?

  • assisted-test-infra environment
  • dev-scripts environment
  • Reviewer's test appreciated
  • Waiting for CI to do a full test run
  • Manual (Elaborate on how it was tested)
  • No tests needed

Checklist

  • Title and description added to both, commit and PR.
  • Relevant issues have been associated (see CONTRIBUTING guide)
  • This change does not require a documentation update (docstring, docs, README, etc)
  • Does this change include unit-tests (note that code changes require unit-tests)

Reviewers Checklist

  • Are the title and description (in both PR and commit) meaningful and clear?
  • Is there a bug required (and linked) for this change?
  • Should this PR be backported?

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added automatic recovery for BareMetalHosts stuck during provisioning after installation completes.
    • Added a configuration toggle for this recovery, enabled by default.
    • Updated BareMetalHost resource capabilities and status fields.
  • Bug Fixes

    • Improved controller event processing and BareMetalHost status updates.
    • Improved handling when discovering provisioning service addresses.
  • Chores

    • Refreshed webhook handling, dependencies, and toolchain support.
    • Expanded test coverage for provisioning recovery and reconciliation scenarios.

@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: LGTM mode

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 10, 2026
@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 Jul 10, 2026
@openshift-ci-robot

openshift-ci-robot commented Jul 10, 2026

Copy link
Copy Markdown

@pastequo: This pull request references MGMT-20398 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "5.0.0" version, but no target version was set.

Details

In response to this:

List all the issues related to this PR

  • New Feature
  • Enhancement
  • Bug fix
  • Tests
  • Documentation
  • CI/CD

What environments does this code impact?

  • Automation (CI, tools, etc)
  • Cloud
  • Operator Managed Deployments
  • None

How was this code tested?

  • assisted-test-infra environment
  • dev-scripts environment
  • Reviewer's test appreciated
  • Waiting for CI to do a full test run
  • Manual (Elaborate on how it was tested)
  • No tests needed

Checklist

  • Title and description added to both, commit and PR.
  • Relevant issues have been associated (see CONTRIBUTING guide)
  • This change does not require a documentation update (docstring, docs, README, etc)
  • Does this change include unit-tests (note that code changes require unit-tests)

Reviewers Checklist

  • Are the title and description (in both PR and commit) meaningful and clear?
  • Is there a bug required (and linked) for this change?
  • Should this PR be backported?

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci

openshift-ci Bot commented Jul 10, 2026

Copy link
Copy Markdown

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 size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jul 10, 2026
@openshift-ci

openshift-ci Bot commented Jul 10, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: pastequo

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 Jul 10, 2026
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

The change adds configurable, phased stale-provisioning remediation for BareMetalHosts. It also updates dependencies, admission decoder types, controller-runtime wiring, RBAC, mocks, utility behavior, CRD schemas, and compatibility tests.

Changes

Stale provisioning remediation

Layer / File(s) Summary
Remediation flow and wiring
cmd/main.go, internal/controller/controllers/bmh_agent_controller.go, config/rbac/role.yaml, deploy/olm-catalog/...
Adds configuration, stale detection, phased detachment, status correction, cleanup, and status-subresource permissions.
Remediation validation
internal/controller/controllers/bmh_agent_controller_test.go
Tests detection, eligibility, interruption cleanup, detachment waiting, completion, external resolution, and pipeline ordering.

Platform compatibility updates

Layer / File(s) Summary
Dependency and CRD refresh
go.mod, hack/crds/metal3/...
Updates Go dependencies and regenerates the BareMetalHost CRD schemas.
API and controller wiring
cmd/webadmission/main.go, pkg/webhooks/..., internal/controller/controllers/...
Uses admission decoder interfaces, channel source constructors, explicit controller naming, updated TLS setup, and revised Ironic IP handling.
Mocks and test maintenance
internal/controller/controllers/mock_*, internal/spoke_k8s_client/..., internal/oc/release_test.go, internal/controller/controllers/*_test.go
Adds Apply mocks and updates assertions, fixtures, and deprecation suppressions.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant BMACReconciler
  participant BareMetalHost
  participant BMO
  BMACReconciler->>BareMetalHost: Set stale remediation marker and force detach
  BMO->>BareMetalHost: Report operational detachment
  BMACReconciler->>BareMetalHost: Patch provisioning state to StateProvisioned
  BMACReconciler->>BareMetalHost: Remove forced-detach annotation
  BMO->>BareMetalHost: Clear operational detachment
  BMACReconciler->>BareMetalHost: Remove stale remediation marker
Loading

Suggested labels: ok-to-test

Suggested reviewers: yoavsc0302, rccrdpccl


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 3 warnings)

Check name Status Explanation Resolution
No-Weak-Crypto ❌ Error The PR adds an active 3DES mapping in vendor/.../pkg/crypto/crypto.go; BMO converts this map into --tls-cipher-suites arguments. Remove the ECDHE-RSA-DES-CBC3-SHA to TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA mapping, or reject 3DES before generating BMO TLS arguments.
Description check ⚠️ Warning The description omits the issue summary, motivation, dependencies, and test details, and incorrectly states that no tests are needed despite extensive unit-test changes. Add the MGMT-20398 summary, motivation, dependency impact, and testing details; select Bug fix and Tests and remove the incorrect no-tests-needed claim.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Test Structure And Quality ⚠️ Warning The added Ginkgo suite has about 102 assertions, including error checks, without meaningful failure messages; it has no Eventually/Consistently timeout issue. Add diagnostic messages to assertions, especially resource-operation errors and key state checks, such as the operation and object name being validated.
✅ Passed checks (11 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: forcing BareMetalHost status after installation.
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 feature commit adds 38 Ginkgo titles, all as static string literals; none contains generated names, timestamps, UUIDs, nodes, namespaces, IPs, or other run-dependent values.
Microshift Test Compatibility ✅ Passed No new Ginkgo e2e tests were added; the changed Ginkgo cases are controller unit tests using fakeclient in internal/controller/controllers.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The only new Ginkgo tests are controller unit tests using fake clients and mocks; no e2e tests or multi-node/SNO assumptions were added.
Topology-Aware Scheduling Compatibility ✅ Passed Changed manifests only update RBAC/CRD data; controller changes add BMH status remediation and watch wiring, with no affinity, spread, nodeSelector, toleration, replica, PDB, or topology constraints.
Ote Binary Stdout Contract ✅ Passed No OTE binary or openshift-tests target exists; the PR's entry-point changes add no process-level stdout writes or suite setup output.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The PR adds Ginkgo controller unit tests using fake clients, not e2e tests; added lines contain no IPv4 literals or network calls, and example.com is only fixture data.
Container-Privileges ✅ Passed The PR adds no privileged, host namespace, SYS_ADMIN, root, or allowPrivilegeEscalation settings; the existing privileged Pod entry is unchanged in deploy/podman/pod_tls.yml.
No-Sensitive-Data-In-Logs ✅ Passed New remediation logs contain only provisioning/operational state and the BMO detached marker; the marker schema has only DeleteAction and Force, with no credentials, tokens, PII, or customer data.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Trivy (0.72.0)

Trivy execution failed: 2026-08-07T13:53:33Z FATAL Fatal error run error: fs scan error: scan error: scan failed: failed analysis: post analysis error: post analysis error: ansible scan error: scan config error: find projects: walk dir: range error: stat .coderabbit-opengrep-fallback.399fe6a3-728d-469e-8312-4175b136b22c.yml: no such file or directory


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

@pastequo
pastequo force-pushed the fix/force-status-on-bmh-after-install branch from 5125872 to 3c35750 Compare July 16, 2026 09:55
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
Validation Failed: {"resource":"IssueComment","code":"custom","field":"body","message":"body is too long (maximum is 65536 characters)"} - https://docs.github.com/rest/issues/comments#update-an-issue-comment

@pastequo

Copy link
Copy Markdown
Contributor Author

/retest

@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.72727% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 44.66%. Comparing base (f46558c) to head (4c01cfe).
⚠️ Report is 46 commits behind head on master.

Files with missing lines Patch % Lines
cmd/main.go 0.00% 10 Missing ⚠️
...nal/controller/controllers/bmh_agent_controller.go 88.70% 4 Missing and 3 partials ⚠️
cmd/operator/main.go 0.00% 2 Missing ⚠️
cmd/webadmission/main.go 0.00% 1 Missing ⚠️
...nternal/controller/controllers/agent_controller.go 0.00% 1 Missing ⚠️
...al/controller/controllers/agentlabel_controller.go 0.00% 1 Missing ⚠️
...oller/controllers/clusterdeployments_controller.go 0.00% 1 Missing ⚠️
...rnal/controller/controllers/infraenv_controller.go 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10606      +/-   ##
==========================================
+ Coverage   44.47%   44.66%   +0.18%     
==========================================
  Files         423      426       +3     
  Lines       73355    73854     +499     
==========================================
+ Hits        32626    32984     +358     
- Misses      37810    37915     +105     
- Partials     2919     2955      +36     
Files with missing lines Coverage Δ
...oller/controllers/agentserviceconfig_controller.go 82.56% <100.00%> (-1.28%) ⬇️
internal/controller/controllers/bmo_utils.go 75.00% <100.00%> (+4.16%) ⬆️
...rollers/hypershiftagentserviceconfig_controller.go 76.63% <ø> (ø)
...hooks/agentinstall/v1beta1/agent_admission_hook.go 87.58% <100.00%> (ø)
...all/v1beta1/agent_classification_admission_hook.go 79.54% <100.00%> (ø)
...ks/agentinstall/v1beta1/infraenv_admission_hook.go 81.86% <100.00%> (ø)
...nsion/v1beta1/agentclusterinstall_mutating_hook.go 59.22% <100.00%> (ø)
...ion/v1beta1/agentclusterinstall_validation_hook.go 87.65% <100.00%> (ø)
cmd/webadmission/main.go 0.00% <0.00%> (ø)
...nternal/controller/controllers/agent_controller.go 76.95% <0.00%> (-0.15%) ⬇️
... and 6 more

... and 27 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@pastequo
pastequo force-pushed the fix/force-status-on-bmh-after-install branch from 3c35750 to fb02b31 Compare July 20, 2026 16:39
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
Validation Failed: {"resource":"IssueComment","code":"custom","field":"body","message":"body is too long (maximum is 65536 characters)"} - https://docs.github.com/rest/issues/comments#update-an-issue-comment

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🤖 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 `@go.mod`:
- Line 41: Update the go.mod dependency pins for github.com/jackc/pgx/v5,
github.com/moby/moby, and github.com/containerd/containerd to releases that
contain fixes for their known advisories; if any vulnerable version must remain,
document why its affected code paths are unreachable.

In `@internal/controller/controllers/bmh_agent_controller_test.go`:
- Around line 4509-5038: Update the test fixtures in the
reconcileBMHStaleProvisioning specs to stop constructing
DetachedAnnotationArguments with the unverified Force field. Use only fields
supported by the pinned bmh_v1alpha1 type while preserving the serialized
force-detach annotation expected by the phase and cleanup tests.

In `@internal/controller/controllers/bmh_agent_controller.go`:
- Around line 2139-2241: Update reconcileBMHStaleProvisioning to bound the Phase
2, Phase 4, and Phase 5 wait states with a persistent timeout or circuit
breaker, so remediation cannot remain blocked indefinitely while BMO fails to
detach or correct status. Track elapsed waiting time across reconciles using the
existing remediation state, and when the threshold is exceeded, stop waiting,
clean up or transition the annotations consistently, and emit an
operator-visible metric, event, or alert identifying the stalled host and phase.
- Around line 2223-2237: The Phase 3 correction in the force-detach handling
must update the live BareMetalHost status rather than only writing
BMH_STATUS_ANNOTATION. Modify the flow around the correctedStatus assignment to
persist the corrected StateProvisioned status through the controller’s status
update mechanism, while retaining the annotation cleanup and stale-provisioning
marker behavior.

In `@internal/controller/controllers/bmo_utils.go`:
- Around line 97-100: Update the error branch in the Ironic IP validation flow
to emit the constructed error, not just attach it to the logger. In the block
checking len(ironicIPs) and ironicIPs[0], make the r.log.WithError(err) chain
invoke the appropriate terminal logging method before returning, while
preserving the existing error and return values.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

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

Comment thread go.mod
Comment thread internal/controller/controllers/bmh_agent_controller_test.go
Comment thread internal/controller/controllers/bmh_agent_controller.go
Comment thread internal/controller/controllers/bmh_agent_controller.go Outdated
Comment thread internal/controller/controllers/bmo_utils.go
Comment thread internal/controller/controllers/bmh_agent_controller.go Outdated
Comment thread internal/controller/controllers/bmh_agent_controller.go Outdated
@pastequo
pastequo force-pushed the fix/force-status-on-bmh-after-install branch from fb02b31 to fbacfb9 Compare July 27, 2026 13:42
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
Validation Failed: {"resource":"IssueComment","code":"custom","field":"body","message":"body is too long (maximum is 65536 characters)"} - https://docs.github.com/rest/issues/comments#update-an-issue-comment

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
go.mod (1)

41-47: 🔒 Security & Privacy | 🔴 Critical

Previously reported vulnerable dependency pins remain.

github.com/jackc/pgx/v5 v5.6.0 and github.com/moby/moby v27.2.1+incompatible still match the advisories reported in the previous review. Upgrade to fixed releases before merging.

#!/usr/bin/env bash
set -euo pipefail
osv-scanner scan source -r .
go mod verify
go list -m -json github.com/jackc/pgx/v5 github.com/moby/moby
🤖 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 `@go.mod` around lines 41 - 47, Update the go.mod dependency pins for
github.com/jackc/pgx/v5 and github.com/moby/moby to releases that contain fixes
for their reported advisories, then synchronize go.sum and verify the resolved
module versions.

Sources: Path instructions, Linters/SAST tools

🤖 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 `@go.mod`:
- Around line 241-246: Update the module dependency for google.golang.org/grpc
to version v1.82.1 or newer, ensuring the resolved module graph no longer
retains v1.79.3 while preserving compatible indirect OpenTelemetry dependencies.

---

Duplicate comments:
In `@go.mod`:
- Around line 41-47: Update the go.mod dependency pins for
github.com/jackc/pgx/v5 and github.com/moby/moby to releases that contain fixes
for their reported advisories, then synchronize go.sum and verify the resolved
module versions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

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

Comment thread go.mod
@pastequo
pastequo marked this pull request as ready for review July 27, 2026 15:27
@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 27, 2026
@openshift-ci
openshift-ci Bot requested review from rccrdpccl and yoavsc0302 July 27, 2026 15:31
@pastequo
pastequo force-pushed the fix/force-status-on-bmh-after-install branch from fbacfb9 to b6c2c51 Compare July 28, 2026 14:58
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
Validation Failed: {"resource":"IssueComment","code":"custom","field":"body","message":"body is too long (maximum is 65536 characters)"} - https://docs.github.com/rest/issues/comments#update-an-issue-comment

@pastequo
pastequo force-pushed the fix/force-status-on-bmh-after-install branch from b6c2c51 to a87aaff Compare July 31, 2026 08:06
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
Validation Failed: {"resource":"IssueComment","code":"custom","field":"body","message":"body is too long (maximum is 65536 characters)"} - https://docs.github.com/rest/issues/comments#update-an-issue-comment

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (4)
internal/controller/controllers/bmh_agent_controller_test.go (4)

4839-4846: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Extract the shared ClusterDeployment fixture.

The same test-cd ClusterDeployment plus agent.Spec.ClusterDeploymentName assignment appears in four places: the prechecks, Phase 2, Phase 3, and pipeline ordering BeforeEach blocks, and in both setupCD closures. Move it into one helper at the suite level.

🤖 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 `@internal/controller/controllers/bmh_agent_controller_test.go` around lines
4839 - 4846, Extract the repeated test-cd ClusterDeployment creation and
agent.Spec.ClusterDeploymentName assignment into a single suite-level helper.
Update the prechecks, Phase 2, Phase 3, pipeline ordering BeforeEach blocks, and
both setupCD closures to call that helper while preserving the existing test
setup behavior.

4999-5013: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert the expected Reconcile error instead of discarding both return values.

Line 5007 discards the ctrl.Result and the error. The test then cannot distinguish the acknowledged MCS-certificate failure from a new failure earlier in the pipeline. If Reconcile begins to fail before handlePauseAndDetachBMHAnnotations, the annotation assertion fails without indicating the cause.

Capture the error and assert what the test expects.

♻️ Suggested change
-		// The Reconcile may error in later stages (e.g. MCS cert lookup), but
-		// the deferred BMH patch ensures annotations are persisted regardless.
-		bmhr.Reconcile(ctx, newBMHRequest(host)) //nolint:errcheck
+		// Reconcile fails in a later stage (MCS cert lookup), but the deferred
+		// BMH patch persists the annotations regardless.
+		_, err := bmhr.Reconcile(ctx, newBMHRequest(host))
+		Expect(err).To(HaveOccurred())
🤖 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 `@internal/controller/controllers/bmh_agent_controller_test.go` around lines
4999 - 5013, Update the Reconcile invocation in the “normal flow resumes after
remediation completes” test to capture both the ctrl.Result and error, then
assert the expected MCS-certificate lookup error before checking the persisted
annotation. Do not discard either return value, so failures occurring before
handlePauseAndDetachBMHAnnotations are reported directly.

4795-4830: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover the Status.Provisioning.CustomDeploy copy in Phase 3.

Phase 3 also copies bmh.Spec.CustomDeploy into Status.Provisioning.CustomDeploy. This fixture leaves Spec.CustomDeploy nil, so that copy is never exercised. Set Spec.CustomDeploy in the fixture and assert the persisted status field.

♻️ Suggested addition
 		host.Status.Provisioning.State = bmh_v1alpha1.StateProvisioning
 		host.Status.OperationalStatus = bmh_v1alpha1.OperationalStatusDetached
+		host.Spec.CustomDeploy = &bmh_v1alpha1.CustomDeploy{Method: ASSISTED_DEPLOY_METHOD}
 			Expect(persisted.Status.Provisioning.State).To(Equal(bmh_v1alpha1.StateProvisioned))
+			Expect(persisted.Status.Provisioning.CustomDeploy).To(Equal(host.Spec.CustomDeploy))
🤖 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 `@internal/controller/controllers/bmh_agent_controller_test.go` around lines
4795 - 4830, Update the Phase 3 fixture in the BeforeEach setup to populate
host.Spec.CustomDeploy with a representative value, then extend the “patches
live status to provisioned directly” test to assert the persisted
Status.Provisioning.CustomDeploy matches it. Use the existing host, persisted,
and reconcileBMHStaleProvisioning symbols without changing unrelated assertions.

4960-4967: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

Remove the redundant BootMACAddress mutation.

newBMH already sets the same value, and newBMHRequest uses only the object key. Remove the assignment after Create.

🤖 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 `@internal/controller/controllers/bmh_agent_controller_test.go` around lines
4960 - 4967, Remove the redundant host.Spec.BootMACAddress assignment to macStr
after c.Create in this test; rely on newBMH’s existing value while preserving
the object creation and subsequent test flow.
🤖 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 `@go.mod`:
- Around line 263-274: Restore the root go.mod replacement for
github.com/metal3-io/baremetal-operator, or update it to a resolvable compatible
version required by cluster-baremetal-operator. Then regenerate the vendor
directory and rerun the module checks to ensure dependency resolution succeeds.

In `@internal/controller/controllers/clusterdeployments_controller_test.go`:
- Line 3429: The test assertion only checks result.Requeue but ignores the
RequeueAfter field, which can also schedule reconciliation. Replace the
Expect(result.Requeue).To(BeFalse()) assertion with
Expect(result).To(Equal(ctrl.Result{})) to validate that the complete
ctrl.Result object matches an empty result and properly stops reconciliation.

---

Nitpick comments:
In `@internal/controller/controllers/bmh_agent_controller_test.go`:
- Around line 4839-4846: Extract the repeated test-cd ClusterDeployment creation
and agent.Spec.ClusterDeploymentName assignment into a single suite-level
helper. Update the prechecks, Phase 2, Phase 3, pipeline ordering BeforeEach
blocks, and both setupCD closures to call that helper while preserving the
existing test setup behavior.
- Around line 4999-5013: Update the Reconcile invocation in the “normal flow
resumes after remediation completes” test to capture both the ctrl.Result and
error, then assert the expected MCS-certificate lookup error before checking the
persisted annotation. Do not discard either return value, so failures occurring
before handlePauseAndDetachBMHAnnotations are reported directly.
- Around line 4795-4830: Update the Phase 3 fixture in the BeforeEach setup to
populate host.Spec.CustomDeploy with a representative value, then extend the
“patches live status to provisioned directly” test to assert the persisted
Status.Provisioning.CustomDeploy matches it. Use the existing host, persisted,
and reconcileBMHStaleProvisioning symbols without changing unrelated assertions.
- Around line 4960-4967: Remove the redundant host.Spec.BootMACAddress
assignment to macStr after c.Create in this test; rely on newBMH’s existing
value while preserving the object creation and subsequent test flow.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

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

Comment thread go.mod
@pastequo

pastequo commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

/retest

@pastequo
pastequo force-pushed the fix/force-status-on-bmh-after-install branch from a87aaff to 4c01cfe Compare August 7, 2026 13:52
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Caution

CodeRabbit couldn't update its existing comment. The review summary may be out of date.

Error details
Validation Failed: {"resource":"IssueComment","code":"custom","field":"body","message":"body is too long (maximum is 65536 characters)"} - https://docs.github.com/rest/issues/comments#update-an-issue-comment

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 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 `@go.mod`:
- Around line 241-246: Update the dependency selecting google.golang.org/grpc so
the module graph resolves to a non-vulnerable fixed version instead of v1.79.3,
then regenerate go.mod/go.sum and vendor metadata to reflect the resolved
version. Preserve the existing OpenTelemetry dependency updates.
- Line 41: Upgrade the github.com/jackc/pgx/v5 dependency from v5.6.0 to a
fixed, non-vulnerable release, then regenerate the related dependency metadata
so go.mod and go.sum remain consistent.
- Line 47: Update the github.com/moby/moby dependency from v27.2.1+incompatible
to a non-vulnerable compatible release when it is used by production or
image-management code; otherwise isolate it from the production dependency graph
as test-only and document that boundary.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

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

Comment thread go.mod
github.com/hashicorp/go-version v1.7.0
github.com/iancoleman/strcase v0.2.0
github.com/itchyny/gojq v0.12.8
github.com/jackc/pgx/v5 v5.6.0

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 | 🔴 Critical

Upgrade github.com/jackc/pgx/v5 before merge.

The v5.6.0 pin at Line 41 remains vulnerable. OSV Scanner reports critical SQL-injection and memory-safety advisories. pkg/db/db.go imports this module, so the dependency is used on a production path. Upgrade to a fixed release and regenerate dependency metadata. This repeats the existing review finding.

🧰 Tools
🪛 OSV Scanner (2.4.0)

[CRITICAL] 41-41: github.com/jackc/pgx/v5 5.6.0: CVE-2026-33815 in github.com/jackc/pgx

(GO-2026-4771)


[CRITICAL] 41-41: github.com/jackc/pgx/v5 5.6.0: CVE-2026-33816 in github.com/jackc/pgx

(GO-2026-4772)


[CRITICAL] 41-41: github.com/jackc/pgx/v5 5.6.0: SQL Injection via placeholder confusion with dollar quoted string literals in github.com/jackc/pgx

(GO-2026-5004)


[CRITICAL] 41-41: github.com/jackc/pgx/v5 5.6.0: Memory-safety vulnerability in github.com/jackc/pgx/v5.

(GHSA-9jj7-4m8r-rfcm)


[CRITICAL] 41-41: github.com/jackc/pgx/v5 5.6.0: pgx: SQL Injection via placeholder confusion with dollar quoted string literals

(GHSA-j88v-2chj-qfwx)


[CRITICAL] 41-41: github.com/jackc/pgx/v5 5.6.0: pgx contains memory-safety vulnerability

(GHSA-xgrm-4fwx-7qm8)

🤖 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 `@go.mod` at line 41, Upgrade the github.com/jackc/pgx/v5 dependency from
v5.6.0 to a fixed, non-vulnerable release, then regenerate the related
dependency metadata so go.mod and go.sum remain consistent.

Source: Linters/SAST tools

Comment thread go.mod
github.com/krishicks/yaml-patch v0.0.10
github.com/metal3-io/baremetal-operator/apis v0.2.0
github.com/metal3-io/baremetal-operator/apis v0.13.1
github.com/moby/moby v27.2.1+incompatible

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 | 🟠 Major

Upgrade or isolate github.com/moby/moby.

The v27.2.1+incompatible pin at Line 47 remains affected by high-severity Docker/Moby advisories. Upgrade it if production or image-management code loads the affected packages. If this dependency is test-only, keep it outside the production dependency graph and document that boundary. This repeats the existing review finding.

🧰 Tools
🪛 OSV Scanner (2.4.0)

[HIGH] 47-47: github.com/moby/moby 27.2.1+incompatible: Moby has an Off-by-one error in its plugin privilege validation in github.com/docker/docker

(GO-2026-4883)


[HIGH] 47-47: github.com/moby/moby 27.2.1+incompatible: Moby has AuthZ plugin bypass when provided oversized request bodies in github.com/docker/docker

(GO-2026-4887)


[HIGH] 47-47: github.com/moby/moby 27.2.1+incompatible: Race condition in 'docker cp' in github.com/docker/docker allows bind mount redirection

(GO-2026-5617)


[HIGH] 47-47: github.com/moby/moby 27.2.1+incompatible: Docker: Race condition in docker cp allows creation of arbitrary empty files on the host via symlink swap in github.com/docker/docker

(GO-2026-5668)


[HIGH] 47-47: github.com/moby/moby 27.2.1+incompatible: Docker: 'PUT /containers/{id}/archive' executes container binary on the host in github.com/docker/docker

(GO-2026-5746)


[HIGH] 47-47: github.com/moby/moby 27.2.1+incompatible: Moby has an Off-by-one error in its plugin privilege validation

(GHSA-pxq6-2prw-chj9)


[HIGH] 47-47: github.com/moby/moby 27.2.1+incompatible: Docker: Race condition in docker cp allows bind mount redirection to host path

(GHSA-rg2x-37c3-w2rh)


[HIGH] 47-47: github.com/moby/moby 27.2.1+incompatible: Docker: Race condition in docker cp allows creation of arbitrary empty files on the host via symlink swap

(GHSA-vp62-88p7-qqf5)


[HIGH] 47-47: github.com/moby/moby 27.2.1+incompatible: Moby has AuthZ plugin bypass when provided oversized request bodies

(GHSA-x744-4wpc-v9h2)


[HIGH] 47-47: github.com/moby/moby 27.2.1+incompatible: Docker: PUT /containers/{id}/archive executes container binary on the host

(GHSA-x86f-5xw2-fm2r)

🤖 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 `@go.mod` at line 47, Update the github.com/moby/moby dependency from
v27.2.1+incompatible to a non-vulnerable compatible release when it is used by
production or image-management code; otherwise isolate it from the production
dependency graph as test-only and document that boundary.

Source: Linters/SAST tools

Comment thread go.mod
Comment on lines +241 to 246
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.60.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0 // indirect
go.opentelemetry.io/otel v1.43.0 // indirect
go.opentelemetry.io/otel/metric v1.43.0 // indirect
go.opentelemetry.io/otel/sdk v1.43.0 // indirect
go.opentelemetry.io/otel/trace v1.43.0 // indirect

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 | 🟠 Major

Resolve google.golang.org/grpc to a fixed version.

The dependency updates at Lines 241-246 still leave google.golang.org/grpc v1.79.3 in the module graph. OSV Scanner reports vulnerabilities in the xDS RBAC and HTTP/2 implementations. Upgrade the dependency that selects gRPC, then regenerate vendor metadata. This repeats the existing review finding.

🧰 Tools
🪛 OSV Scanner (2.4.0)

[HIGH] 241-241: google.golang.org/grpc 1.79.3: Vulnerabilities in the xDS RBAC authorization engine and the HTTP/2 transport server implementation in google.golang.org/grpc

(GO-2026-6061)


[HIGH] 241-241: google.golang.org/grpc 1.79.3: gRPC-Go: xDS RBAC and HTTP/2 Vulnerabilities

(GHSA-hrxh-6v49-42gf)

🤖 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 `@go.mod` around lines 241 - 246, Update the dependency selecting
google.golang.org/grpc so the module graph resolves to a non-vulnerable fixed
version instead of v1.79.3, then regenerate go.mod/go.sum and vendor metadata to
reflect the resolved version. Preserve the existing OpenTelemetry dependency
updates.

Source: Linters/SAST tools

@openshift-ci

openshift-ci Bot commented Aug 7, 2026

Copy link
Copy Markdown

@pastequo: 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/edge-e2e-ai-operator-disconnected-capi 4c01cfe link true /test edge-e2e-ai-operator-disconnected-capi
ci/prow/edge-subsystem-kubeapi-aws 4c01cfe link true /test edge-subsystem-kubeapi-aws
ci/prow/edge-e2e-ai-operator-ztp-capi 4c01cfe link true /test edge-e2e-ai-operator-ztp-capi
ci/prow/edge-e2e-ai-operator-ztp 4c01cfe link true /test edge-e2e-ai-operator-ztp

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. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants