Skip to content

OCPBUGS-85498: BareMetal skew e2e fails patching provisioning CR after CBO webhook fix#6031

Open
djoshy wants to merge 1 commit into
openshift:mainfrom
djoshy:fix-bm-test
Open

OCPBUGS-85498: BareMetal skew e2e fails patching provisioning CR after CBO webhook fix#6031
djoshy wants to merge 1 commit into
openshift:mainfrom
djoshy:fix-bm-test

Conversation

@djoshy
Copy link
Copy Markdown
Contributor

@djoshy djoshy commented May 12, 2026

- What I did
The Verify BareMetal defaults to None mode and flips to Manual on legacy provisioning path test began failing after cluster-baremetal-operator PR #587 (merged May 4, 2026) fixed the vprovisioning.kb.io validating webhook server. Prior to that fix, a missing WithValidator(r) call meant no webhook handlers were ever registered; combined with failurePolicy: Ignore, all patch requests to the provisioning CR silently passed. The test was added in 9971d2f under those conditions.

After the webhook fix, patching provisioningOSDownloadURL alone is rejected on machine-os-images clusters (4.10+). We need to our patch request so it passes the webhook’s validation, which requires certain values to be read back and set.

- How to verify it
The baremetal e2es should now begin to pass, no additional QE is necessary.

Summary by CodeRabbit

  • Tests
    • Enhanced test coverage for BareMetal provisioning scenarios with legacy configurations
    • Improved validation of network field handling during provisioning mode transitions
    • Strengthened test infrastructure for enforcement mode verification

@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 jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels May 12, 2026
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

@djoshy: This pull request references Jira Issue OCPBUGS-85498, which is invalid:

  • expected the bug to target the "5.0.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

- What I did
The Verify BareMetal defaults to None mode and flips to Manual on legacy provisioning path test began failing after cluster-baremetal-operator PR #587 (merged May 4, 2026) fixed the vprovisioning.kb.io validating webhook server. Prior to that fix, a missing WithValidator(r) call meant no webhook handlers were ever registered; combined with failurePolicy: Ignore, all patch requests to the provisioning CR silently passed. The test was added in 9971d2f under those conditions.

After the webhook fix, patching provisioningOSDownloadURL alone is rejected on machine-os-images clusters (4.10+). We need to our patch request so it passes the webhook’s validation, which requires certain values to be read back and set.

- How to verify it
The baremetal e2es should now begin to pass, no additional QE is necessary.

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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

Walkthrough

This PR updates a single test case in the BareMetal skew enforcement test suite. The legacy qcow2 simulation now reads provisioning network fields from the CR, constructs a JSON patch that includes those fields alongside a legacy download URL, and restores them during cleanup.

Changes

BareMetal Legacy Provisioning Patch Test

