Skip to content

Adapt vspehere bootimage tests to multi vcenter - #6317

Draft
sergiordlr wants to merge 1 commit into
openshift:mainfrom
sergiordlr:adapt_vsphere_bootimage_tests_to_multi_vcenter
Draft

Adapt vspehere bootimage tests to multi vcenter#6317
sergiordlr wants to merge 1 commit into
openshift:mainfrom
sergiordlr:adapt_vsphere_bootimage_tests_to_multi_vcenter

Conversation

@sergiordlr

@sergiordlr sergiordlr commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

- What I did

WIP

- How to verify it

Summary by CodeRabbit

  • New Features

    • Improved vSphere machine set handling by automatically identifying matching failure domains and connection details.
    • Added support for selecting a specific vSphere folder when importing boot images.
  • Bug Fixes

    • Improved credential lookup and validation for vSphere connections.
    • Updated boot-image test workflows to use the appropriate machine set context, improving test accuracy across upgrade 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 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 17, 2026
@openshift-ci

openshift-ci Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

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 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sergiordlr

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

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Walkthrough

vSphere test helpers now resolve connection details from MachineSet-specific failure domains and workspace folders. Boot-image upload helpers and their call sites pass MachineSet context, while control-plane tests use nil where appropriate.

Changes

MachineSet-aware vSphere uploads

Layer / File(s) Summary
vSphere utility contracts and resolution
test/extended-priv/util/vsphere.go
vSphere connection parsing uses required failure-domain fields and deterministic credential keys; image uploads select an explicit folder or the datacenter default.
MachineSet failure-domain helpers
test/extended-priv/machineset.go
MachineSet workspace server and datacenter values are matched against infrastructure failure domains and converted into vSphere connection information.
MachineSet-aware upload orchestration
test/extended-priv/mco_bootimages.go, test/extended-priv/mco_scale.go
Backdated and cloned image uploads pass MachineSet context and workspace folder data through the vSphere upload path.
Boot-image call-site propagation
test/extended-priv/mco_bootimages*.go, test/extended-priv/mco_controlplanemachineset.go
Boot-image test calls pass their target MachineSet or nil to the updated helper signature.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant getBackdatedBootImage
  participant uploadBaseImageToCloud
  participant GetVSphereConnectionInfoForMachineSet
  participant UploadBaseImageToVsphere
  getBackdatedBootImage->>uploadBaseImageToCloud: pass MachineSet and image data
  uploadBaseImageToCloud->>GetVSphereConnectionInfoForMachineSet: resolve vSphere connection
  GetVSphereConnectionInfoForMachineSet-->>uploadBaseImageToCloud: return connection info
  uploadBaseImageToCloud->>UploadBaseImageToVsphere: pass connection info and folder
  UploadBaseImageToVsphere-->>getBackdatedBootImage: upload result
Loading

Suggested reviewers: djoshy

