@@ -1759,20 +1759,13 @@ def _heal_allocations_for_instance(self, ctxt, instance, node_cache,
1759
1759
# return None if we can't communicate with Placement, and the
1760
1760
# response can have an empty {'allocations': {}} response if
1761
1761
# 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 ):
1776
1769
# We have an instance with allocations but not the correct
1777
1770
# project_id/user_id, so we want to update the allocations
1778
1771
# 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,
1781
1774
return self ._heal_missing_project_and_user_id (
1782
1775
allocations , instance , dry_run , output , placement )
1783
1776
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
1788
1780
1789
1781
def _heal_instances_in_cell (self , ctxt , max_count , unlimited , output ,
1790
1782
placement , dry_run , instance_uuid ):
0 commit comments