Commit 8c0b16f6 authored by Guido Trotter's avatar Guido Trotter
Browse files

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: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent e57602c2
......@@ -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")
......
......@@ -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] <instance>", "Migrate instance to its secondary node"
" (only for mirrored instances)"),
"move": (
......
......@@ -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] <node>",
"Migrate all the primary instance on a node away from it"
" (only for instances of type drbd)"),
......
......@@ -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"),
......
......@@ -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
......
......@@ -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.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment