reorder conditions in _heal_allocations_for_instance
The new order will make it simple to pull the placement update out from the different healing steps to a single place. Related-Bug: #1819923 Change-Id: Iff5b73d8e818fb1145690d0eeff880d98424fa1d
This commit is contained in:
parent
e6fc316261
commit
9adcf53210
|
@ -1759,20 +1759,13 @@ class PlacementCommands(object):
|
||||||
# return None if we can't communicate with Placement, and the
|
# return None if we can't communicate with Placement, and the
|
||||||
# response can have an empty {'allocations': {}} response if
|
# response can have an empty {'allocations': {}} response if
|
||||||
# there are no allocations for the instance so handle both
|
# there are no allocations for the instance so handle both
|
||||||
if allocations and allocations.get('allocations'):
|
if not allocations or not allocations.get('allocations'):
|
||||||
# Check to see if the allocation project_id
|
# This instance doesn't have allocations
|
||||||
# and user_id matches the instance project and user and
|
return self._heal_missing_alloc(
|
||||||
# fix the allocation project/user if they don't match.
|
ctxt, instance, node_cache, dry_run, output, placement)
|
||||||
# Allocations created before Placement API version 1.8
|
|
||||||
# did not have a project_id/user_id, and migrated records
|
if (allocations.get('project_id') != instance.project_id or
|
||||||
# could have sentinel values from config.
|
allocations.get('user_id') != instance.user_id):
|
||||||
if (allocations.get('project_id') ==
|
|
||||||
instance.project_id and
|
|
||||||
allocations.get('user_id') == instance.user_id):
|
|
||||||
output(_('Instance %s already has allocations with '
|
|
||||||
'matching consumer project/user.') %
|
|
||||||
instance.uuid)
|
|
||||||
return
|
|
||||||
# We have an instance with allocations but not the correct
|
# We have an instance with allocations but not the correct
|
||||||
# project_id/user_id, so we want to update the allocations
|
# project_id/user_id, so we want to update the allocations
|
||||||
# and re-put them. We don't use put_allocations here
|
# and re-put them. We don't use put_allocations here
|
||||||
|
@ -1781,10 +1774,9 @@ class PlacementCommands(object):
|
||||||
return self._heal_missing_project_and_user_id(
|
return self._heal_missing_project_and_user_id(
|
||||||
allocations, instance, dry_run, output, placement)
|
allocations, instance, dry_run, output, placement)
|
||||||
|
|
||||||
# This instance doesn't have allocations so we need to find
|
output(_('Instance %s already has allocations with '
|
||||||
# its compute node resource provider.
|
'matching consumer project/user.') % instance.uuid)
|
||||||
return self._heal_missing_alloc(
|
return
|
||||||
ctxt, instance, node_cache, dry_run, output, placement)
|
|
||||||
|
|
||||||
def _heal_instances_in_cell(self, ctxt, max_count, unlimited, output,
|
def _heal_instances_in_cell(self, ctxt, max_count, unlimited, output,
|
||||||
placement, dry_run, instance_uuid):
|
placement, dry_run, instance_uuid):
|
||||||
|
|
Loading…
Reference in New Issue