From 7bcd88bf9d351fd58d1a67dfe4d159a6c166a7a8 Mon Sep 17 00:00:00 2001 From: Marcel <156897072+mblos@users.noreply.github.com> Date: Mon, 26 Oct 2026 10:21:26 +0100 Subject: [PATCH] fix: confirm CR reservation allocations immediately when VM is already on hypervisor Signed-off-by: Marcel <156897072+mblos@users.noreply.github.com> --- .../commitments/reservation_controller.go | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/internal/scheduling/reservations/commitments/reservation_controller.go b/internal/scheduling/reservations/commitments/reservation_controller.go index ba10dfcd5..8d4186e8c 100644 --- a/internal/scheduling/reservations/commitments/reservation_controller.go +++ b/internal/scheduling/reservations/commitments/reservation_controller.go @@ -522,20 +522,10 @@ func (r *CommitmentReservationController) reconcileAllocations(ctx context.Conte allocationAge := now.Sub(allocation.CreationTimestamp.Time) isInGracePeriod := allocationAge < r.Conf.AllocationGracePeriod.Duration - // Confirmed VMs (already in Status.Allocations) bypass the grace period: - // their departure from the HV CRD is authoritative and must be acted on immediately. - // Unconfirmed VMs still within the grace period may not yet appear in the HV CRD - // (still spawning), so defer verification and requeue with a short interval. _, isConfirmed := existingStatusAllocations[vmUUID] - if !isConfirmed && isInGracePeriod { - result.HasAllocationsInGracePeriod = true - logger.V(1).Info("allocation in grace period, deferring verification", - "vm", vmUUID, - "allocationAge", allocationAge) - continue - } - // Post-grace-period or confirmed VM: use HV CRD as authoritative source. + // Always check HV CRD first: if the VM is already present (e.g. a long-running + // PayG VM being absorbed), confirm immediately without waiting for the grace period. if hvInstanceSet[vmUUID] { newStatusAllocations[vmUUID] = expectedHost logger.V(1).Info("verified VM allocation via Hypervisor CRD", @@ -544,8 +534,18 @@ func (r *CommitmentReservationController) reconcileAllocations(ctx context.Conte continue } - // VM not on the expected host. For unconfirmed post-grace VMs this is a clean - // stale allocation — remove it without further searching. + // VM not yet visible in HV CRD. For unconfirmed VMs still within the grace period + // the HV CRD sync may not have caught up yet (newly spawned VM) — defer and requeue. + if !isConfirmed && isInGracePeriod { + result.HasAllocationsInGracePeriod = true + logger.V(1).Info("allocation in grace period, deferring verification", + "vm", vmUUID, + "allocationAge", allocationAge) + continue + } + + // VM not on the expected host, past grace period or already confirmed. + // For unconfirmed post-grace VMs this is a clean stale allocation — remove it. if !isConfirmed { allocationsToRemove = append(allocationsToRemove, vmUUID) logger.Info("removing stale allocation (VM not found on hypervisor)",