summaryrefslogtreecommitdiff
path: root/nova/objects
diff options
context:
space:
mode:
authorDan Smith <dansmith@redhat.com>2023-02-01 08:27:08 -0800
committerDan Smith <dansmith@redhat.com>2023-02-01 09:23:33 -0800
commitcf33be68713e30b7e4a4ca8dd3c4138329914503 (patch)
treed441b435768cf0a2453a120e1c7fcd12b798fc07 /nova/objects
parent5934f85fb9e7d18a05ef7e8a6217697bed753d4f (diff)
downloadnova-cf33be68713e30b7e4a4ca8dd3c4138329914503.tar.gz
Abort startup if nodename conflict is detected
We do run update_available_resource() synchronously during service startup, but we only allow certain exceptions to abort startup. This makes us abort for InvalidConfiguration, and makes the resource tracker raise that for the case where the compute node create failed due to a duplicate entry. This also modifies the object to raise a nova-specific error for that condition to avoid the compute node needing to import oslo_db stuff just to be able to catch it. Change-Id: I5de98e6fe52e45996bc2e1014fa8a09a2de53682
Diffstat (limited to 'nova/objects')
-rw-r--r--nova/objects/compute_node.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/nova/objects/compute_node.py b/nova/objects/compute_node.py
index 528cfc0776..dfc1b2ae28 100644
--- a/nova/objects/compute_node.py
+++ b/nova/objects/compute_node.py
@@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo_db import exception as db_exc
from oslo_serialization import jsonutils
from oslo_utils import uuidutils
from oslo_utils import versionutils
@@ -339,7 +340,12 @@ class ComputeNode(base.NovaPersistentObject, base.NovaObject):
self._convert_supported_instances_to_db_format(updates)
self._convert_pci_stats_to_db_format(updates)
- db_compute = db.compute_node_create(self._context, updates)
+ try:
+ db_compute = db.compute_node_create(self._context, updates)
+ except db_exc.DBDuplicateEntry:
+ target = 'compute node %s:%s' % (updates['hypervisor_hostname'],
+ updates['uuid'])
+ raise exception.DuplicateRecord(target=target)
self._from_db_object(self._context, self, db_compute)
@base.remotable