mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +00:00
fix(backups): a schedule of every VM of a compute reads the host's VMs
The schedule took a compute's VMs from the database, which learns of a VM made with virsh only when a page reads the host. When its time comes, the compute's own schedule task reads the host first, once a day per compute and day; the new VM is backed up a pass later. refresh_instance_database now says whether it synchronized: a host that did not answer, was busy or failed is read again at the next pass, and the known VMs are backed up meanwhile. A host in maintenance is not read.
This commit is contained in:
parent
1d880acb17
commit
2e3ffba851
4 changed files with 95 additions and 12 deletions
|
|
@ -184,6 +184,8 @@ def refresh_instance_database(compute):
|
|||
UserInstance permission relationships (matched by UUID).
|
||||
- If libvirt is unreachable (connection/network error), the database is left
|
||||
untouched to avoid false deletions.
|
||||
True when the database matches the host's VMs afterwards; None when it was
|
||||
not synchronized (host not answering, busy or changed meanwhile).
|
||||
"""
|
||||
compute_pk = getattr(compute, "pk", getattr(compute, "id", None))
|
||||
if not compute_pk:
|
||||
|
|
@ -202,7 +204,7 @@ def refresh_instance_database(compute):
|
|||
cutoff = timezone.now() - timedelta(days=retention)
|
||||
if (dict(Instance.objects.filter(compute_id=compute_pk).values_list("uuid", "name")) == host_domains
|
||||
and not InstanceTombstone.objects.filter(removed__lt=cutoff).exists()):
|
||||
return
|
||||
return True
|
||||
|
||||
try:
|
||||
# The compute shared: VM operations and jobs on it go on; changes of
|
||||
|
|
@ -260,6 +262,7 @@ def refresh_instance_database(compute):
|
|||
)
|
||||
if created and not Instance.objects.filter(uuid=uuid).exclude(compute=compute).exists():
|
||||
_restore(inst)
|
||||
return True
|
||||
except claims.Busy:
|
||||
logger.debug("Compute %s is busy; not synchronized now", compute_pk)
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue