DNM/WIP: Create missing allocation on list?

Change-Id: I033a9925fe798f329b7bb9a629da0cd0f1202683
This commit is contained in:
Julia Kreger 2024-05-08 07:40:11 -07:00
parent cbb0f359d0
commit 267789b6ac
1 changed files with 16 additions and 2 deletions

View File

@ -689,8 +689,22 @@ class Provisioner(object):
allocation = Provisioner.allocations_cache[
node.instance_id]
except KeyError:
allocation = self.connection.baremetal.get_allocation(
node.allocation_id)
# NOTE(TheJulia): The pattern here assumes we just haven't
# found the allocation entry, so we try to get it.
if node.allocation_id:
allocation = self.connection.baremetal.get_allocation(
node.allocation_id)
elif node.instance_id:
LOG.debug('Discovered node %s without an '
'allocation when we believe it should have '
'an allocation. Attempting to create an '
'allocation.', node.id)
# We have an instance_id, and to be here we have
# no allocation ID. Lets reconcile!
allocation = \
self.connection.baremetal.create_allocation(
node_id=node.id,
name=node.name)
except os_exc.ResourceNotFound as exc:
raise exceptions.InstanceNotFound(str(exc))
else: