Add missing ComputeHostNotFound exception in live-migration
Commit c824982e6a
did not update
expected exceptions. Therefore we end up with 500 internal server
error when triggering targeted live migration to non-existing compute
node. This patch adds ComputeHostNotFound to expected exception list
in both, conductor and API.
Change-Id: If515a90217a8e329d932dcacb357b78081c505c1
Related-bug: 1538837
This commit is contained in:
parent
d0905df10a
commit
89bf80202b
|
@ -102,6 +102,7 @@ class MigrateServerController(wsgi.Controller):
|
|||
raise exc.HTTPNotFound(explanation=e.format_message())
|
||||
except (exception.NoValidHost,
|
||||
exception.ComputeServiceUnavailable,
|
||||
exception.ComputeHostNotFound,
|
||||
exception.InvalidHypervisorType,
|
||||
exception.InvalidCPUInfo,
|
||||
exception.UnableToMigrateToSelf,
|
||||
|
|
|
@ -166,6 +166,7 @@ class ComputeTaskManager(base.Base):
|
|||
@messaging.expected_exceptions(
|
||||
exception.NoValidHost,
|
||||
exception.ComputeServiceUnavailable,
|
||||
exception.ComputeHostNotFound,
|
||||
exception.InvalidHypervisorType,
|
||||
exception.InvalidCPUInfo,
|
||||
exception.UnableToMigrateToSelf,
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
import mock
|
||||
from oslo_utils import versionutils
|
||||
|
||||
from nova import exception
|
||||
from nova import objects
|
||||
from nova.tests.functional.api_sample_tests import test_servers
|
||||
|
||||
|
@ -75,6 +76,19 @@ class MigrateServerSamplesJsonTest(test_servers.ServersSampleBase):
|
|||
# Get api samples to server live migrate request.
|
||||
self._check_post_live_migrate_server()
|
||||
|
||||
def test_live_migrate_compute_host_not_found(self):
|
||||
hostname = 'dummy-host'
|
||||
|
||||
def fake_execute(_self):
|
||||
raise exception.ComputeHostNotFound(host=hostname)
|
||||
self.stub_out('nova.conductor.tasks.live_migrate.'
|
||||
'LiveMigrationTask._execute', fake_execute)
|
||||
|
||||
response = self._do_post('servers/%s/action' % self.uuid,
|
||||
'live-migrate-server',
|
||||
{'hostname': hostname})
|
||||
self.assertEqual(400, response.status_code)
|
||||
|
||||
|
||||
class MigrateServerSamplesJsonTestV225(MigrateServerSamplesJsonTest):
|
||||
sample_dir = "os-migrate-server"
|
||||
|
@ -113,3 +127,17 @@ class MigrateServerSamplesJsonTestV230(MigrateServerSamplesJsonTest):
|
|||
self._check_post_live_migrate_server(
|
||||
req_subs={'hostname': self.compute.host,
|
||||
'force': 'True'})
|
||||
|
||||
def test_live_migrate_compute_host_not_found(self):
|
||||
hostname = 'dummy-host'
|
||||
|
||||
def fake_execute(_self):
|
||||
raise exception.ComputeHostNotFound(host=hostname)
|
||||
self.stub_out('nova.conductor.tasks.live_migrate.'
|
||||
'LiveMigrationTask._execute', fake_execute)
|
||||
|
||||
response = self._do_post('servers/%s/action' % self.uuid,
|
||||
'live-migrate-server',
|
||||
{'hostname': hostname,
|
||||
'force': 'False'})
|
||||
self.assertEqual(400, response.status_code)
|
||||
|
|
|
@ -217,6 +217,10 @@ class MigrateServerTestsV21(admin_only_action_common.CommonTests):
|
|||
self._test_migrate_live_failed_with_exception(
|
||||
exception.ComputeServiceUnavailable(host='host'))
|
||||
|
||||
def test_migrate_live_compute_service_not_found(self):
|
||||
self._test_migrate_live_failed_with_exception(
|
||||
exception.ComputeHostNotFound(host='host'))
|
||||
|
||||
def test_migrate_live_invalid_hypervisor_type(self):
|
||||
self._test_migrate_live_failed_with_exception(
|
||||
exception.InvalidHypervisorType())
|
||||
|
@ -375,6 +379,9 @@ class MigrateServerTestsV234(MigrateServerTestsV230):
|
|||
def test_migrate_live_compute_service_unavailable(self):
|
||||
pass
|
||||
|
||||
def test_migrate_live_compute_service_not_found(self):
|
||||
pass
|
||||
|
||||
def test_migrate_live_invalid_hypervisor_type(self):
|
||||
pass
|
||||
|
||||
|
|
|
@ -1417,7 +1417,8 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
|
|||
exc.InvalidCPUInfo(reason='dummy'),
|
||||
exc.UnableToMigrateToSelf(instance_id='dummy', host='dummy'),
|
||||
exc.InvalidLocalStorage(path='dummy', reason='dummy'),
|
||||
exc.MigrationSchedulerRPCError(reason='dummy')]
|
||||
exc.MigrationSchedulerRPCError(reason='dummy'),
|
||||
exc.ComputeHostNotFound(host='dummy')]
|
||||
for ex in exs:
|
||||
self._test_migrate_server_deals_with_expected_exceptions(ex)
|
||||
|
||||
|
|
Loading…
Reference in New Issue