Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distinguish resize from offline migrate in scheduler #454

Open
wants to merge 1 commit into
base: stable/xena-m3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion nova/compute/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
13 changes: 13 additions & 0 deletions nova/scheduler/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions nova/tests/unit/compute/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down