diff --git a/nova/conductor/tasks/live_migrate.py b/nova/conductor/tasks/live_migrate.py index 1bc83af15cd4..13d2344d02f9 100644 --- a/nova/conductor/tasks/live_migrate.py +++ b/nova/conductor/tasks/live_migrate.py @@ -12,6 +12,7 @@ from oslo_config import cfg from oslo_log import log as logging +import oslo_messaging as messaging from nova.compute import power_state from nova.conductor.tasks import base @@ -141,9 +142,14 @@ class LiveMigrationTask(base.TaskBase): raise exception.DestinationHypervisorTooOld() def _call_livem_checks_on_host(self, destination): - self.migrate_data = self.compute_rpcapi.\ - check_can_live_migrate_destination(self.context, self.instance, - destination, self.block_migration, self.disk_over_commit) + try: + self.migrate_data = self.compute_rpcapi.\ + check_can_live_migrate_destination(self.context, self.instance, + destination, self.block_migration, self.disk_over_commit) + except messaging.MessagingTimeout: + msg = _("Timeout while checking if we can live migrate to host: " + "%s") % destination + raise exception.MigrationPreCheckError(msg) def _find_destination(self): # TODO(johngarbutt) this retry loop should be shared diff --git a/nova/tests/unit/conductor/tasks/test_live_migrate.py b/nova/tests/unit/conductor/tasks/test_live_migrate.py index cd4dc0494954..ca49966b74b9 100644 --- a/nova/tests/unit/conductor/tasks/test_live_migrate.py +++ b/nova/tests/unit/conductor/tasks/test_live_migrate.py @@ -12,6 +12,7 @@ import mock from mox3 import mox +import oslo_messaging as messaging from nova.compute import power_state from nova.compute import rpcapi as compute_rpcapi @@ -445,3 +446,10 @@ class LiveMigrationTaskTestCase(test.NoDBTestCase): self.mox.ReplayAll() self.assertRaises(exception.NoValidHost, self.task._find_destination) + + def test_call_livem_checks_on_host(self): + with mock.patch.object(self.task.compute_rpcapi, + 'check_can_live_migrate_destination', + side_effect=messaging.MessagingTimeout): + self.assertRaises(exception.MigrationPreCheckError, + self.task._call_livem_checks_on_host, {})