De-duplicate two delete_allocation_for_* methods
delete_allocation_for_migrated_instance and delete_allocation_for_evacuated_instance are only different in their log messages, so extract their guts to a shared private method. This same method could also be used at the end of drop_move_claim, but the extent of change to the logging there made me pause. Perhaps another time. Change-Id: Ifad17e08aa3ddbd95f25b6133564ea1a1a1bb87c
This commit is contained in:
parent
1080506f16
commit
5a0aa09737
@ -1211,6 +1211,13 @@ class ResourceTracker(object):
|
|||||||
instance_uuid, instance.host, instance.node, alloc)
|
instance_uuid, instance.host, instance.node, alloc)
|
||||||
|
|
||||||
def delete_allocation_for_evacuated_instance(self, instance, node):
|
def delete_allocation_for_evacuated_instance(self, instance, node):
|
||||||
|
self._delete_allocation_for_moved_instance(instance, node, 'evacuated')
|
||||||
|
|
||||||
|
def delete_allocation_for_migrated_instance(self, instance, node):
|
||||||
|
self._delete_allocation_for_moved_instance(instance, node, 'migrated')
|
||||||
|
|
||||||
|
def _delete_allocation_for_moved_instance(
|
||||||
|
self, instance, node, move_type):
|
||||||
# Clean up the instance allocation from this node in placement
|
# Clean up the instance allocation from this node in placement
|
||||||
my_resources = scheduler_utils.resources_from_flavor(
|
my_resources = scheduler_utils.resources_from_flavor(
|
||||||
instance, instance.flavor)
|
instance, instance.flavor)
|
||||||
@ -1221,21 +1228,9 @@ class ResourceTracker(object):
|
|||||||
instance.uuid, cn_uuid, instance.user_id,
|
instance.uuid, cn_uuid, instance.user_id,
|
||||||
instance.project_id, my_resources)
|
instance.project_id, my_resources)
|
||||||
if not res:
|
if not res:
|
||||||
LOG.error("Failed to clean allocation of an evacuated "
|
LOG.error("Failed to clean allocation of %s "
|
||||||
"instance on the source node %s",
|
"instance on the source node %s",
|
||||||
cn_uuid, instance=instance)
|
move_type, cn_uuid, instance=instance)
|
||||||
|
|
||||||
def delete_allocation_for_migrated_instance(self, instance, node):
|
|
||||||
my_resources = scheduler_utils.resources_from_flavor(instance,
|
|
||||||
instance.flavor)
|
|
||||||
cn = self.compute_nodes[node]
|
|
||||||
res = self.reportclient.remove_provider_from_instance_allocation(
|
|
||||||
instance.uuid, cn.uuid, instance.user_id, instance.project_id,
|
|
||||||
my_resources)
|
|
||||||
if not res:
|
|
||||||
LOG.error('Failed to clean allocation of a migrated instance '
|
|
||||||
'on the source node %s', cn.uuid,
|
|
||||||
instance=instance)
|
|
||||||
|
|
||||||
def delete_allocation_for_failed_resize(self, instance, node, flavor):
|
def delete_allocation_for_failed_resize(self, instance, node, flavor):
|
||||||
"""Delete instance allocations for the node during a failed resize
|
"""Delete instance allocations for the node during a failed resize
|
||||||
|
Loading…
Reference in New Issue
Block a user