Reconcile VMLocation when it's moved to different RP or folder and set appropriate conditions#1558
Reconcile VMLocation when it's moved to different RP or folder and set appropriate conditions#1558anwithaun-1 wants to merge 16 commits into
Conversation
anwithaun-1
left a comment
There was a problem hiding this comment.
Please take a look at the addressed comments.
Minimum allowed line rate is |
anwithaun-1
left a comment
There was a problem hiding this comment.
Resolved all the comments. pls review again.
| ctx, | ||
| vcClient.VimClient(), | ||
| nil, | ||
| []string{"resourcePool", |
There was a problem hiding this comment.
When set, the default DefaultWatchedPropertyPaths() is no longer used so that will break the watcher functionality that we need.
Also, the VM managed object doesn't have a parent field. What that one trying to watch?
There was a problem hiding this comment.
@bryanv can I add these property in DefaultWatchedPropertyPaths() then?
| vmCtx.VM, | ||
| vmopv1.VirtualMachineConditionInAuthorizedLocation, | ||
| "LocationMismatch", | ||
| "VM is in an unauthorized Resource Pool. Move the VM back to the Resource Pool hierarchy for namespace '%s' to resume reconciliation.", |
There was a problem hiding this comment.
NS can't have spaces in the name so I don't think quotes are needed
| vmCtx.VM.Namespace, | ||
| ) | ||
|
|
||
| return pkgerr.NoRequeueError{Message: fmt.Errorf( |
There was a problem hiding this comment.
Can't this use Sprintf instead of calling Error() on a error that was just built?
Doesn't the context of where this is use include the VM name?
There was a problem hiding this comment.
We can use sprintf also in this case. I used Errorf as this has been used at many places with NoRequeue.
| if currentRPMoRef.Value == expectedRootRPMoID { | ||
| isValid = true | ||
| } else { | ||
| poolObj := object.NewResourcePool(vcClient.VimClient(), currentRPMoRef) |
There was a problem hiding this comment.
We have some RP related helpers in vsphere/vcenter/resourcepool.go that this could be moved to.
What does this PR do, and why is it needed?
Problem:
Currently, the VM Operator does not set appropriate conditions or halt reconciliation when a VM is moved out of its designated resource pool or folder. This leads to two major issues:
Permission Creep: DevOps admin privileges are inadvertently extended to reconfigure VMs that have drifted into different inventory locations.
Lack of Visibility: There is no "stop-gap" or clear status indicator telling administrators that the VM is in an orphaned state, leading to unpredictable reconciliation behavior.
Solution:
State Conflict: Two instances of the same workload existing simultaneously in different locations.
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 #
VMSVC-3539
VMSVC-3541
Are there any special notes for your reviewer:
Please add a release note if necessary: