diff options
author | Dan Smith <dansmith@redhat.com> | 2023-01-30 12:46:45 -0800 |
---|---|---|
committer | Dan Smith <dansmith@redhat.com> | 2023-02-01 09:20:59 -0800 |
commit | 72370a188c0755bc9c864b5a5e4a972077cb8dd6 (patch) | |
tree | c517c770a3c35f1bc3a8932945c445032fec005f /nova/compute | |
parent | f01a90ccb85ab254236f84009cd432d03ce12ebb (diff) | |
download | nova-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/compute')
-rw-r--r-- | nova/compute/manager.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 0bf6fdfec5..f59fd82d10 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -1473,7 +1473,7 @@ class ComputeManager(manager.Manager): node. """ try: - node_uuids = self.driver.get_available_node_uuids() + node_ids = self.driver.get_nodenames_by_uuid() except exception.VirtDriverNotReady: LOG.warning( "Virt driver is not ready. If this is the first time this " @@ -1481,7 +1481,8 @@ class ComputeManager(manager.Manager): "this warning.") return {} - nodes = objects.ComputeNodeList.get_all_by_uuids(context, node_uuids) + nodes = objects.ComputeNodeList.get_all_by_uuids(context, + list(node_ids.keys())) if not nodes: # NOTE(danms): This should only happen if the compute_id is # pre-provisioned on a host that has never started. @@ -1489,9 +1490,18 @@ class ComputeManager(manager.Manager): 'database. If this is the first time this service is ' 'starting on this host, then you can ignore this ' 'warning.', - node_uuids, self.host) + list(node_ids.keys()), self.host) return {} + for node in nodes: + if node.hypervisor_hostname != node_ids.get(node.uuid): + raise exception.InvalidConfiguration( + ('My compute node %s has hypervisor_hostname %s ' + 'but virt driver reports it should be %s. Possible ' + 'rename detected, refusing to start!') % ( + node.uuid, node.hypervisor_hostname, + node_ids.get(node.uuid))) + return {n.uuid: n for n in nodes} def _ensure_existing_node_identity(self, service_ref): |