Skip to content

✨ BestEffortRestartPolicy e2e - #1860

Open
hpannem wants to merge 1 commit into
vmware-tanzu:mainfrom
hpannem:maint-mode-policy-besteffort
Open

✨ BestEffortRestartPolicy e2e#1860
hpannem wants to merge 1 commit into
vmware-tanzu:mainfrom
hpannem:maint-mode-policy-besteffort

Conversation

@hpannem

@hpannem hpannem commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

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

Adds the remaining E2E coverage for the AutomaticVMEvictionPolicy/BestEffortRestartPolicy compute-policy CRDs (product code already merged in #1859), closing out tasks.md T021/T022 and adding T040:

  • Explicitly referencing a matching Optional BestEffortRestartPolicy via spec.policies tags the VM.
  • Explicitly referencing a non-matching Optional BestEffortRestartPolicy surfaces a not-ready PolicyEvaluation condition (Ready=False, message containing "does not match").
  • A VM matching a Mandatory AutomaticVMEvictionPolicy and explicitly referencing an Optional BestEffortRestartPolicy surfaces both in status.policies.
  • Both policies Mandatory and matching the same VM simultaneously (no explicit references).
  • Both policies Optional and explicitly referenced together via spec.policies.

All new Its are labeled experimental per e2e-testing.md, pending validation on real hardware.

Also removes a standalone ComputePolicy e2e spec (computepolicy.go) and its Context("COMPUTE-POLICY", ...) wiring that were added earlier under the mistaken assumption ComputePolicy had no e2e coverage — it already has thorough mandatory/optional combination coverage through the real WCP admin API path in test/e2e/vmservice/vmservice/virtualmachine/virtualmachinelcm.go (Context("IaaS Policies", ...), Context("PLACEMENT-POLICY-COMBINATIONS", ...)), so the parallel direct-CRD-creation spec was redundant. This PR's scope is intentionally limited to AutomaticVMEvictionPolicy/BestEffortRestartPolicy.

.sdd/specs/007-vm-eviction-policy/plan.md and tasks.md updated to match.

Which issue(s) is/are addressed by this PR? (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):

Fixes #

Are there any special notes for your reviewer:

  • Not yet run against a real WCP/vSphere testbed — all new specs carry the experimental label and are excluded from CI until validated on hardware.
  • createAutomaticVMEvictionPolicy/createBestEffortRestartPolicy gained an enforcementMode parameter (previously hardcoded per kind) so both Mandatory and Optional variants are exercisable from the same helpers; all existing call sites updated accordingly.

Please add a release note if necessary:

NONE

@hpannem hpannem self-assigned this Aug 28, 2026
@hpannem
hpannem requested review from a team and faisalabujabal as code owners August 28, 2026 04:58
@github-actions github-actions Bot added the size/XXL Denotes a PR that changes 1000+ lines. label Aug 28, 2026
@hpannem hpannem added the pro-ai-review-requested Mark the PR as ready for the AI Review bot using a Pro model label Aug 28, 2026
@svc-vmop-bot

Copy link
Copy Markdown

📝 CL Summary:

This pull request introduces the AutomaticHostEvacuationPolicy and BestEffortRestartPolicy CRDs to support host maintenance mode infrastructure policies. These policies enable DRS to automatically power off workloads that cannot be evacuated during host maintenance and optionally restart them on a best-effort basis. To support these additions efficiently, the policyevaluation controller is refactored to use a table-driven registry, eliminating the need for duplicated per-kind reconciliation logic. All new functionality is gated behind the supports_infrapolicy_vm_evacuation Supervisor capability.

@svc-vmop-bot svc-vmop-bot added cl-summary-reviewed AI Reviewed PR Summary commit-msg-reviewed AI Reviewed Commit Message labels Aug 28, 2026
Comment thread external/vsphere-policy/api/v1alpha1/besteffortrestartpolicy_types.go Outdated
Comment thread test/e2e/vmservice/vmservice/hostmaintenancepolicy/hostmaintenancepolicy.go Outdated
Comment thread test/e2e/vmservice/vmservice/computepolicies/vmevictionpolicy.go
@svc-vmop-bot svc-vmop-bot added the ai-reviewed This PR has been reviewed by the AI review bot label Aug 28, 2026
@faisalabujabal faisalabujabal removed the pro-ai-review-requested Mark the PR as ready for the AI Review bot using a Pro model label Aug 28, 2026
@hpannem
hpannem force-pushed the maint-mode-policy-besteffort branch 3 times, most recently from cf95240 to 8975be3 Compare September 3, 2026 22:54
@hpannem hpannem changed the title ✨ BestEffortRestartPolicy CRD and fold policy-kind reconciliation into a registry ✨ BestEffortRestartPolicy e2e Sep 3, 2026
@hpannem
hpannem force-pushed the maint-mode-policy-besteffort branch from 8975be3 to 3540c58 Compare September 4, 2026 23:40
@github-actions github-actions Bot added size/XL Denotes a PR that changes 500-999 lines. and removed size/XXL Denotes a PR that changes 1000+ lines. labels Sep 4, 2026
@hpannem hpannem added pro-ai-review-requested Mark the PR as ready for the AI Review bot using a Pro model and removed ai-reviewed This PR has been reviewed by the AI review bot labels Sep 4, 2026
@svc-vmop-bot svc-vmop-bot added ai-reviewed This PR has been reviewed by the AI review bot and removed pro-ai-review-requested Mark the PR as ready for the AI Review bot using a Pro model labels Sep 5, 2026
@hpannem
hpannem force-pushed the maint-mode-policy-besteffort branch from 3540c58 to 6993c1a Compare September 6, 2026 16:14
test fix
issue with condition message update
@hpannem
hpannem force-pushed the maint-mode-policy-besteffort branch from 6993c1a to 4215de5 Compare September 7, 2026 00:40
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Code Coverage

Package Line Rate Health
github.com/vmware-tanzu/vm-operator/controllers/configtarget 74%
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/clustercontentlibraryitem 67%
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/contentlibraryitem 67%
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/utils 85%
github.com/vmware-tanzu/vm-operator/controllers/infra/capability/configmap 92%
github.com/vmware-tanzu/vm-operator/controllers/infra/capability/crd 100%
github.com/vmware-tanzu/vm-operator/controllers/infra/configmap 75%
github.com/vmware-tanzu/vm-operator/controllers/infra/node 77%
github.com/vmware-tanzu/vm-operator/controllers/infra/secret 76%
github.com/vmware-tanzu/vm-operator/controllers/infra/validatingwebhookconfiguration 87%
github.com/vmware-tanzu/vm-operator/controllers/infra/workloadnetworkconfig 86%
github.com/vmware-tanzu/vm-operator/controllers/infra/zone 80%
github.com/vmware-tanzu/vm-operator/controllers/storage/storageclass 93%
github.com/vmware-tanzu/vm-operator/controllers/storage/storagepolicy 96%
github.com/vmware-tanzu/vm-operator/controllers/storage/storagepolicyquota 91%
github.com/vmware-tanzu/vm-operator/controllers/storage/volumeattributesclass 93%
github.com/vmware-tanzu/vm-operator/controllers/util/encoding 73%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachine/storagepolicyusage 96%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachine/virtualmachine 65%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachine/volume 85%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachine/volumebatch 89%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineclass 73%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineconfigoptions 87%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinegroup 90%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinegrouppublishrequest 88%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineimagecache 89%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinepublishrequest 84%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinereplicaset 68%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineservice 90%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineservice/providers 93%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinesetresourcepolicy 81%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinesnapshot 91%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinewebconsolerequest 72%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinewebconsolerequest/v1alpha1 72%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinewebconsolerequest/v1alpha1/conditions 88%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinewebconsolerequest/v1alpha1/patch 78%
github.com/vmware-tanzu/vm-operator/controllers/vspherepolicy/policyevaluation 87%
github.com/vmware-tanzu/vm-operator/pkg/bitmask 100%
github.com/vmware-tanzu/vm-operator/pkg/builder 89%
github.com/vmware-tanzu/vm-operator/pkg/conditions 90%
github.com/vmware-tanzu/vm-operator/pkg/config 100%
github.com/vmware-tanzu/vm-operator/pkg/config/capabilities 97%
github.com/vmware-tanzu/vm-operator/pkg/config/env 100%
github.com/vmware-tanzu/vm-operator/pkg/context 37%
github.com/vmware-tanzu/vm-operator/pkg/context/generic 100%
github.com/vmware-tanzu/vm-operator/pkg/context/operation 100%
github.com/vmware-tanzu/vm-operator/pkg/crd 77%
github.com/vmware-tanzu/vm-operator/pkg/errors 74%
github.com/vmware-tanzu/vm-operator/pkg/exit 100%
github.com/vmware-tanzu/vm-operator/pkg/log 100%
github.com/vmware-tanzu/vm-operator/pkg/mem 100%
github.com/vmware-tanzu/vm-operator/pkg/patch 78%
github.com/vmware-tanzu/vm-operator/pkg/prober 89%
github.com/vmware-tanzu/vm-operator/pkg/prober/probe 90%
github.com/vmware-tanzu/vm-operator/pkg/prober/worker 77%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere 74%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/clustermodules 73%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/config 88%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/contentlibrary 76%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/credentials 100%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/network 86%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/placement 70%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/session 60%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/storage 44%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/upgrade/virtualmachine 96%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/upgrade/virtualmachine/backfill 96%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/vcenter 86%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/virtualmachine 85%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/virtualmachine/extraconfig 91%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/virtualmachine/networkextraconfig 75%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/vmlifecycle 77%
github.com/vmware-tanzu/vm-operator/pkg/record 84%
github.com/vmware-tanzu/vm-operator/pkg/topology 91%
github.com/vmware-tanzu/vm-operator/pkg/util 79%
github.com/vmware-tanzu/vm-operator/pkg/util/cloudinit 89%
github.com/vmware-tanzu/vm-operator/pkg/util/cloudinit/validate 91%
github.com/vmware-tanzu/vm-operator/pkg/util/image 100%
github.com/vmware-tanzu/vm-operator/pkg/util/kube 91%
github.com/vmware-tanzu/vm-operator/pkg/util/kube/cource 100%
github.com/vmware-tanzu/vm-operator/pkg/util/kube/internal 100%
github.com/vmware-tanzu/vm-operator/pkg/util/kube/networksettings 100%
github.com/vmware-tanzu/vm-operator/pkg/util/kube/proxyaddr 73%
github.com/vmware-tanzu/vm-operator/pkg/util/kube/spq 99%
github.com/vmware-tanzu/vm-operator/pkg/util/linuxprep 97%
github.com/vmware-tanzu/vm-operator/pkg/util/netplan 100%
github.com/vmware-tanzu/vm-operator/pkg/util/nil 100%
github.com/vmware-tanzu/vm-operator/pkg/util/ovfcache 75%
github.com/vmware-tanzu/vm-operator/pkg/util/ovfcache/internal 100%
github.com/vmware-tanzu/vm-operator/pkg/util/paused 100%
github.com/vmware-tanzu/vm-operator/pkg/util/ptr 100%
github.com/vmware-tanzu/vm-operator/pkg/util/resize 98%
github.com/vmware-tanzu/vm-operator/pkg/util/sysprep 98%
github.com/vmware-tanzu/vm-operator/pkg/util/vmopv1 88%
github.com/vmware-tanzu/vm-operator/pkg/util/volumes 100%
github.com/vmware-tanzu/vm-operator/pkg/util/vsphere/client 66%
github.com/vmware-tanzu/vm-operator/pkg/util/vsphere/datastore 100%
github.com/vmware-tanzu/vm-operator/pkg/util/vsphere/fault 100%
github.com/vmware-tanzu/vm-operator/pkg/util/vsphere/library 95%
github.com/vmware-tanzu/vm-operator/pkg/util/vsphere/storage 82%
github.com/vmware-tanzu/vm-operator/pkg/util/vsphere/task 100%
github.com/vmware-tanzu/vm-operator/pkg/util/vsphere/vm 78%
github.com/vmware-tanzu/vm-operator/pkg/util/vsphere/watcher 85%
github.com/vmware-tanzu/vm-operator/pkg/vmconfig 95%
github.com/vmware-tanzu/vm-operator/pkg/vmconfig/anno2extraconfig 100%
github.com/vmware-tanzu/vm-operator/pkg/vmconfig/bootoptions 88%
github.com/vmware-tanzu/vm-operator/pkg/vmconfig/cdrom 88%
github.com/vmware-tanzu/vm-operator/pkg/vmconfig/crypto 92%
github.com/vmware-tanzu/vm-operator/pkg/vmconfig/diskpromo 100%
github.com/vmware-tanzu/vm-operator/pkg/vmconfig/extensioncompatconstraint 93%
github.com/vmware-tanzu/vm-operator/pkg/vmconfig/extraconfig 100%
github.com/vmware-tanzu/vm-operator/pkg/vmconfig/networkextraconfig 79%
github.com/vmware-tanzu/vm-operator/pkg/vmconfig/policy 97%
github.com/vmware-tanzu/vm-operator/pkg/vmconfig/virtualcontroller 93%
github.com/vmware-tanzu/vm-operator/pkg/vmconfig/volumes/unmanaged/backfill 98%
github.com/vmware-tanzu/vm-operator/pkg/vmconfig/volumes/unmanaged/register 92%
github.com/vmware-tanzu/vm-operator/pkg/webconsolevalidation 100%
github.com/vmware-tanzu/vm-operator/services/vm-watcher 85%
github.com/vmware-tanzu/vm-operator/webhooks/common 98%
github.com/vmware-tanzu/vm-operator/webhooks/configtarget/validation 87%
github.com/vmware-tanzu/vm-operator/webhooks/persistentvolumeclaim/validation 95%
github.com/vmware-tanzu/vm-operator/webhooks/unifiedstoragequota/validation 89%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachine/mutation 86%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachine/validation 96%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineclass/mutation 62%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineclass/validation 89%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineconfigoptions/validation 88%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinegroup/mutation 87%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinegroup/validation 93%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinegrouppublishrequest/mutation 86%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinegrouppublishrequest/validation 88%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineguestoptions/validation 88%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinepublishrequest/validation 90%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinereplicaset/validation 90%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineservice/mutation 67%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineservice/validation 92%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinesetresourcepolicy/validation 89%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinesnapshot/mutation 86%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinesnapshot/validation 91%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinewebconsolerequest/v1alpha1/validation 92%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinewebconsolerequest/validation 92%
Summary 84% (21833 / 25857)

Minimum allowed line rate is 79%

@aruneshpa aruneshpa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. Two minor comments.

vmCtx.VM,
vmopv1.VirtualMachineConditionPlacementReady) {
vmopv1.VirtualMachineConditionPlacementReady) ||
pkgcond.GetReason(vmCtx.VM,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I may be missing something here. :( But what you are adding seems redundant? The only way your code executes is when the VirtualMachineConditionPlacementReady is False AND the reason is NotReady -- upon which we set the reason to NotReady in the if block?


// The object is still being processed.
msg := pkgcond.GetMessage(obj, vspherepolv1.ReadyConditionType)
if msg != "" {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is confusing. Instead of creating this weird formatted string by sticking this next to the error, let's either have another key (e.g., "msg", ). Or, change the error to include the message somehow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-reviewed This PR has been reviewed by the AI review bot cl-summary-reviewed AI Reviewed PR Summary commit-msg-reviewed AI Reviewed Commit Message size/XL Denotes a PR that changes 500-999 lines.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants