summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPawel Koniszewski <pawel.koniszewski@intel.com>2016-07-29 10:17:26 +0200
committerPawel Koniszewski <pawel.koniszewski@intel.com>2016-07-29 10:17:26 +0200
commit89bf80202b2e3501a4673bc527e7e17cd0b116be (patch)
tree1c8737e42c40d937bbfd7b18d41d5f177528330e
parentd0905df10a48212950c0854597a2df923e6ddd0c (diff)
downloadnova-89bf80202b2e3501a4673bc527e7e17cd0b116be.tar.gz
Add missing ComputeHostNotFound exception in live-migration
Commit c824982e6a3d6660697e503f7236377cc8202d41 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
-rw-r--r--nova/api/openstack/compute/migrate_server.py1
-rw-r--r--nova/conductor/manager.py1
-rw-r--r--nova/tests/functional/api_sample_tests/test_migrate_server.py28
-rw-r--r--nova/tests/unit/api/openstack/compute/test_migrate_server.py7
-rw-r--r--nova/tests/unit/conductor/test_conductor.py3
5 files changed, 39 insertions, 1 deletions
diff --git a/nova/api/openstack/compute/migrate_server.py b/nova/api/openstack/compute/migrate_server.py
index 94e68260a3..89983f0b85 100644
--- a/nova/api/openstack/compute/migrate_server.py
+++ b/nova/api/openstack/compute/migrate_server.py
@@ -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,
diff --git a/nova/conductor/manager.py b/nova/conductor/manager.py
index b01c69833e..e24189d4e9 100644
--- a/nova/conductor/manager.py
+++ b/nova/conductor/manager.py
@@ -166,6 +166,7 @@ class ComputeTaskManager(base.Base):
@messaging.expected_exceptions(
exception.NoValidHost,
exception.ComputeServiceUnavailable,
+ exception.ComputeHostNotFound,
exception.InvalidHypervisorType,
exception.InvalidCPUInfo,
exception.UnableToMigrateToSelf,
diff --git a/nova/tests/functional/api_sample_tests/test_migrate_server.py b/nova/tests/functional/api_sample_tests/test_migrate_server.py
index 68c0645aae..0d18b7e80f 100644
--- a/nova/tests/functional/api_sample_tests/test_migrate_server.py
+++ b/nova/tests/functional/api_sample_tests/test_migrate_server.py
@@ -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)
diff --git a/nova/tests/unit/api/openstack/compute/test_migrate_server.py b/nova/tests/unit/api/openstack/compute/test_migrate_server.py
index a21ba78586..26c39cf3da 100644
--- a/nova/tests/unit/api/openstack/compute/test_migrate_server.py
+++ b/nova/tests/unit/api/openstack/compute/test_migrate_server.py
@@ -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
diff --git a/nova/tests/unit/conductor/test_conductor.py b/nova/tests/unit/conductor/test_conductor.py
index 0de2ca277c..e3c0c6fb01 100644
--- a/nova/tests/unit/conductor/test_conductor.py
+++ b/nova/tests/unit/conductor/test_conductor.py
@@ -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)