Commit e290ac5b authored by Hrvoje Ribicic's avatar Hrvoje Ribicic
Browse files

Allow instance disks to be added with --no-wait-for-sync

The patch 3c260845

 fixed a bug where
adding a new disk to an instance with deactivated disks activated the
disk. However, it also introduced some erroneous behaviour, preventing
disks from being added to online instances with --no-wait-for-sync.

In line with the original meaning of the patch, this patch modifies the
check to disallow adding disks to shutdown instances with
--no-wait-for-sync, and allow doing so for online instances.
Signed-off-by: default avatarHrvoje Ribicic <riba@google.com>
Reviewed-by: default avatarKlaus Aehlig <aehlig@google.com>
parent e4b27f2d
......@@ -2819,11 +2819,11 @@ class LUInstanceSetParams(LogicalUnit):
constants.DT_EXT),
errors.ECODE_INVAL)
if not self.op.wait_for_sync and self.instance.disks_active:
if not self.op.wait_for_sync and not self.instance.disks_active:
for mod in self.diskmod:
if mod[0] == constants.DDM_ADD:
raise errors.OpPrereqError("Can't add a disk to an instance with"
" activated disks and"
" deactivated disks and"
" --no-wait-for-sync given.",
errors.ECODE_INVAL)
......
......@@ -2159,9 +2159,8 @@ class TestLUInstanceSetParams(CmdlibTestCase):
constants.IDISK_SIZE: 1024
}]],
wait_for_sync=False)
self.ExecOpCodeExpectOpPrereqError(
op, "Can't add a disk to an instance with activated disks"
" and --no-wait-for-sync given.")
self.ExecOpCode(op)
self.assertFalse(self.rpc.call_blockdev_shutdown.called)
def testAddDiskDownInstance(self):
op = self.CopyOpCode(self.op,
......@@ -2173,6 +2172,17 @@ class TestLUInstanceSetParams(CmdlibTestCase):
self.assertTrue(self.rpc.call_blockdev_shutdown.called)
def testAddDiskDownInstanceNoWaitForSync(self):
op = self.CopyOpCode(self.op,
disks=[[constants.DDM_ADD, -1,
{
constants.IDISK_SIZE: 1024
}]],
wait_for_sync=False)
self.ExecOpCodeExpectOpPrereqError(
op, "Can't add a disk to an instance with deactivated disks"
" and --no-wait-for-sync given.")
def testAddDiskRunningInstance(self):
op = self.CopyOpCode(self.running_op,
disks=[[constants.DDM_ADD, -1,
......
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