Merge "Add service version check for evacuate with qos"
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
# under the License.
|
||||
|
||||
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import strutils
|
||||
from webob import exc
|
||||
|
||||
@@ -31,6 +32,8 @@ from nova import utils
|
||||
|
||||
CONF = nova.conf.CONF
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class EvacuateController(wsgi.Controller):
|
||||
def __init__(self):
|
||||
@@ -117,6 +120,22 @@ class EvacuateController(wsgi.Controller):
|
||||
msg = _("The target host can't be the same one.")
|
||||
raise exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
# We could potentially move this check to conductor and avoid the
|
||||
# extra API call to neutron when we support move operations with ports
|
||||
# having resource requests.
|
||||
if (common.instance_has_port_with_resource_request(
|
||||
instance.uuid, self.network_api) and not
|
||||
common.supports_port_resource_request_during_move()):
|
||||
LOG.warning("The evacuate action on a server with ports "
|
||||
"having resource requests, like a port with a QoS "
|
||||
"minimum bandwidth policy, is not supported until "
|
||||
"every nova-compute is upgraded to Ussuri")
|
||||
msg = _("The evacuate action on a server with ports having "
|
||||
"resource requests, like a port with a QoS minimum "
|
||||
"bandwidth policy, is not supported by this cluster right "
|
||||
"now")
|
||||
raise exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
try:
|
||||
self.compute_api.evacuate(context, instance, host,
|
||||
on_shared_storage, password, force)
|
||||
|
||||
@@ -6043,6 +6043,38 @@ class UnsupportedPortResourceRequestBasedSchedulingTest(
|
||||
"not supported until every nova-compute is upgraded to Ussuri",
|
||||
self.stdlog.logger.output)
|
||||
|
||||
def test_evacuate_server_with_port_resource_request_old_version(
|
||||
self):
|
||||
server = self._create_server(
|
||||
flavor=self.flavor,
|
||||
networks=[{'port': self.neutron.port_1['id']}])
|
||||
self._wait_for_state_change(server, 'ACTIVE')
|
||||
|
||||
# We need to simulate that the above server has a port that has
|
||||
# resource request; we cannot boot with such a port but legacy servers
|
||||
# can exist with such a port.
|
||||
self._add_resource_request_to_a_bound_port(self.neutron.port_1['id'])
|
||||
|
||||
with mock.patch(
|
||||
"nova.objects.service.get_minimum_version_all_cells",
|
||||
return_value=48,
|
||||
):
|
||||
ex = self.assertRaises(
|
||||
client.OpenStackApiException,
|
||||
self.api.post_server_action, server['id'], {'evacuate': {}})
|
||||
|
||||
self.assertEqual(400, ex.response.status_code)
|
||||
self.assertIn(
|
||||
"The evacuate action on a server with ports having resource "
|
||||
"requests, like a port with a QoS minimum bandwidth policy, is "
|
||||
"not supported by this cluster right now",
|
||||
six.text_type(ex))
|
||||
self.assertIn(
|
||||
"The evacuate action on a server with ports having resource "
|
||||
"requests, like a port with a QoS minimum bandwidth policy, is "
|
||||
"not supported until every nova-compute is upgraded to Ussuri",
|
||||
self.stdlog.logger.output)
|
||||
|
||||
def test_unshelve_offloaded_server_with_port_resource_request_old_version(
|
||||
self):
|
||||
server = self._create_server(
|
||||
@@ -6132,7 +6164,8 @@ class NonAdminUnsupportedPortResourceRequestBasedSchedulingTest(
|
||||
'os_compute_api:os-attach-interfaces:create': '@',
|
||||
'os_compute_api:os-shelve:shelve': '@',
|
||||
'os_compute_api:os-shelve:unshelve': '@',
|
||||
'os_compute_api:os-migrate-server:migrate_live': '@'
|
||||
'os_compute_api:os-migrate-server:migrate_live': '@',
|
||||
'os_compute_api:os-evacuate': '@',
|
||||
})
|
||||
|
||||
|
||||
|
||||
@@ -47,6 +47,10 @@ class EvacuatePolicyTest(base.BasePolicyTest):
|
||||
user_id = self.user_req.environ['nova.context'].user_id
|
||||
self.stub_out('nova.compute.api.HostAPI.service_get_by_compute_host',
|
||||
fake_service_get_by_compute_host)
|
||||
self.stub_out(
|
||||
'nova.api.openstack.common.'
|
||||
'instance_has_port_with_resource_request',
|
||||
lambda *args, **kwargs: False)
|
||||
self.mock_get = self.useFixture(
|
||||
fixtures.MockPatch('nova.compute.api.API.get')).mock
|
||||
uuid = uuids.fake_id
|
||||
|
||||
Reference in New Issue
Block a user