1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 17:36:05 +00:00

feat(computes): Balance proposes migrations that even out the hosts

A Balance button on the Computes page opens computes/balance/: the memory
and vCPUs each host gives its running VMs, before and after, and the
proposed migrations. The proposal (computes/balance.py) takes, step by
step, the one move that most lowers the sum of the squared memory loads,
then of the squared vCPU loads, and stops when none does; each VM moves
once, and the VMs moved to a host fit in the memory its running and
paused VMs leave without counting those moved away, so the moves may
run in any order. Only running VMs count and
move; one that cannot move (no destination shares its disks) still
counts on its host and is listed with the reason. Unticking a VM keeps
it where it is and makes the proposal again.

Migrate runs the moves shown in one host.balance job. It shares the bulk
migration's loop (computes.jobs.Migrations): migrate jobs, the chosen
number at once, one bulk job at a time. Its migrations take only a
running VM (moveto running_only): one stopped since stays where it is.

A job another one started now shows only on its own page: a host's page
no longer lists a bulk migration's or a balance's migrations, and the
Computes page shows the bulk jobs.
This commit is contained in:
catborise 2026-11-16 07:33:39 +03:00
parent 027896c3d4
commit 4941a8a048
19 changed files with 1179 additions and 481 deletions

12
static/js/balance.js Normal file
View file

@ -0,0 +1,12 @@
// The Balance page: unticking a VM keeps it where it is, ticking it again
// lets it move; either makes the proposal again. The header box ticks or
// unticks every VM listed.
const form = document.getElementById("balance-form");
form?.addEventListener("change", function (event) {
if (event.target.id === "balance-all") {
form.querySelectorAll("input[name=vm]").forEach(function (box) {
box.checked = event.target.checked;
});
}
form.submit();
});