project-pegaprox icon indicating copy to clipboard operation
project-pegaprox copied to clipboard

[Feature] Bulk migration: migrate sequentially instead of starting everything at once

Open mkellermann97 opened this issue 2 months ago • 1 comments

Describe the feature

Bulk migration should move the selected guests one after another — start a migration, wait for that task to finish, then start the next — instead of firing them all off at once.

How it works today (POST /api/clusters/<id>/vms/bulk-migrate, bulk_migrate_api in pegaprox/api/vms.py): the handler loops over the selected VMs and calls migrate_vm_manual() per guest. That call starts a migration and returns a UPID; nothing waits on it. So for a selection of 20 guests, Proxmox gets 20 migrations kicked off within a second of each other and runs them concurrently.

What we'd want instead:

  • sequential by default — each migration awaited before the next begins
  • an optional concurrency setting for people with the bandwidth for 2–3 at a time
  • progress visible while it runs (n of m done, which guest is moving, which failed) rather than one response at the end
  • a failure on one guest doesn't abort the rest, same as today
  • keep the existing 1000-guest batch cap and the per-VM vm.migrate authorization

Use Case

Evacuating a node, or rebalancing after adding one, means moving everything at once. In that situation concurrent migrations are actively harmful: they share the migration network and the source/target storage, so they slow each other down, and a batch that would finish comfortably one-at-a-time instead has everything in flight and blocking. Sequential is slower on paper and faster in practice, and much easier to reason about when one guest fails halfway.

It also makes the operation observable. Right now the API answers once all migrations have been started, so the UI can't distinguish "20 migrations queued" from "20 migrations finished", and a stuck guest is invisible until someone looks at the task log.

Alternatives considered

  • Leave it to Proxmox — PVE does have its own limits, but they're cluster-wide and not aware of what else PegaProx has in flight, so a bulk action can still pile on.
  • Fixed small parallelism instead of strictly sequential — reasonable, and worth exposing as a setting, but the default should be the safe one.
  • Reuse the rolling-update path — node evacuation already migrates guests and waits on each task, so the waiting logic exists (_wait_for_task); this is largely about wiring the bulk endpoint to the same discipline and reporting progress out.

How important is this for you?

Nice to have, but it comes up every time a node is drained by hand.

Checklist

  • [x] I have searched existing issues to make sure this is not a duplicate
  • [x] This is a feature request, not a bug report

mkellermann97 avatar Sep 26 '26 13:09 mkellermann97

Bulk migration now runs on the server with a choice of mode: one guest at a time, two to five at once, or all at once as before. The dialog defaults to one at a time for more than three guests, shows a card per run with each guest's progress, keeps going past a failed guest and lets you cancel the rest, while the 1000-guest cap and the per-guest vm.migrate check stay in place. This ships in 1.3.0.

Marcus

mkellermann97 avatar Oct 07 '26 04:10 mkellermann97