Skip to content

Commit 47bfc46

Browse files
author
Balazs Gibizer
committed
Follow up for Ib50b6b02208f5bd2972de8a6f8f685c19745514c
* Extract out the provider mapping code from finish_revert_resize * Fix nits in the code comments Change-Id: If48134a87aaedcd1c7cfef0229a7e0af05514910 blueprint: support-move-ops-with-qos-ports
1 parent 7113ac4 commit 47bfc46

File tree

2 files changed

+38
-20
lines changed

2 files changed

+38
-20
lines changed

nova/compute/api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3463,9 +3463,9 @@ def revert_resize(self, context, instance):
34633463
# RequestSpec.requested_resources as others like cyborg might added
34643464
# to things there already
34653465
# NOTE(gibi): We need to collect the requested resource again as it is
3466-
# intentionally not persisted in nova. Note that this is needs to be
3467-
# done here as the nova REST API code directly calls revert on the
3468-
# compute_api skipping the conductor.
3466+
# intentionally not persisted in nova. Note that this needs to be
3467+
# done here as the nova API code directly calls revert on the
3468+
# dest compute service skipping the conductor.
34693469
port_res_req = self.network_api.get_requested_resource_for_instance(
34703470
context, instance.uuid)
34713471
reqspec.requested_resources = port_res_req

nova/compute/manager.py

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4295,23 +4295,8 @@ def finish_revert_resize(
42954295
'migration_uuid': migration.uuid})
42964296
raise
42974297

4298-
if request_spec:
4299-
# NOTE(gibi): We need to re-calculate the resource provider -
4300-
# port mapping as we have to have the neutron ports allocate
4301-
# from the source compute after revert.
4302-
scheduler_utils.fill_provider_mapping_based_on_allocation(
4303-
context, self.reportclient, request_spec,
4304-
source_allocations)
4305-
provider_mappings = self._get_request_group_mapping(
4306-
request_spec)
4307-
else:
4308-
# NOTE(gibi): The compute RPC is pinned to be older than 5.2
4309-
# and therefore request_spec is not sent. We cannot calculate
4310-
# the provider mappings. If the instance has ports with
4311-
# resource request then the port update will fail in
4312-
# _update_port_binding_for_instance() called via
4313-
# _finish_revert_resize_network_migrate_finish() below.
4314-
provider_mappings = None
4298+
provider_mappings = self._fill_provider_mapping_based_on_allocs(
4299+
context, source_allocations, request_spec)
43154300

43164301
self.network_api.setup_networks_on_host(context, instance,
43174302
migration.source_compute)
@@ -4363,6 +4348,39 @@ def finish_revert_resize(
43634348
self.host, action=fields.NotificationAction.RESIZE_REVERT,
43644349
phase=fields.NotificationPhase.END, bdms=bdms)
43654350

4351+
def _fill_provider_mapping_based_on_allocs(
4352+
self, context, allocations, request_spec):
4353+
"""Fills and returns the request group - resource provider mapping
4354+
based on the allocation passed in.
4355+
4356+
:param context: The security context
4357+
:param allocation: allocation dict keyed by RP UUID.
4358+
:param request_spec: The RequestSpec object associated with the
4359+
operation
4360+
:returns: None if the request_spec is None. Otherwise a mapping
4361+
between RequestGroup requester_id, currently Neutron port_id,
4362+
and a list of resource provider UUIDs providing resource for
4363+
that RequestGroup.
4364+
"""
4365+
if request_spec:
4366+
# NOTE(gibi): We need to re-calculate the resource provider -
4367+
# port mapping as we have to have the neutron ports allocate
4368+
# from the source compute after revert.
4369+
scheduler_utils.fill_provider_mapping_based_on_allocation(
4370+
context, self.reportclient, request_spec, allocations)
4371+
provider_mappings = self._get_request_group_mapping(
4372+
request_spec)
4373+
else:
4374+
# NOTE(gibi): The compute RPC is pinned to be older than 5.2
4375+
# and therefore request_spec is not sent. We cannot calculate
4376+
# the provider mappings. If the instance has ports with
4377+
# resource request then the port update will fail in
4378+
# _update_port_binding_for_instance() called via
4379+
# _finish_revert_resize_network_migrate_finish() in
4380+
# finish_revert_resize.
4381+
provider_mappings = None
4382+
return provider_mappings
4383+
43664384
def _revert_allocation(self, context, instance, migration):
43674385
"""Revert an allocation that is held by migration to our instance."""
43684386

0 commit comments

Comments
 (0)