Skip to content

Commit a412d72

Browse files
Balazs Gibizermriedem
authored andcommitted
Allow resizing server with port resource request
This patch adds functional coverage for such resize. No extra code changes were needed on top of the migrate patches to make resize work. Now that the nova code supports the resize this patch removes the check from the API that rejected the operation. Note that in the spec [1] we agreed not to introduce new microversion for this change but treat it as a bugfix. The current change also makes it possible to accept the resize of these servers with _any_ microversion. [1] https://specs.openstack.org/openstack/nova-specs/specs/train/approved/support-move-ops-with-qos-ports.html#rest-api-impact blueprint: support-move-ops-with-qos-ports Change-Id: Id0ee10e8d323786f4d79c82e3f05b48e76bd0956
1 parent fee98b7 commit a412d72

File tree

7 files changed

+123
-90
lines changed

7 files changed

+123
-90
lines changed

api-guide/source/port_with_resource_request.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ version of nova:
2525
shelve offload) servers with ports having resource request is not yet
2626
supported.
2727

28-
As of 20.0.0 (Train), nova supports cold migrating servers with neutron ports
29-
having resource requests if both the source and destination compute services
30-
are upgraded to 20.0.0 (Train) and the ``[upgrade_levels]/compute``
31-
configuration does not prevent the computes from using the latest RPC version.
28+
As of 20.0.0 (Train), nova supports cold migrating and resizing servers with
29+
neutron ports having resource requests if both the source and destination
30+
compute services are upgraded to 20.0.0 (Train) and the
31+
``[upgrade_levels]/compute`` configuration does not prevent the computes from
32+
using the latest RPC version.
33+
34+
See :nova-doc:`the admin guide <admin/port_with_resource_request.html>` for
35+
administrative details.

nova/api/openstack/compute/servers.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -940,18 +940,8 @@ def _resize(self, req, instance_id, flavor_id, **kwargs):
940940
target={'user_id': instance.user_id,
941941
'project_id': instance.project_id})
942942

943-
# We could potentially move this check to conductor and avoid the
944-
# extra API call to neutron when we support move operations with ports
945-
# having resource requests.
946943
if common.instance_has_port_with_resource_request(
947944
context, instance_id, self.network_api):
948-
if not common.supports_port_resource_request_during_move(req):
949-
msg = _("The resize action on a server with ports having "
950-
"resource requests, like a port with a QoS minimum "
951-
"bandwidth policy, is not supported with this "
952-
"microversion")
953-
raise exc.HTTPBadRequest(explanation=msg)
954-
955945
# TODO(gibi): Remove when nova only supports compute newer than
956946
# Train
957947
source_service = objects.Service.get_by_host_and_binary(

nova/compute/manager.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4284,7 +4284,8 @@ def finish_revert_resize(
42844284
instance.save()
42854285

42864286
try:
4287-
self._revert_allocation(context, instance, migration)
4287+
source_allocations = self._revert_allocation(
4288+
context, instance, migration)
42884289
except exception.AllocationMoveFailed:
42894290
LOG.error('Reverting allocation in placement for migration '
42904291
'%(migration_uuid)s failed. The instance '
@@ -4295,16 +4296,12 @@ def finish_revert_resize(
42954296
raise
42964297

42974298
if request_spec:
4298-
# TODO(gibi): the _revert_allocation() call above already
4299-
# fetched the original allocation of the instance so we could
4300-
# avoid this second call to placement
43014299
# NOTE(gibi): We need to re-calculate the resource provider -
43024300
# port mapping as we have to have the neutron ports allocate
43034301
# from the source compute after revert.
4304-
allocs = self.reportclient.get_allocations_for_consumer(
4305-
context, instance.uuid)
43064302
scheduler_utils.fill_provider_mapping_based_on_allocation(
4307-
context, self.reportclient, request_spec, allocs)
4303+
context, self.reportclient, request_spec,
4304+
source_allocations)
43084305
provider_mappings = self._get_request_group_mapping(
43094306
request_spec)
43104307
else:
@@ -4391,7 +4388,7 @@ def _revert_allocation(self, context, instance, migration):
43914388
# TODO(cdent): Should we be doing anything with return values here?
43924389
self.reportclient.move_allocations(context, migration.uuid,
43934390
instance.uuid)
4394-
return True
4391+
return orig_alloc
43954392

43964393
def _prep_resize(self, context, image, instance, instance_type,
43974394
filter_properties, node, migration, request_spec,

nova/tests/functional/integrated_helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,10 +433,10 @@ def setUp(self):
433433

434434
placement = self.useFixture(func_fixtures.PlacementFixture())
435435
self.placement_api = placement.api
436-
api_fixture = self.useFixture(nova_fixtures.OSAPIFixture(
436+
self.api_fixture = self.useFixture(nova_fixtures.OSAPIFixture(
437437
api_version='v2.1'))
438438

439-
self.admin_api = api_fixture.admin_api
439+
self.admin_api = self.api_fixture.admin_api
440440
self.admin_api.microversion = self.microversion
441441
self.api = self.admin_api
442442

0 commit comments

Comments
 (0)