🚥 Pre-merge checks | ✅ 15
✅ Passed checks (15 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the PR’s main change: adapting vSphere boot image tests for multi-vCenter support.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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 No changed Ginkgo titles use dynamic values; the modified files only adjust helpers and all existing titles are static string literals.
Test Structure And Quality ✅ Passed PASS: The touched Ginkgo specs keep bounded Eventually/Consistently calls and existing cleanup patterns; the change is helper/call-site plumbing only.
Microshift Test Compatibility ✅ Passed PR only changes helpers and updates existing MachineSet/CPMS specs already tagged [apigroup:machineconfiguration.openshift.io], so MicroShift skips them.
Single Node Openshift (Sno) Test Compatibility ✅ Passed No new Ginkgo tests were added; existing multi-node suites already skip SNO via SkipOnSingleNodeTopology or SkipTestIfWorkersCannotBeScaled.
Topology-Aware Scheduling Compatibility ✅ Passed Only vSphere test helpers/boot-image plumbing changed; no affinity, topology spread, nodeSelector, or replica logic was introduced.
Ote Binary Stdout Contract ✅ Passed No stdout writes were added in process-level code; touched files only add helpers, and setup logging routes through GinkgoWriter.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No new Ginkgo test cases were added; the PR only adjusts helper/call-site logic, with no new IPv4-only assumptions or new public connectivity requirements introduced.
No-Weak-Crypto ✅ Passed Touched files add vSphere helpers and call sites only; no MD5/SHA1/DES/RC4/3DES/Blowfish/ECB, custom crypto, or secret comparisons were introduced.
Container-Privileges ✅ Passed Touched files are Go test helpers only; no manifest/container specs and no privileged, hostPID/Network/IPC, SYS_ADMIN, runAsUser, or allowPrivilegeEscalation settings found.
No-Sensitive-Data-In-Logs ✅ Passed The PR’s new logs only emit non-secret metadata (folder/network/template names); no passwords, tokens, API keys, or credentials are logged.
✨ 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.

@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

🤖 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_scale.go`:
- Around line 691-698: Update the uploadBaseImageToCloud flow around
GetVSphereConnectionInfoForMachineSet to handle a nil ms before dereferencing
it: use the default GetVSphereConnectionInfo when ms is nil, and retain the
existing MachineSet-specific lookup and workspace folder extraction for non-nil
ms 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

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: d265aed6-2975-4ffd-aa5f-c1d0bcb64594

📥 Commits

Reviewing files that changed from the base of the PR and between fa31822 and 11dae54.

📒 Files selected for processing (6)
  • test/extended-priv/machineset.go
  • test/extended-priv/mco_bootimages.go
  • test/extended-priv/mco_bootimages_skew.go
  • test/extended-priv/mco_controlplanemachineset.go
  • test/extended-priv/mco_scale.go
  • test/extended-priv/util/vsphere.go

Comment on lines +691 to +698
vsInfo, err := GetVSphereConnectionInfoForMachineSet(ms)
if err != nil {
return err
}

err = exutil.UploadBaseImageToVsphere(baseImageURL, baseImage, vsInfo)
folder, _ := ms.Get(`{.spec.template.spec.providerSpec.value.workspace.folder}`)

err = exutil.UploadBaseImageToVsphere(baseImageURL, baseImage, vsInfo, folder)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Prevent nil-pointer panic when ms is nil.

Currently, uploadBaseImageToCloud is called with ms = nil from the ControlPlaneMachineSet test suite. While VspherePlatform is skipped in that suite right now, this will crash with a nil-pointer dereference inside GetVSphereConnectionInfoForMachineSet if vSphere ever becomes a supported platform for CPMS updates.

Adding a nil guard and falling back to the default GetVSphereConnectionInfo ensures the helper remains robust against changes in upstream test definitions.

🛠️ Proposed fix to handle nil MachineSet
-		vsInfo, err := GetVSphereConnectionInfoForMachineSet(ms)
-		if err != nil {
-			return err
-		}
-
-		folder, _ := ms.Get(`{.spec.template.spec.providerSpec.value.workspace.folder}`)
+		var vsInfo *exutil.VSphereConnectionInfo
+		var err error
+		var folder string
+		
+		if ms != nil {
+			vsInfo, err = GetVSphereConnectionInfoForMachineSet(ms)
+			folder, _ = ms.Get(`{.spec.template.spec.providerSpec.value.workspace.folder}`)
+		} else {
+			vsInfo, err = exutil.GetVSphereConnectionInfo(oc.AsAdmin())
+		}
+		
+		if err != nil {
+			return err
+		}
📝 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
vsInfo, err := GetVSphereConnectionInfoForMachineSet(ms)
if err != nil {
return err
}
err = exutil.UploadBaseImageToVsphere(baseImageURL, baseImage, vsInfo)
folder, _ := ms.Get(`{.spec.template.spec.providerSpec.value.workspace.folder}`)
err = exutil.UploadBaseImageToVsphere(baseImageURL, baseImage, vsInfo, folder)
var vsInfo *exutil.VSphereConnectionInfo
var err error
var folder string
if ms != nil {
vsInfo, err = GetVSphereConnectionInfoForMachineSet(ms)
folder, _ = ms.Get(`{.spec.template.spec.providerSpec.value.workspace.folder}`)
} else {
vsInfo, err = exutil.GetVSphereConnectionInfo(oc.AsAdmin())
}
if err != nil {
return err
}
err = exutil.UploadBaseImageToVsphere(baseImageURL, baseImage, vsInfo, folder)
🤖 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_scale.go` around lines 691 - 698, Update the
uploadBaseImageToCloud flow around GetVSphereConnectionInfoForMachineSet to
handle a nil ms before dereferencing it: use the default
GetVSphereConnectionInfo when ms is nil, and retain the existing
MachineSet-specific lookup and workspace folder extraction for non-nil ms
values.

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.

1 participant