Commit b4ec07f8 authored by Iustin Pop's avatar Iustin Pop
Browse files

Implement --ignore-size in activate-disks



This patch modified OpActivateDisks, LUActivateDisks and gnt-instance
activate-disks to support and pass this option to
_AssembleInstanceDisks.

The patch is quite trivial I think; there should be no issues from it
except if used when not needed.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent e3443b36
......@@ -2592,12 +2592,16 @@ class LUActivateInstanceDisks(NoHooksLU):
assert self.instance is not None, \
"Cannot retrieve locked instance %s" % self.op.instance_name
_CheckNodeOnline(self, self.instance.primary_node)
if not hasattr(self.op, "ignore_size"):
self.op.ignore_size = False
def Exec(self, feedback_fn):
"""Activate the disks.
"""
disks_ok, disks_info = _AssembleInstanceDisks(self, self.instance)
disks_ok, disks_info = \
_AssembleInstanceDisks(self, self.instance,
ignore_size=self.op.ignore_size)
if not disks_ok:
raise errors.OpExecError("Cannot activate block devices")
......
......@@ -438,7 +438,7 @@ class OpActivateInstanceDisks(OpCode):
"""Activate an instance's disks."""
OP_ID = "OP_INSTANCE_ACTIVATE_DISKS"
OP_DSC_FIELD = "instance_name"
__slots__ = ["instance_name"]
__slots__ = ["instance_name", "ignore_size"]
class OpDeactivateInstanceDisks(OpCode):
......
......@@ -1657,6 +1657,7 @@ instance5: 11225
<cmdsynopsis>
<command>activate-disks</command>
<arg>--submit</arg>
<arg>--ignore-size</arg>
<arg choice="req"><replaceable>instance</replaceable></arg>
</cmdsynopsis>
<para>
......@@ -1685,6 +1686,16 @@ node1.example.com:disk/1:/dev/drbd1
<command>gnt-job info</command>.
</para>
<para>
The <option>--ignore-size</option> option can be used to
activate disks ignoring the currently configured size in
Ganeti. This can be used in cases where the configuration
has gotten out of sync with the real-world (e.g. after a
partially-failed grow-disk operation or due to rounding in
LVM devices). This should not be used in normal cases, but
only when activate-disks fails without it.
</para>
<para>
Note that it is safe to run this command while the instance
is already running.
......
......@@ -609,7 +609,8 @@ def ActivateDisks(opts, args):
"""
instance_name = args[0]
op = opcodes.OpActivateInstanceDisks(instance_name=instance_name)
op = opcodes.OpActivateInstanceDisks(instance_name=instance_name,
ignore_size=opts.ignore_size)
disks_info = SubmitOrSend(op, opts)
for host, iname, nname in disks_info:
ToStdout("%s:%s:%s", host, iname, nname)
......@@ -1482,7 +1483,14 @@ commands = {
SUBMIT_OPT,
],
"<instance>", "Reboots an instance"),
'activate-disks': (ActivateDisks, ARGS_ONE, [DEBUG_OPT, SUBMIT_OPT],
'activate-disks': (ActivateDisks, ARGS_ONE,
[DEBUG_OPT, SUBMIT_OPT,
make_option("--ignore-size", dest="ignore_size",
default=False, action="store_true",
help="Ignore current recorded size"
" (useful for forcing activation when"
" the recorded size is wrong)"),
],
"<instance>",
"Activate an instance's disks"),
'deactivate-disks': (DeactivateDisks, ARGS_ONE, [DEBUG_OPT, SUBMIT_OPT],
......
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