Skip to content

✨ vmop-3743: Add VirtualMachineConfigOptions controller and webhook#1672

Open
faisalabujabal wants to merge 2 commits into
vmware-tanzu:mainfrom
faisalabujabal:vmop-3763-vm-config-options-controller
Open

✨ vmop-3743: Add VirtualMachineConfigOptions controller and webhook#1672
faisalabujabal wants to merge 2 commits into
vmware-tanzu:mainfrom
faisalabujabal:vmop-3763-vm-config-options-controller

Conversation

@faisalabujabal

Copy link
Copy Markdown
Contributor

What does this PR do, and why is it needed?

Implements Story S6 (vmop-3743) from the 001-class-policy-resize spec: the VirtualMachineConfigOptions controller and its admission webhook. This is a self-contained vertical slice (product code + unit tests + pending E2E skeleton) for the ConfigTarget → VirtualMachineConfigOptions pipeline stage.

Controller (controllers/virtualmachineconfigoptions/):

  • Watches cluster-scoped VirtualMachineConfigOptions objects
  • Resolves the owning ConfigTarget via owner references to obtain the cluster MoID
  • Calls QueryConfigOptionEx on the vSphere provider to retrieve hardware version capabilities from the cluster's EnvironmentBrowser
  • Maps the result into status (description, guest OS identifiers, default index, hardware options, etc.)
  • Fans out one VirtualMachineGuestOptions child object per guest OS descriptor, upserting the per-hardware-version status entry
  • Tracks status.observedGeneration and sets a Ready condition; requeues with RequeueAfter: 10s when no ConfigTarget owner is found yet

Validation webhook (webhooks/virtualmachineconfigoptions/validation/):

  • Enforces spec.hardwareVersion matches ^vmx-\d+$ on create
  • Makes spec.hardwareVersion immutable on update

vSphere provider plumbing (pkg/providers/vsphere/environment_browser.go):

  • Wraps govmomi EnvironmentBrowser.QueryConfigOption using a ClusterComputeResource property fetch to resolve the browser reference

RBAC: +kubebuilder:rbac markers in the controller; config/rbac/role.yaml regenerated via make generate-manifests.

Test coverage: 5 controller unit tests (72.7% coverage), 10 webhook unit tests (73.7% coverage). E2E tests are marked Pending in test/e2e/vmservice/configpolicy/ — full pipeline (Zone → ConfigTarget → VirtualMachineConfigOptions) is not yet running on a real cluster.

Which issue(s) is/are addressed by this PR?

Fixes #

Are there any special notes for your reviewer:

  • The E2E tests are intentionally Pending — they require the ConfigTarget controller (S4/vmop-3740) to be merged first so the pipeline has objects to drive the test.
  • The test/builder/fake.go change registers vimv1 types (ConfigTarget, VirtualMachineConfigOptions, VirtualMachineGuestOptions) into the unit-test scheme, which is needed for the controller's fake-client unit tests.
  • make generate-manifests fails locally because the hack/tools module requires Go 1.26.4 but the runner has 1.26.2; the existing controller-gen from ~/go/bin was used instead (same version v0.19.0).

Please add a release note if necessary:

NONE

Implement Story S6 (vmop-3743) from the class-policy-resize spec
(001-class-policy-resize). This PR delivers a vertical slice:
validation webhook, controller, environment-browser helper, unit
tests, and a pending E2E skeleton.

Changes:
- controllers/virtualmachineconfigoptions: new Reconciler that
  resolves the owning ConfigTarget, calls QueryConfigOptionEx via
  the provider, maps the result into status, and fans out
  VirtualMachineGuestOptions child objects; includes finalizer
  management, Ready condition, and observedGeneration tracking
- webhooks/virtualmachineconfigoptions/validation: immutable
  spec.hardwareVersion and ^vmx-\d+ format enforcement
- pkg/providers/vsphere/environment_browser.go: govmomi wrapper
  for QueryConfigOptionEx using the cluster EnvironmentBrowser
- pkg/providers/{vm_provider_interface,fake,vsphere/vmprovider}:
  extend interface with QueryConfigOptionEx and wire the vSphere
  implementation
- controllers/controllers.go, webhooks/webhooks.go: register new
  controller and webhook under VirtualMachineConfigPolicy gate
- config/rbac/role.yaml: regenerated from +kubebuilder:rbac markers
- test/e2e/vmservice/configpolicy: pending E2E skeleton (full
  pipeline not yet deployed)
- test/builder/fake.go: register vimv1 types in test scheme
@faisalabujabal faisalabujabal requested a review from a team as a code owner June 17, 2026 23:00
The VirtualMachineConfigOptions validation webhook and its
registration in webhooks/webhooks.go are covered by PR vmop-3762
(vmop-3762-vm-config-options-webhook). Remove the duplicate files
to keep this PR scoped to the controller only.
@github-actions github-actions Bot added size/XXL Denotes a PR that changes 1000+ lines. size/XL Denotes a PR that changes 500-999 lines. and removed size/XXL Denotes a PR that changes 1000+ lines. labels Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XL Denotes a PR that changes 500-999 lines.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant