diff options
author | Balazs Gibizer <balazs.gibizer@est.tech> | 2021-07-23 18:23:28 +0200 |
---|---|---|
committer | Balazs Gibizer <balazs.gibizer@est.tech> | 2021-08-27 17:59:18 +0200 |
commit | 191bdf2069086493be2a2e0351afa7f3efad7099 (patch) | |
tree | 5f97addbfd9f3b0bddcc8344ca8a0bfb240e9e41 /nova/api/openstack/compute | |
parent | c3886c3ca758b32df8a58388d967dc3c0a5aebec (diff) | |
download | nova-191bdf2069086493be2a2e0351afa7f3efad7099.tar.gz |
Support move ops with extended resource request
Nova re-generates the resource request of an instance for each server
move operation (migrate, resize, evacuate, live-migrate, unshelve) to
find (or validate) a target host for the instance move. This patch
extends the this logic to support the extended resource request from
neutron.
As the changes in the neutron interface code is called from nova-compute
service during the port binding the compute service version is bumped.
And a check is added to the compute-api to reject the move operations
with ports having extended resource request if there are old computes
in the cluster.
blueprint: qos-minimum-guaranteed-packet-rate
Change-Id: Ibcf703e254e720b9a6de17527325758676628d48
Diffstat (limited to 'nova/api/openstack/compute')
-rw-r--r-- | nova/api/openstack/compute/evacuate.py | 10 | ||||
-rw-r--r-- | nova/api/openstack/compute/migrate_server.py | 30 | ||||
-rw-r--r-- | nova/api/openstack/compute/servers.py | 24 | ||||
-rw-r--r-- | nova/api/openstack/compute/shelve.py | 20 |
4 files changed, 23 insertions, 61 deletions
diff --git a/nova/api/openstack/compute/evacuate.py b/nova/api/openstack/compute/evacuate.py index 6d014ef2f3..b09e592a2b 100644 --- a/nova/api/openstack/compute/evacuate.py +++ b/nova/api/openstack/compute/evacuate.py @@ -26,7 +26,6 @@ from nova.compute import api as compute import nova.conf from nova import exception from nova.i18n import _ -from nova.network import neutron from nova.policies import evacuate as evac_policies from nova import utils @@ -40,7 +39,6 @@ class EvacuateController(wsgi.Controller): super(EvacuateController, self).__init__() self.compute_api = compute.API() self.host_api = compute.HostAPI() - self.network_api = neutron.API() def _get_on_shared_storage(self, req, evacuate_body): if api_version_request.is_supported(req, min_version='2.14'): @@ -120,13 +118,6 @@ class EvacuateController(wsgi.Controller): msg = _("The target host can't be the same one.") raise exc.HTTPBadRequest(explanation=msg) - if self.network_api.instance_has_extended_resource_request(id): - msg = _( - "The evacuate server operation with port having extended " - "resource request, like a port with both QoS minimum " - "bandwidth and packet rate policies, is not yet supported.") - raise exc.HTTPBadRequest(explanation=msg) - try: self.compute_api.evacuate(context, instance, host, on_shared_storage, password, force) @@ -136,6 +127,7 @@ class EvacuateController(wsgi.Controller): except ( exception.ComputeServiceInUse, exception.ForbiddenPortsWithAccelerator, + exception.ExtendedResourceRequestOldCompute, ) as e: raise exc.HTTPBadRequest(explanation=e.format_message()) except exception.ForbiddenWithAccelerators as e: diff --git a/nova/api/openstack/compute/migrate_server.py b/nova/api/openstack/compute/migrate_server.py index be2fe51ce5..ebaeccff3d 100644 --- a/nova/api/openstack/compute/migrate_server.py +++ b/nova/api/openstack/compute/migrate_server.py @@ -26,7 +26,6 @@ from nova.api import validation from nova.compute import api as compute from nova import exception from nova.i18n import _ -from nova.network import neutron from nova.policies import migrate_server as ms_policies LOG = logging.getLogger(__name__) @@ -36,7 +35,6 @@ class MigrateServerController(wsgi.Controller): def __init__(self): super(MigrateServerController, self).__init__() self.compute_api = compute.API() - self.network_api = neutron.API() @wsgi.response(202) @wsgi.expected_errors((400, 403, 404, 409)) @@ -56,13 +54,6 @@ class MigrateServerController(wsgi.Controller): body['migrate'] is not None): host_name = body['migrate'].get('host') - if self.network_api.instance_has_extended_resource_request(id): - msg = _( - "The migrate server operation with port having extended " - "resource request, like a port with both QoS minimum " - "bandwidth and packet rate policies, is not yet supported.") - raise exc.HTTPBadRequest(explanation=msg) - try: self.compute_api.resize(req.environ['nova.context'], instance, host_name=host_name) @@ -81,9 +72,12 @@ class MigrateServerController(wsgi.Controller): 'migrate', id) except exception.InstanceNotFound as e: raise exc.HTTPNotFound(explanation=e.format_message()) - except (exception.ComputeHostNotFound, - exception.CannotMigrateToSameHost, - exception.ForbiddenPortsWithAccelerator) as e: + except ( + exception.ComputeHostNotFound, + exception.CannotMigrateToSameHost, + exception.ForbiddenPortsWithAccelerator, + exception.ExtendedResourceRequestOldCompute, + ) as e: raise exc.HTTPBadRequest(explanation=e.format_message()) @wsgi.response(202) @@ -127,13 +121,6 @@ class MigrateServerController(wsgi.Controller): disk_over_commit = strutils.bool_from_string(disk_over_commit, strict=True) - if self.network_api.instance_has_extended_resource_request(id): - msg = _( - "The live migrate server operation with port having extended " - "resource request, like a port with both QoS minimum " - "bandwidth and packet rate policies, is not yet supported.") - raise exc.HTTPBadRequest(explanation=msg) - try: self.compute_api.live_migrate(context, instance, block_migration, disk_over_commit, host, force, @@ -164,7 +151,10 @@ class MigrateServerController(wsgi.Controller): raise exc.HTTPConflict(explanation=e.format_message()) except exception.InstanceIsLocked as e: raise exc.HTTPConflict(explanation=e.format_message()) - except exception.ComputeHostNotFound as e: + except ( + exception.ComputeHostNotFound, + exception.ExtendedResourceRequestOldCompute, + )as e: raise exc.HTTPBadRequest(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error, diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index a297d11e57..4a52cff4e0 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -40,7 +40,6 @@ from nova import context as nova_context from nova import exception from nova.i18n import _ from nova.image import glance -from nova.network import neutron from nova import objects from nova.policies import servers as server_policies from nova import utils @@ -114,7 +113,6 @@ class ServersController(wsgi.Controller): def __init__(self): super(ServersController, self).__init__() self.compute_api = compute.API() - self.network_api = neutron.API() @wsgi.expected_errors((400, 403)) @validation.query_schema(schema_servers.query_params_v275, '2.75') @@ -1028,15 +1026,6 @@ class ServersController(wsgi.Controller): target={'user_id': instance.user_id, 'project_id': instance.project_id}) - if self.network_api.instance_has_extended_resource_request( - instance_id - ): - msg = _( - "The resize server operation with port having extended " - "resource request, like a port with both QoS minimum " - "bandwidth and packet rate policies, is not yet supported.") - raise exc.HTTPBadRequest(explanation=msg) - try: self.compute_api.resize(context, instance, flavor_id, auto_disk_config=auto_disk_config) @@ -1063,11 +1052,14 @@ class ServersController(wsgi.Controller): msg = _("Image that the instance was started " "with could not be found.") raise exc.HTTPBadRequest(explanation=msg) - except (exception.AutoDiskConfigDisabledByImage, - exception.CannotResizeDisk, - exception.CannotResizeToSameFlavor, - exception.FlavorNotFound, - exception.ForbiddenPortsWithAccelerator) as e: + except ( + exception.AutoDiskConfigDisabledByImage, + exception.CannotResizeDisk, + exception.CannotResizeToSameFlavor, + exception.FlavorNotFound, + exception.ForbiddenPortsWithAccelerator, + exception.ExtendedResourceRequestOldCompute, + ) as e: raise exc.HTTPBadRequest(explanation=e.format_message()) except INVALID_FLAVOR_IMAGE_EXCEPTIONS as e: raise exc.HTTPBadRequest(explanation=e.format_message()) diff --git a/nova/api/openstack/compute/shelve.py b/nova/api/openstack/compute/shelve.py index 5bb589817b..b985d49a9a 100644 --- a/nova/api/openstack/compute/shelve.py +++ b/nova/api/openstack/compute/shelve.py @@ -23,10 +23,7 @@ from nova.api.openstack.compute.schemas import shelve as shelve_schemas from nova.api.openstack import wsgi from nova.api import validation from nova.compute import api as compute -from nova.compute import vm_states from nova import exception -from nova.i18n import _ -from nova.network import neutron from nova.policies import shelve as shelve_policies LOG = logging.getLogger(__name__) @@ -36,7 +33,6 @@ class ShelveController(wsgi.Controller): def __init__(self): super(ShelveController, self).__init__() self.compute_api = compute.API() - self.network_api = neutron.API() @wsgi.response(202) @wsgi.expected_errors((404, 403, 409, 400)) @@ -107,17 +103,6 @@ class ShelveController(wsgi.Controller): if support_az and unshelve_dict: new_az = unshelve_dict['availability_zone'] - if ( - instance.vm_state == vm_states.SHELVED_OFFLOADED and - self.network_api.instance_has_extended_resource_request(id) - ): - msg = _( - "The unshelve server operation on a shelve offloaded server " - "with port having extended resource request, like a " - "port with both QoS minimum bandwidth and packet rate " - "policies, is not yet supported.") - raise exc.HTTPBadRequest(explanation=msg) - try: self.compute_api.unshelve(context, instance, new_az=new_az) except (exception.InstanceIsLocked, @@ -128,5 +113,8 @@ class ShelveController(wsgi.Controller): common.raise_http_conflict_for_instance_invalid_state(state_error, 'unshelve', id) - except exception.InvalidRequest as e: + except ( + exception.InvalidRequest, + exception.ExtendedResourceRequestOldCompute, + ) as e: raise exc.HTTPBadRequest(explanation=e.format_message()) |