Skip to content

Commit 5352c68

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "reorder conditions in _heal_allocations_for_instance"
2 parents bc7b9ec + 9adcf53 commit 5352c68

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

nova/cmd/manage.py

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1759,20 +1759,13 @@ def _heal_allocations_for_instance(self, ctxt, instance, node_cache,
17591759
# return None if we can't communicate with Placement, and the
17601760
# response can have an empty {'allocations': {}} response if
17611761
# there are no allocations for the instance so handle both
1762-
if allocations and allocations.get('allocations'):
1763-
# Check to see if the allocation project_id
1764-
# and user_id matches the instance project and user and
1765-
# fix the allocation project/user if they don't match.
1766-
# Allocations created before Placement API version 1.8
1767-
# did not have a project_id/user_id, and migrated records
1768-
# could have sentinel values from config.
1769-
if (allocations.get('project_id') ==
1770-
instance.project_id and
1771-
allocations.get('user_id') == instance.user_id):
1772-
output(_('Instance %s already has allocations with '
1773-
'matching consumer project/user.') %
1774-
instance.uuid)
1775-
return
1762+
if not allocations or not allocations.get('allocations'):
1763+
# This instance doesn't have allocations
1764+
return self._heal_missing_alloc(
1765+
ctxt, instance, node_cache, dry_run, output, placement)
1766+
1767+
if (allocations.get('project_id') != instance.project_id or
1768+
allocations.get('user_id') != instance.user_id):
17761769
# We have an instance with allocations but not the correct
17771770
# project_id/user_id, so we want to update the allocations
17781771
# and re-put them. We don't use put_allocations here
@@ -1781,10 +1774,9 @@ def _heal_allocations_for_instance(self, ctxt, instance, node_cache,
17811774
return self._heal_missing_project_and_user_id(
17821775
allocations, instance, dry_run, output, placement)
17831776

1784-
# This instance doesn't have allocations so we need to find
1785-
# its compute node resource provider.
1786-
return self._heal_missing_alloc(
1787-
ctxt, instance, node_cache, dry_run, output, placement)
1777+
output(_('Instance %s already has allocations with '
1778+
'matching consumer project/user.') % instance.uuid)
1779+
return
17881780

17891781
def _heal_instances_in_cell(self, ctxt, max_count, unlimited, output,
17901782
placement, dry_run, instance_uuid):

0 commit comments

Comments
 (0)