From: Guido Trotter Date: Wed, 25 Jan 2012 15:26:22 +0000 (+0000) Subject: cli/opcodes: add a --no-runtime-changes migrate opt X-Git-Tag: v2.6.0beta1~333 X-Git-Url: https://code.grnet.gr/git/ganeti-local/commitdiff_plain/8c0b16f6983e778ef350d358808bb1773f9fa587 cli/opcodes: add a --no-runtime-changes migrate opt This will be used for now to avoid ballooning memory at live migration time. Signed-off-by: Guido Trotter Reviewed-by: Michael Hanselmann --- diff --git a/lib/cli.py b/lib/cli.py index 505ced4..7421741 100644 --- a/lib/cli.py +++ b/lib/cli.py @@ -132,6 +132,7 @@ __all__ = [ "NONICS_OPT", "NONLIVE_OPT", "NONPLUS1_OPT", + "NORUNTIME_CHGS_OPT", "NOSHUTDOWN_OPT", "NOSTART_OPT", "NOSSH_KEYCHECK_OPT", @@ -771,6 +772,11 @@ NO_INSTALL_OPT = cli_option("--no-install", dest="no_install", help="Do not install the OS (will" " enable no-start)") +NORUNTIME_CHGS_OPT = cli_option("--no-runtime-changes", + dest="allow_runtime_chgs", + default=True, action="store_false", + help="Don't allow runtime changes") + BACKEND_OPT = cli_option("-B", "--backend-parameters", dest="beparams", type="keyval", default={}, help="Backend parameters") diff --git a/lib/client/gnt_instance.py b/lib/client/gnt_instance.py index d417c83..67aae31 100644 --- a/lib/client/gnt_instance.py +++ b/lib/client/gnt_instance.py @@ -865,6 +865,7 @@ def MigrateInstance(opts, args): cleanup=opts.cleanup, iallocator=iallocator, target_node=target_node, allow_failover=opts.allow_failover, + allow_runtime_changes=opts.allow_runtime_chgs, ignore_ipolicy=opts.ignore_ipolicy) SubmitOpCode(op, cl=cl, opts=opts) return 0 @@ -1469,7 +1470,7 @@ commands = { MigrateInstance, ARGS_ONE_INSTANCE, [FORCE_OPT, NONLIVE_OPT, MIGRATION_MODE_OPT, CLEANUP_OPT, DRY_RUN_OPT, PRIORITY_OPT, DST_NODE_OPT, IALLOCATOR_OPT, ALLOW_FAILOVER_OPT, - IGNORE_IPOLICY_OPT], + IGNORE_IPOLICY_OPT, NORUNTIME_CHGS_OPT], "[-f] ", "Migrate instance to its secondary node" " (only for mirrored instances)"), "move": ( diff --git a/lib/client/gnt_node.py b/lib/client/gnt_node.py index 9fff35f..1be466b 100644 --- a/lib/client/gnt_node.py +++ b/lib/client/gnt_node.py @@ -427,6 +427,7 @@ def MigrateNode(opts, args): op = opcodes.OpNodeMigrate(node_name=args[0], mode=mode, iallocator=opts.iallocator, target_node=opts.dst_node, + allow_runtime_changes=opts.allow_runtime_chgs, ignore_ipolicy=opts.ignore_ipolicy) result = SubmitOpCode(op, cl=cl, opts=opts) @@ -900,7 +901,8 @@ commands = { "migrate": ( MigrateNode, ARGS_ONE_NODE, [FORCE_OPT, NONLIVE_OPT, MIGRATION_MODE_OPT, DST_NODE_OPT, - IALLOCATOR_OPT, PRIORITY_OPT, IGNORE_IPOLICY_OPT], + IALLOCATOR_OPT, PRIORITY_OPT, IGNORE_IPOLICY_OPT, + NORUNTIME_CHGS_OPT], "[-f] ", "Migrate all the primary instance on a node away from it" " (only for instances of type drbd)"), diff --git a/lib/opcodes.py b/lib/opcodes.py index 16cba8c..8823581 100644 --- a/lib/opcodes.py +++ b/lib/opcodes.py @@ -156,6 +156,11 @@ _PDiskState = ("disk_state", None, ht.TMaybeDict, "Set disk states") _PIgnoreIpolicy = ("ignore_ipolicy", False, ht.TBool, "Whether to ignore ipolicy violations") +# Allow runtime changes while migrating +_PAllowRuntimeChgs = ("allow_runtime_changes", True, ht.TBool, + "Allow runtime changes (eg. memory ballooning)") + + #: OP_ID conversion regular expression _OPID_RE = re.compile("([a-z])([A-Z])") @@ -1052,6 +1057,7 @@ class OpNodeMigrate(OpCode): _PMigrationMode, _PMigrationLive, _PMigrationTargetNode, + _PAllowRuntimeChgs, _PIgnoreIpolicy, ("iallocator", None, ht.TMaybeString, "Iallocator for deciding the target node for shared-storage instances"), @@ -1268,6 +1274,7 @@ class OpInstanceMigrate(OpCode): _PMigrationMode, _PMigrationLive, _PMigrationTargetNode, + _PAllowRuntimeChgs, _PIgnoreIpolicy, ("cleanup", False, ht.TBool, "Whether a previously failed migration should be cleaned up"), diff --git a/man/gnt-instance.rst b/man/gnt-instance.rst index 59ed6f2..2102452 100644 --- a/man/gnt-instance.rst +++ b/man/gnt-instance.rst @@ -1442,7 +1442,8 @@ MIGRATE **migrate** [-f] {--cleanup} {*instance*} **migrate** [-f] [--allow-failover] [--non-live] -[--migration-mode=live\|non-live] [--ignore-ipolicy] {*instance*} +[--migration-mode=live\|non-live] [--ignore-ipolicy] +[--no-runtime-changes] {*instance*} Migrate will move the instance to its secondary node without shutdown. It only works for instances having the drbd8 disk template @@ -1481,6 +1482,10 @@ during execution. If a migration fails during execution it still fails. If ``--ignore-ipolicy`` is given any instance policy violations occuring during this operation are ignored. +The ``--no-runtime-changes`` option forbids migrate to alter an +instance's runtime before migrating it (eg. ballooning an instance +down because the target node doesn't have enough available memory). + Example (and expected output):: # gnt-instance migrate instance1 diff --git a/man/gnt-node.rst b/man/gnt-node.rst index 794fc0a..5a6ef51 100644 --- a/man/gnt-node.rst +++ b/man/gnt-node.rst @@ -252,8 +252,8 @@ primary to their secondary nodes. This works only for instances having a drbd disk template. As for the **gnt-instance migrate** command, the options -``--no-live`` and ``--migration-mode`` can be given to influence -the migration type. +``--no-live``, ``--migration-mode`` and ``--no-runtime-changes`` +can be given to influence the migration type. If ``--ignore-ipolicy`` is given any instance policy violations occuring during this operation are ignored.