Evacuate VMs from Compute node
In preparation phase of the upgrade of a node, evacuate virtual machines from that node to other hosts using live migration. This feature only supported for nodes where live migration is available. Change-Id: I13a20b884aea1e3058a93f5459955b4d2a8a2089 Related-bug: 1523469
This commit is contained in:
parent
9acebae050
commit
fbcf3c2d95
|
@ -17,6 +17,7 @@ class UpgradeHandler(object):
|
|||
def __init__(self, node, env, isolated):
|
||||
self.node = node
|
||||
self.orig_env = self.node.env
|
||||
self.orig_version = self.orig_env.data["fuel_version"]
|
||||
self.env = env
|
||||
self.isolated = isolated
|
||||
|
||||
|
|
|
@ -32,8 +32,11 @@ class ComputeUpgrade(upgrade.UpgradeHandler):
|
|||
if env_util.get_env_provision_method(env) != 'image':
|
||||
self.create_configdrive_partition()
|
||||
disk.update_node_partition_info(self.node.id)
|
||||
self.backup_iscsi_initiator_info()
|
||||
self.preserve_partition()
|
||||
if node_util.is_live_migration_supported(self.node):
|
||||
self.evacuate_host()
|
||||
else:
|
||||
self.backup_iscsi_initiator_info()
|
||||
self.preserve_partition()
|
||||
|
||||
def postdeploy(self):
|
||||
self.restore_iscsi_initiator_info()
|
||||
|
|
|
@ -141,3 +141,24 @@ def test_remove_compute_upgrade_levels(mocker, node, content,
|
|||
expected_content):
|
||||
with _check_upgrade_levels(mocker, node, content, expected_content):
|
||||
node_util.remove_compute_upgrade_levels(node)
|
||||
|
||||
|
||||
NOVA_LIVE_MIGRATION_FLAG = b" live_migration_flag="
|
||||
NOVA_LIVE_MIGRATION_ENABLED = NOVA_LIVE_MIGRATION_FLAG + \
|
||||
b"FLAG1,VIR_MIGRATE_LIVE,FLAG2\n"
|
||||
NOVA_NO_LIVE_MIGRATION_FLAG = b"no_live_migration_flag\n"
|
||||
NOVA_EMPTY = b""
|
||||
|
||||
|
||||
@pytest.mark.parametrize("content,expected_res", [
|
||||
(NOVA_LIVE_MIGRATION_ENABLED, True),
|
||||
(NOVA_LIVE_MIGRATION_FLAG, False),
|
||||
(NOVA_NO_LIVE_MIGRATION_FLAG, False),
|
||||
(NOVA_EMPTY, False),
|
||||
])
|
||||
def test_is_live_migration_supported(mocker, node, content, expected_res):
|
||||
mock_sftp = mocker.patch("octane.util.ssh.sftp")
|
||||
mock_sftp.return_value.open.return_value = io.BytesIO(content)
|
||||
|
||||
res = node_util.is_live_migration_supported(node)
|
||||
assert res == expected_res
|
||||
|
|
|
@ -137,3 +137,13 @@ def remove_compute_upgrade_levels(node):
|
|||
if line.startswith("compute="):
|
||||
continue
|
||||
new.write(line)
|
||||
|
||||
|
||||
def is_live_migration_supported(node):
|
||||
sftp = ssh.sftp(node)
|
||||
with sftp.open('/etc/nova/nova.conf') as config:
|
||||
for line in config:
|
||||
if line.strip().startswith("live_migration_flag") \
|
||||
and "VIR_MIGRATE_LIVE" in line:
|
||||
return True
|
||||
return False
|
||||
|
|
Loading…
Reference in New Issue