mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +00:00
fix(computes): a bulk migration shows as one job on the host's page
The host's VM list showed every migration of a bulk migration as a job of its own (each holds the host), and kept a card for each when it ended: 20 VMs, 20 cards down the page. The migrations a bulk migration starts now name it as their parent, and a page leaves out a job whose parent is that page's own: the host page shows the bulk migration, with how many of its VMs are done as its progress; each migration still shows on its VM's page and the Jobs page. A page also shows the jobs it is the page of, not only those holding it: the bulk migration holds no claim on the host.
This commit is contained in:
parent
60c581e5e1
commit
25e3794cc9
6 changed files with 46 additions and 4 deletions
|
|
@ -94,7 +94,7 @@ class BulkMigrate(Kind):
|
|||
continue # it left the host meanwhile
|
||||
raw = {"instance": pk, "source": p["compute"], "target": p["target"], "live": True, "autoconverge": True}
|
||||
try:
|
||||
child = jobs.submit("instance.migrate", op.user, raw, f"evac-{op.pk.hex}-{pk}")
|
||||
child = jobs.submit("instance.migrate", op.user, raw, f"bulk-{op.pk.hex}-{pk}", parent=op)
|
||||
except claims.Busy as busy:
|
||||
if busy.blocker is not None and busy.blocker.state == Operation.UNCERTAIN:
|
||||
# it holds its claims until someone resolves it
|
||||
|
|
@ -117,6 +117,10 @@ class BulkMigrate(Kind):
|
|||
raise util.OperationError(gettext_noop("These VMs did not migrate: %(vms)s"), vms=", ".join(failed))
|
||||
return {}
|
||||
|
||||
def progress(self, op):
|
||||
"""(the VMs whose migration ended, the chosen VMs)."""
|
||||
return op.children.filter(state__in=Operation.TERMINAL).count(), len(op.params["instances"])
|
||||
|
||||
def cancel(self, op):
|
||||
"""run sees the cancel and cancels the migrations that run."""
|
||||
|
||||
|
|
|
|||
|
|
@ -222,3 +222,17 @@ class BulkMigrateJobTests(TestCase):
|
|||
raw = {"instance": self.vms[0].pk, "source": third.pk, "target": self.other.pk}
|
||||
with self.assertRaisesRegex(util.OperationError, "moved to another compute"):
|
||||
jobs.submit("instance.migrate", self.admin, raw, "key-mig00003")
|
||||
|
||||
def test_the_host_page_shows_the_bulk_migration_and_not_its_migrations(self):
|
||||
params = {"compute": self.compute.pk, "target": self.other.pk, "parallel": 2, "instances": [self.vms[0].pk]}
|
||||
bulk = jobs.submit("host.bulk_migrate", self.admin, params, "key-bulk0001")
|
||||
child = jobs.submit("instance.migrate", self.admin, {"instance": self.vms[0].pk, "target": self.other.pk},
|
||||
"key-mig00004", parent=bulk)
|
||||
self.client.force_login(self.admin)
|
||||
|
||||
def shown(key):
|
||||
return [job["id"] for job in self.client.get(reverse("operation-resource"), {"key": key}).json()["jobs"]]
|
||||
|
||||
self.assertEqual(shown(claims.compute_key(self.compute.pk)), [str(bulk.pk)])
|
||||
self.assertEqual(shown(claims.instance_key(self.vms[0].uuid)), [str(child.pk)])
|
||||
self.assertEqual(BulkMigrate().progress(bulk), (0, 1))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue