From 3d9c01b2d37e0ba5e4ea21a0697fdd83ace3d1ab Mon Sep 17 00:00:00 2001 From: Artom Lifshitz Date: Wed, 2 Sep 2015 16:47:44 +0000 Subject: [PATCH] Option to specify max servers for live evacuate The current behaviour of live evacuate is to naively request that all servers on the hypervisor be evacuated. The more VMs are migrated simultaneously, the more bandwidth is required. Once a certain number of migrating VMs is reached, there is not enough bandwidth to cope with the rate at which they dirty their memory. The migrations will thus never complete. The correct solution to this would be a whole lot of work on the Nova side. As a stopgap measure, this patch introduces a --max-servers option to host-evacuate-live. With this option, the user can control the number of VMs that are live-migrated at the same time, thus allowing the user to avoid the dirty memory scenario described above. Change-Id: I17bad5f3253d6657fc1e6610159fc8e3921e6ea4 --- novaclient/tests/unit/v2/test_shell.py | 8 ++++++++ novaclient/v2/contrib/host_evacuate_live.py | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/novaclient/tests/unit/v2/test_shell.py b/novaclient/tests/unit/v2/test_shell.py index cfd81fccb..06224ed31 100644 --- a/novaclient/tests/unit/v2/test_shell.py +++ b/novaclient/tests/unit/v2/test_shell.py @@ -1583,6 +1583,14 @@ class ShellTest(utils.TestCase): self.assert_called('POST', '/servers/uuid3/action', body, pos=3) self.assert_called('POST', '/servers/uuid4/action', body, pos=4) + def test_host_evacuate_list_with_max_servers(self): + self.run_command('host-evacuate-live --max-servers 1 hyper') + self.assert_called('GET', '/os-hypervisors/hyper/servers', pos=0) + body = {'os-migrateLive': {'host': None, + 'block_migration': False, + 'disk_over_commit': False}} + self.assert_called('POST', '/servers/uuid1/action', body, pos=1) + def test_reset_state(self): self.run_command('reset-state sample-server') self.assert_called('POST', '/servers/1234/action', diff --git a/novaclient/v2/contrib/host_evacuate_live.py b/novaclient/v2/contrib/host_evacuate_live.py index 276fb2f70..f91599bbd 100644 --- a/novaclient/v2/contrib/host_evacuate_live.py +++ b/novaclient/v2/contrib/host_evacuate_live.py @@ -54,15 +54,25 @@ def _server_live_migrate(cs, server, args): action='store_true', default=False, help=_('Enable disk overcommit.')) +@cliutils.arg( + '--max-servers', + type=int, + dest='max_servers', + metavar='', + help='Maximum number of servers to live migrate simultaneously') def do_host_evacuate_live(cs, args): """Live migrate all instances of the specified host to other available hosts. """ hypervisors = cs.hypervisors.search(args.host, servers=True) response = [] + migrating = 0 for hyper in hypervisors: for server in getattr(hyper, 'servers', []): response.append(_server_live_migrate(cs, server, args)) + migrating = migrating + 1 + if args.max_servers is not None and migrating >= args.max_servers: + break utils.print_list(response, ["Server UUID", "Live Migration Accepted", "Error Message"])