mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +00:00
fix(computes): a changed compute does not use or list its old host
A compute saved with another address, login or password, or deleted, left its connection open in the panel: saved back to the old credentials, the panel used it again although the host no longer took them. A VM list that read the host before such a change could then save that listing over the VMs of the new one. The old connection is retired when a compute's connection changes or the compute is deleted, and a listing is saved only when the compute's connection is still the one it was read with.
This commit is contained in:
parent
29ec20682b
commit
d682c4bc82
5 changed files with 81 additions and 2 deletions
|
|
@ -7,7 +7,7 @@ from django.conf import settings
|
|||
from django.contrib.auth import get_user_model
|
||||
from django.db import connection, transaction
|
||||
from django.utils import timezone
|
||||
from computes.models import Compute
|
||||
from computes.models import ENDPOINT, Compute
|
||||
from instances.models import Instance, InstanceTombstone
|
||||
from logs.audit import write
|
||||
from operations import claims
|
||||
|
|
@ -193,6 +193,10 @@ def refresh_instance_database(compute):
|
|||
# undoing a newer one.
|
||||
with claims.hold({claims.compute_key(compute_pk): Claim.SHARED,
|
||||
claims.reconcile_key(compute_pk): Claim.EXCLUSIVE}):
|
||||
# a compute whose connection changed since it was read: the listing would be the old host's
|
||||
if Compute.objects.filter(pk=compute_pk).values_list(*ENDPOINT).first() != \
|
||||
tuple(getattr(compute, field, None) for field in ENDPOINT):
|
||||
return
|
||||
host_domains = _host_domains(compute)
|
||||
if host_domains is None:
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue