Merge "Add live migration timeout for clustered instances" into stable/ocata

This commit is contained in:
Jenkins 2017-06-20 08:40:30 +00:00 committed by Gerrit Code Review
commit 1641b53fc2
2 changed files with 24 additions and 2 deletions

View File

@ -15,8 +15,10 @@
"""Management class for cluster live migration VM operations."""
import nova.conf
from os_win import exceptions as os_win_exc
from os_win import utilsfactory
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import excutils
@ -24,6 +26,19 @@ from hyperv.nova import livemigrationops
LOG = logging.getLogger(__name__)
hyperv_opts = [
cfg.IntOpt('instance_live_migration_timeout',
default=300,
min=0,
help='Number of seconds to wait for an instance to be '
'live migrated (Only applies to clustered instances '
'for the moment).'),
]
CONF = nova.conf.CONF
CONF.register_opts(hyperv_opts, 'hyperv')
class ClusterLiveMigrationOps(livemigrationops.LiveMigrationOps):
def __init__(self):
@ -62,7 +77,10 @@ class ClusterLiveMigrationOps(livemigrationops.LiveMigrationOps):
# destination is in the same cluster.
# perform a clustered live migration.
try:
self._clustutils.live_migrate_vm(instance_name, dest)
self._clustutils.live_migrate_vm(
instance_name,
dest,
CONF.hyperv.instance_live_migration_timeout)
except os_win_exc.HyperVVMNotFoundException:
with excutils.save_and_reraise_exception():
LOG.debug("Calling live migration recover_method "

View File

@ -40,6 +40,9 @@ class ClusterLiveMigrationOpsTestCase(test_base.HyperVBaseTestCase):
self.livemigrops._clustutils.vm_exists.return_value, ret)
def test_live_migration_in_cluster(self):
self.flags(instance_live_migration_timeout=mock.sentinel.migr_timeout,
group='hyperv')
mock_instance = fake_instance.fake_instance_obj(self._fake_context)
self.livemigrops._clustutils.vm_exists.return_value = True
post_method = mock.MagicMock()
@ -56,7 +59,8 @@ class ClusterLiveMigrationOpsTestCase(test_base.HyperVBaseTestCase):
clustutils = self.livemigrops._clustutils
clustutils.live_migrate_vm.assert_called_once_with(
mock_instance.name, dest)
mock_instance.name, dest,
mock.sentinel.migr_timeout)
post_method.assert_called_once_with(
self._fake_context, mock_instance, dest,
mock.sentinel.block_migration, mock.sentinel.migrate_data)