Layer / File(s) Summary
Legacy provisioning network patch construction and cleanup
test/extended-priv/mco_bootimages_skew.go
Imports fmt and strings to support field parsing and JSON patch generation. The legacy qcow2 simulation reads provisioning network, IP, CIDR, and DHCP range from the CR, constructs a patch body via fmt.Sprintf that includes those fields plus provisioningOSDownloadURL, defers full restoration of those fields and clears the legacy URL, then verifies skew enforcement mode transitions from None to Manual.

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 11 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Test Structure And Quality ⚠️ Warning Line 276-277 directly indexes split result without length validation. Panics if provisioning fields are missing/empty with no diagnostic context, violating assertion quality requirements. Add length check before indexing: o.Expect(parts).To(o.HaveLen(4)) to validate output format and provide clear error messages if provisioning CR structure is unexpected.
✅ Passed checks (11 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: fixing a BareMetal e2e test that fails when patching the provisioning CR after a webhook fix, directly matching the changeset modifications.
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 All test titles use only static hardcoded strings. No dynamic information, generated identifiers, timestamps, or varying values present in test names.
Microshift Test Compatibility ✅ Passed This PR does not add new Ginkgo tests, only modifies an existing test's body. The custom check applies only to new test additions, not modifications to existing tests.
Single Node Openshift (Sno) Test Compatibility ✅ Passed All new Ginkgo tests in the added test file are protected from SNO via exutil.SkipOnSingleNodeTopology(oc) call in BeforeEach, which skips the entire test suite on single-node clusters.
Topology-Aware Scheduling Compatibility ✅ Passed PR modifies only test code. Check applies only to deployment manifests, operator code, or controllers.
Ote Binary Stdout Contract ✅ Passed No OTE stdout contract violations. File uses only fmt.Sprintf() (returns strings, not stdout) within test cases. No fmt.Print*/printf calls or process-level code that could corrupt JSON output.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed Tests read network fields dynamically from cluster resources (IPv4/IPv6 compatible). No hardcoded IPv4 addresses. No external connectivity or image pulls.

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

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

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

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 12, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: djoshy

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 12, 2026
@djoshy
Copy link
Copy Markdown
Contributor Author

djoshy commented May 12, 2026

/payload-job periodic-ci-openshift-machine-config-operator-release-5.0-periodics-e2e-metal-ipi-ovn-ipv6-mco-disruptive-1of2

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 12, 2026

@djoshy: trigger 1 job(s) for the /payload-(with-prs|job|aggregate|job-with-prs|aggregate-with-prs) command

  • periodic-ci-openshift-machine-config-operator-release-5.0-periodics-e2e-metal-ipi-ovn-ipv6-mco-disruptive-1of2

See details on https://pr-payload-tests.ci.openshift.org/runs/ci/601c4090-4e3a-11f1-925e-03564194e031-0

@djoshy
Copy link
Copy Markdown
Contributor Author

djoshy commented May 12, 2026

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels May 12, 2026
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

@djoshy: This pull request references Jira Issue OCPBUGS-85498, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state New, which is one of the valid states (NEW, ASSIGNED, POST)
Details

In response to this:

/jira refresh

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-robot
Copy link
Copy Markdown
Contributor

@djoshy: This pull request references Jira Issue OCPBUGS-85498, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)
Details

In response to this:

- What I did
The Verify BareMetal defaults to None mode and flips to Manual on legacy provisioning path test began failing after cluster-baremetal-operator PR #587 (merged May 4, 2026) fixed the vprovisioning.kb.io validating webhook server. Prior to that fix, a missing WithValidator(r) call meant no webhook handlers were ever registered; combined with failurePolicy: Ignore, all patch requests to the provisioning CR silently passed. The test was added in 9971d2f under those conditions.

After the webhook fix, patching provisioningOSDownloadURL alone is rejected on machine-os-images clusters (4.10+). We need to our patch request so it passes the webhook’s validation, which requires certain values to be read back and set.

- How to verify it
The baremetal e2es should now begin to pass, no additional QE is necessary.

