Add live migration timeout for clustered instances

os-win now allows setting a timeout when migrating clustered
instances. When that timeout is hit, pending migrations will be
canceled.

For the moment, we're only going to use this timeout value when
live migrating clustered instances.

The default timeout is 300s, adjustable through a config option.

Conflicts:
	hyperv/nova/conf.py

NOTE(claudiub): the config options have been refactored on master.

Change-Id: I21a7a8edd763f0203b58dc58fb30b7a495ec04cd
(cherry picked from commit 067f602612)
(cherry picked from commit 920138c341)
This commit is contained in:
Lucian Petrut 2017-03-21 15:00:25 +02:00 committed by Claudiu Belu
parent 3705a2b277
commit 7669cfc4eb
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)