Commit 6605411d authored by Iustin Pop's avatar Iustin Pop
Browse files

grow-disk: wait until resync is completed

The patch adds a new ‘--no-wait-for-sync’ parameter to grow-disk similar
to the one in instance add, and changes the default to wait.

This is cleaner as at the moment when the command returns, we either
have a fully synced disk or there is an error.

This is a forward-port of rev 1183 on the 1.2 branch.

Reviewed-by: ultrotter
parent 659712c8
......@@ -4254,7 +4254,7 @@ class LUGrowDisk(LogicalUnit):
"""
HPATH = "disk-grow"
HTYPE = constants.HTYPE_INSTANCE
_OP_REQP = ["instance_name", "disk", "amount"]
_OP_REQP = ["instance_name", "disk", "amount", "wait_for_sync"]
REQ_BGL = False
def ExpandNames(self):
......@@ -4337,7 +4337,11 @@ class LUGrowDisk(LogicalUnit):
(node, result[1]))
disk.RecordGrow(self.op.amount)
self.cfg.Update(instance)
return
if self.op.wait_for_sync:
disk_abort = not _WaitForSync(self.cfg, instance, self.proc)
if disk_abort:
logger.Error("Warning: disk sync-ing has not returned a good status.\n"
" Please check the instance.")
class LUQueryInstanceData(NoHooksLU):
......
......@@ -432,7 +432,7 @@ class OpGrowDisk(OpCode):
"""Grow a disk of an instance."""
OP_ID = "OP_INSTANCE_GROW_DISK"
OP_DSC_FIELD = "instance_name"
__slots__ = ["instance_name", "disk", "amount"]
__slots__ = ["instance_name", "disk", "amount", "wait_for_sync"]
# OS opcodes
......
......@@ -1176,6 +1176,7 @@ node1.example.com:sdb:/dev/drbd1
<title>GROW-DISK</title>
<cmdsynopsis>
<command>grow-disk</command>
<arg>--no-wait-for-sync</arg>
<arg choice="req"><replaceable>instance</replaceable></arg>
<arg choice="req"><replaceable>disk</replaceable></arg>
<arg choice="req"><replaceable>amount</replaceable></arg>
......@@ -1232,7 +1233,14 @@ node1.example.com:sdb:/dev/drbd1
create problems (except for unused space).
</para>
<para>Example (increasing sda for instance1 with 16GiB):
<para>
If you do not want gnt-instance to wait for the new disk
region to be synced, use the
<option>--no-wait-for-sync</option> option.
</para>
<para>Example (increase sda for instance1 by 16GiB):
<screen>
# gnt-instance grow-disk instance1.example.com sda 16g
</screen>
......
......@@ -443,7 +443,8 @@ def GrowDisk(opts, args):
instance = args[0]
disk = args[1]
amount = utils.ParseUnit(args[2])
op = opcodes.OpGrowDisk(instance_name=instance, disk=disk, amount=amount)
op = opcodes.OpGrowDisk(instance_name=instance, disk=disk, amount=amount,
wait_for_sync=opts.wait_for_sync)
SubmitOrSend(op, opts)
return 0
......@@ -1069,7 +1070,13 @@ commands = {
'deactivate-disks': (DeactivateDisks, ARGS_ONE, [DEBUG_OPT, SUBMIT_OPT],
"<instance>",
"Deactivate an instance's disks"),
'grow-disk': (GrowDisk, ARGS_FIXED(3), [DEBUG_OPT, SUBMIT_OPT],
'grow-disk': (GrowDisk, ARGS_FIXED(3),
[DEBUG_OPT, SUBMIT_OPT,
make_option("--no-wait-for-sync",
dest="wait_for_sync", default=True,
action="store_false",
help="Don't wait for sync (DANGEROUS!)"),
],
"<instance> <disk> <size>", "Grow an instance's disk"),
'list-tags': (ListTags, ARGS_ONE, [DEBUG_OPT],
"<instance_name>", "List the tags of the given instance"),
......
......@@ -288,7 +288,7 @@ class Burner(object):
growth = getattr(self.opts, '%s_growth' % disk)
if growth > 0:
op = opcodes.OpGrowDisk(instance_name=instance, disk=disk,
amount=growth)
amount=growth, wait_for_sync=True)
Log("- Increase %s's %s disk by %s MB" % (instance, disk, growth))
self.ExecOp(op)
......
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