@@ -626,8 +626,9 @@ func (r *Reconciler) getVMForPlacement(
626626 return
627627 }
628628
629- // If both error and vm are nil, then the VM is already placed, or will
630- // be placed outside the group. Update PlacementReady condition to True.
629+ // Set PlacementReady condition to True if the VM is already placed.
630+ // For VMs with zone label override, VMG will receive reconciliation
631+ // requests once they're actually placed and update the condition then.
631632 if alreadyPlaced {
632633 conditions .Set (memberStatus , & metav1.Condition {
633634 Type : vmopv1 .VirtualMachineGroupMemberConditionPlacementReady ,
@@ -640,8 +641,6 @@ func (r *Reconciler) getVMForPlacement(
640641 //
641642 Message : alreadyPlacedZone ,
642643 })
643- } else {
644- conditions .MarkTrue (memberStatus , vmopv1 .VirtualMachineGroupMemberConditionPlacementReady )
645644 }
646645 }()
647646
@@ -658,21 +657,6 @@ func (r *Reconciler) getVMForPlacement(
658657 return nil , fmt .Errorf ("VM %q is assigned to group %q instead of expected %q" , vmName , gn , vmGroup .Name )
659658 }
660659
661- // Check if VM has uniqueID set first to update the AlreadyPlaced reason.
662- if vm .Status .UniqueID != "" {
663-
664- alreadyPlaced = true
665- alreadyPlacedZone = vm .Status .Zone
666-
667- pkglog .FromContextOrDefault (ctx ).V (4 ).Info (
668- "VM has uniqueID, skipping group placement" ,
669- "vmName" , vmName ,
670- "uniqueID" , vm .Status .UniqueID ,
671- "zone" , vm .Status .Zone ,
672- )
673- return nil , nil
674- }
675-
676660 // Skip if the group already has placement condition ready true for this VM.
677661 // Need to check the UID in case the VM is recreated with the same name and
678662 // without being removed from the group (could have stale placement status).
@@ -688,8 +672,24 @@ func (r *Reconciler) getVMForPlacement(
688672 return nil , nil
689673 }
690674
675+ // Group status doesn't have placement condition ready for this VM (UID).
676+ // Check if the VM is already placed or will be placed outside the group.
677+
691678 memberStatus .UID = vm .GetUID ()
692679
680+ if vm .Status .UniqueID != "" {
681+ alreadyPlaced = true
682+ alreadyPlacedZone = vm .Status .Zone
683+
684+ pkglog .FromContextOrDefault (ctx ).V (4 ).Info (
685+ "VM has uniqueID, skipping group placement" ,
686+ "vmName" , vmName ,
687+ "uniqueID" , vm .Status .UniqueID ,
688+ "zone" , vm .Status .Zone ,
689+ )
690+ return nil , nil
691+ }
692+
693693 // If VM has a zone label, skip group placement to respect zone override.
694694 if zoneName := vm .Labels [corev1 .LabelTopologyZone ]; zoneName != "" {
695695 pkglog .FromContextOrDefault (ctx ).V (4 ).Info (
@@ -700,6 +700,9 @@ func (r *Reconciler) getVMForPlacement(
700700 return nil , nil
701701 }
702702
703+ // VMG doesn't have a PlacementReady condition true for this VM (UID).
704+ // VM is not already placed, nor has a zone label override.
705+ // Return this VM to get it placed by the group.
703706 return vm , nil
704707}
705708
0 commit comments