cli/opcodes: add a --no-runtime-changes migrate opt
authorGuido Trotter <ultrotter@google.com>
Wed, 25 Jan 2012 15:26:22 +0000 (15:26 +0000)
committerGuido Trotter <ultrotter@google.com>
Thu, 26 Jan 2012 16:33:52 +0000 (16:33 +0000)
This will be used for now to avoid ballooning memory at live migration time.

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

lib/cli.py
lib/client/gnt_instance.py
lib/client/gnt_node.py
lib/opcodes.py
man/gnt-instance.rst
man/gnt-node.rst

index 505ced4..7421741 100644 (file)
@@ -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")
index d417c83..67aae31 100644 (file)
@@ -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": (
index 9fff35f..1be466b 100644 (file)
@@ -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)"),
index 16cba8c..8823581 100644 (file)
@@ -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"),
index 59ed6f2..2102452 100644 (file)
@@ -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
index 794fc0a..5a6ef51 100644 (file)
@@ -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.