From 7c2ed78d85003267f0b0513af16e45b53395255d Mon Sep 17 00:00:00 2001 From: Arik Hadas Date: Sun, 9 Jun 2024 17:10:46 +0300 Subject: [PATCH] vsphere: virt-v2v transfers disks sequentially when scheduling migrations to accommodate the controller_max_vm_inflight setting for vSphere, we didn't take into account that disks are transferred sequentially by virt-v2v (as opposed to CDI that transfers them in parallel by different pods). This lead to performance degregeration since could have triggered more migrations, in case of migrations of multi-disk VMs, simultaneously without exceeding the value of controller_max_vm_inflight. This is fixed by setting the cost of each VM for which the disks are transferred by virt-v2v to 1. Signed-off-by: Arik Hadas --- .../plan/scheduler/vsphere/scheduler.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pkg/controller/plan/scheduler/vsphere/scheduler.go b/pkg/controller/plan/scheduler/vsphere/scheduler.go index 100130c90..2e7159450 100644 --- a/pkg/controller/plan/scheduler/vsphere/scheduler.go +++ b/pkg/controller/plan/scheduler/vsphere/scheduler.go @@ -107,7 +107,7 @@ func (r *Scheduler) buildInFlight() (err error) { return } if vmStatus.Running() { - r.inFlight[vm.Host] += len(vm.Disks) + r.inFlight[vm.Host] += r.cost(vm) } } @@ -148,7 +148,7 @@ func (r *Scheduler) buildInFlight() (err error) { } return err } - r.inFlight[vm.Host] += len(vm.Disks) + r.inFlight[vm.Host] += r.cost(vm) } } @@ -169,7 +169,7 @@ func (r *Scheduler) buildPending() (err error) { if !vmStatus.MarkedStarted() && !vmStatus.MarkedCompleted() { pending := &pendingVM{ status: vmStatus, - cost: len(vm.Disks), + cost: r.cost(vm), } r.pending[vm.Host] = append(r.pending[vm.Host], pending) } @@ -177,6 +177,16 @@ func (r *Scheduler) buildPending() (err error) { return } +func (r *Scheduler) cost(vm *model.VM) int { + if el9, _ := r.Plan.VSphereUsesEl9VirtV2v(); el9 { + /// virt-v2v transfers one disk at a time + return 1 + } else { + // CDI transfers the disks in parallel by different pods + return len(vm.Disks) + } +} + // Return a map of all the VMs that could be scheduled // based on the available host capacities. func (r *Scheduler) schedulable() (schedulable map[string][]*pendingVM) {