Summary by CodeRabbit

  • Tests
  • Enhanced test coverage for BareMetal provisioning scenarios with legacy configurations
  • Improved validation of network field handling during provisioning mode transitions
  • Strengthened test infrastructure for enforcement mode verification

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.

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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/extended-priv/mco_bootimages_skew.go`:
- Around line 276-277: The code immediately indexes parts[0..3] after parts :=
strings.SplitN(fields, "\n", 4) which can panic if the split produced fewer than
4 elements; add an explicit length assertion before indexing (e.g., use
o.Expect(parts).To(o.HaveLen(4)) with a clear message) so the test fails with a
helpful diagnostic instead of an index-out-of-range panic; place this check
right after the SplitN call in the same function where originalNetwork,
originalIP, originalCIDR, originalDHCP are assigned.
🪄 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: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: c8bc30a4-8bd1-4d36-9192-4f378bc5ba98

📥 Commits

Reviewing files that changed from the base of the PR and between 99cb8a4 and f648c42.

📒 Files selected for processing (1)
  • test/extended-priv/mco_bootimages_skew.go

Comment on lines +276 to +277
parts := strings.SplitN(fields, "\n", 4)
originalNetwork, originalIP, originalCIDR, originalDHCP := parts[0], parts[1], parts[2], parts[3]
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 | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify parsing/indexing pattern around provisioning field extraction.
rg -n -C3 'SplitN\(|parts\[[0-9]+\]' test/extended-priv/mco_bootimages_skew.go

Repository: openshift/machine-config-operator

Length of output: 2091


🏁 Script executed:

cat test/extended-priv/mco_bootimages_skew.go | head -300 | tail -100

Repository: openshift/machine-config-operator

Length of output: 5837


🏁 Script executed:

grep -n "strings.SplitN\|parts\[" test/extended-priv/mco_bootimages_skew.go

Repository: openshift/machine-config-operator

Length of output: 228


🏁 Script executed:

grep -n "o.Expect.*HaveLen\|o.Expect.*len(" test/extended-priv/mco_bootimages_skew.go | head -20

Repository: openshift/machine-config-operator

Length of output: 59


🏁 Script executed:

sed -n '260,290p' test/extended-priv/mco_bootimages_skew.go

Repository: openshift/machine-config-operator

Length of output: 2029


🏁 Script executed:

grep -B5 -A5 "strings.Split" test/extended-priv/mco_bootimages_skew.go

Repository: openshift/machine-config-operator

Length of output: 714


🏁 Script executed:

wc -l test/extended-priv/mco_bootimages_skew.go

Repository: openshift/machine-config-operator

Length of output: 123


🏁 Script executed:

rg "strings\.SplitN.*\n.*parts\[" test/extended-priv/ -A3

Repository: openshift/machine-config-operator

Length of output: 269


🏁 Script executed:

rg "o\.Expect.*HaveLen|Expect.*len\(" test/extended-priv/ --type go | head -10

Repository: openshift/machine-config-operator

Length of output: 1238


🏁 Script executed:

sed -n '270,282p' test/extended-priv/mco_bootimages_skew.go

Repository: openshift/machine-config-operator

Length of output: 814


Add explicit length validation before indexing split result

Line 277 directly indexes parts[0..3] immediately after strings.SplitN(fields, "\n", 4) without checking the resulting slice length. While the jsonpath format is structured to produce 4 fields, missing or empty provisioning fields could cause a panic (index out of range) with no meaningful diagnostic context. This violates the assertion quality guideline.

Add a length check using o.Expect(parts).To(o.HaveLen(4)) to validate the output format and provide clear error messages if the provisioning CR structure is unexpected.

Suggested fix
-		parts := strings.SplitN(fields, "\n", 4)
-		originalNetwork, originalIP, originalCIDR, originalDHCP := parts[0], parts[1], parts[2], parts[3]
+		parts := strings.SplitN(strings.TrimSpace(fields), "\n", 4)
+		o.Expect(parts).To(o.HaveLen(4), "Expected 4 provisioning fields from CR, got %d in: %q", len(parts), fields)
+		originalNetwork := strings.TrimSpace(parts[0])
+		originalIP := strings.TrimSpace(parts[1])
+		originalCIDR := strings.TrimSpace(parts[2])
+		originalDHCP := strings.TrimSpace(parts[3])
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
parts := strings.SplitN(fields, "\n", 4)
originalNetwork, originalIP, originalCIDR, originalDHCP := parts[0], parts[1], parts[2], parts[3]
parts := strings.SplitN(strings.TrimSpace(fields), "\n", 4)
o.Expect(parts).To(o.HaveLen(4), "Expected 4 provisioning fields from CR, got %d in: %q", len(parts), fields)
originalNetwork := strings.TrimSpace(parts[0])
originalIP := strings.TrimSpace(parts[1])
originalCIDR := strings.TrimSpace(parts[2])
originalDHCP := strings.TrimSpace(parts[3])
🤖 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 `@test/extended-priv/mco_bootimages_skew.go` around lines 276 - 277, The code
immediately indexes parts[0..3] after parts := strings.SplitN(fields, "\n", 4)
which can panic if the split produced fewer than 4 elements; add an explicit
length assertion before indexing (e.g., use o.Expect(parts).To(o.HaveLen(4))
with a clear message) so the test fails with a helpful diagnostic instead of an
index-out-of-range panic; place this check right after the SplitN call in the
same function where originalNetwork, originalIP, originalCIDR, originalDHCP are
assigned.

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-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants