diff --git a/nova/compute/api.py b/nova/compute/api.py index ef169323bb3..4b4341cf4b2 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -4143,7 +4143,10 @@ def resize(self, context, instance, flavor_id=None, clean_shutdown=True, validate_pci=True) # Not to be confused with scheduler_hint (singular) - scheduler_hints = {'_nova_check_type': ['resize']} + if same_flavor: + scheduler_hints = {'_nova_check_type': ['migrate']} + else: + scheduler_hints = {'_nova_check_type': ['resize']} filter_properties = {'ignore_hosts': [], 'scheduler_hints': scheduler_hints} diff --git a/nova/scheduler/utils.py b/nova/scheduler/utils.py index e984f136ec2..5cb92e9894a 100644 --- a/nova/scheduler/utils.py +++ b/nova/scheduler/utils.py @@ -1239,6 +1239,19 @@ def request_is_live_migrate(spec_obj): return check_type == 'live_migrate' +def request_is_migrate(spec_obj): + """Returns True if request is for an offline migration + + :param spec_obj: An objects.RequestSpec to examine (or None). + """ + if not spec_obj: + return False + if 'scheduler_hints' not in spec_obj: + return False + check_type = spec_obj.get_scheduler_hint('_nova_check_type') + return check_type == 'migrate' + + def claim_resources(ctx, client, spec_obj, instance_uuid, alloc_req, allocation_request_version=None): """Given an instance UUID (representing the consumer of resources) and the diff --git a/nova/tests/unit/compute/test_api.py b/nova/tests/unit/compute/test_api.py index f640251e1bd..c850f27a148 100644 --- a/nova/tests/unit/compute/test_api.py +++ b/nova/tests/unit/compute/test_api.py @@ -2066,8 +2066,12 @@ def _check_state(expected_task_state=None): else: filter_properties = {'ignore_hosts': [fake_inst['host']]} - filter_properties['scheduler_hints'] = { - '_nova_check_type': ['resize']} + if flavor_id_passed: + filter_properties['scheduler_hints'] = { + '_nova_check_type': ['resize']} + else: + filter_properties['scheduler_hints'] = { + '_nova_check_type': ['migrate']} if request_spec: fake_spec = objects.RequestSpec()