summaryrefslogtreecommitdiff
path: root/nova/virt
diff options
context:
space:
mode:
authorDan Smith <dansmith@redhat.com>2023-01-30 12:46:45 -0800
committerDan Smith <dansmith@redhat.com>2023-02-01 09:20:59 -0800
commit72370a188c0755bc9c864b5a5e4a972077cb8dd6 (patch)
treec517c770a3c35f1bc3a8932945c445032fec005f /nova/virt
parentf01a90ccb85ab254236f84009cd432d03ce12ebb (diff)
downloadnova-72370a188c0755bc9c864b5a5e4a972077cb8dd6.tar.gz
Check our nodes for hypervisor_hostname changes
When we are loading our ComputeNode objects by UUID according to what the virt driver reported, we can sanity check the DB records against the virt driver's hostname. This covers the case where our CONF.host has not changed but the hostname reported by the virt driver has, assuming we can find the ComputeNode object(s) that match our persistent node uuid. Related to blueprint stable-compute-uuid Change-Id: I41635210d7d6f46b437b06d2570a26a80ed8676a
Diffstat (limited to 'nova/virt')
-rw-r--r--nova/virt/driver.py6
-rw-r--r--nova/virt/fake.py7
-rw-r--r--nova/virt/ironic/driver.py8
-rw-r--r--nova/virt/libvirt/driver.py4
4 files changed, 16 insertions, 9 deletions
diff --git a/nova/virt/driver.py b/nova/virt/driver.py
index b6297bb785..5d42a392d8 100644
--- a/nova/virt/driver.py
+++ b/nova/virt/driver.py
@@ -1596,8 +1596,10 @@ class ComputeDriver(object):
"""
raise NotImplementedError()
- def get_available_node_uuids(self, refresh=False):
- return [nova.virt.node.get_local_node_uuid()]
+ def get_nodenames_by_uuid(self, refresh=False):
+ """Returns a dict of {uuid: nodename} for all managed nodes."""
+ nodename = self.get_available_nodes()[0]
+ return {nova.virt.node.get_local_node_uuid(): nodename}
def node_is_available(self, nodename):
"""Return whether this compute service manages a particular node."""
diff --git a/nova/virt/fake.py b/nova/virt/fake.py
index f86db8fcb2..2234bd068e 100644
--- a/nova/virt/fake.py
+++ b/nova/virt/fake.py
@@ -510,7 +510,7 @@ class FakeDriver(driver.ComputeDriver):
# control our node uuids. Make sure we return a unique and
# consistent uuid for each node we are responsible for to
# avoid the persistent local node identity from taking over.
- host_status['uuid'] = str(getattr(uuids, nodename))
+ host_status['uuid'] = str(getattr(uuids, 'node_%s' % nodename))
return host_status
def update_provider_tree(self, provider_tree, nodename, allocations=None):
@@ -653,8 +653,9 @@ class FakeDriver(driver.ComputeDriver):
def get_available_nodes(self, refresh=False):
return self._nodes
- def get_available_node_uuids(self, refresh=False):
- return [str(getattr(uuids, n)) for n in self.get_available_nodes()]
+ def get_nodenames_by_uuid(self, refresh=False):
+ return {str(getattr(uuids, 'node_%s' % n)): n
+ for n in self.get_available_nodes()}
def instance_on_disk(self, instance):
return False
diff --git a/nova/virt/ironic/driver.py b/nova/virt/ironic/driver.py
index b437b4a959..77fefb81ea 100644
--- a/nova/virt/ironic/driver.py
+++ b/nova/virt/ironic/driver.py
@@ -839,8 +839,12 @@ class IronicDriver(virt_driver.ComputeDriver):
return node_uuids
- def get_available_node_uuids(self, refresh=False):
- return self.get_available_nodes(refresh=refresh)
+ def get_nodenames_by_uuid(self, refresh=False):
+ nodes = self.get_available_nodes(refresh=refresh)
+ # We use the uuid for compute_node.uuid and
+ # compute_node.hypervisor_hostname, so the dict keys and values are
+ # the same.
+ return dict(zip(nodes, nodes))
def update_provider_tree(self, provider_tree, nodename, allocations=None):
"""Update a ProviderTree object with current resource provider and
diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py
index 4b34759bb7..542383cbad 100644
--- a/nova/virt/libvirt/driver.py
+++ b/nova/virt/libvirt/driver.py
@@ -11332,8 +11332,8 @@ class LibvirtDriver(driver.ComputeDriver):
def get_available_nodes(self, refresh=False):
return [self._host.get_hostname()]
- def get_available_node_uuids(self, refresh=False):
- return [self._host.get_node_uuid()]
+ def get_nodenames_by_uuid(self, refresh=False):
+ return {self._host.get_node_uuid(): self._host.get_hostname()}
def get_host_cpu_stats(self):
"""Return the current CPU state of the host."""