Merge "Add service version check for live migrate with qos"

This commit is contained in:
Zuul
2020-03-24 00:28:47 +00:00
committed by Gerrit Code Review
2 changed files with 55 additions and 0 deletions

View File

@@ -128,6 +128,22 @@ class MigrateServerController(wsgi.Controller):
instance = common.get_instance(self.compute_api, context, id,
expected_attrs=['numa_topology'])
# 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 os-migrateLive 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 os-migrateLive 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.live_migrate(context, instance, block_migration,
disk_over_commit, host, force,

View File

@@ -6005,6 +6005,44 @@ class UnsupportedPortResourceRequestBasedSchedulingTest(
"until microversion 2.72.",
six.text_type(ex))
def test_live_migrate_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'])
post = {
'os-migrateLive': {
'host': None,
'block_migration': False,
}
}
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'], post)
self.assertEqual(400, ex.response.status_code)
self.assertIn(
"The os-migrateLive 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 os-migrateLive 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(
@@ -6094,6 +6132,7 @@ 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': '@'
})