Commit aa112e9f authored by Thomas Thrainer's avatar Thomas Thrainer

Add --no-locks option to gnt-debug delay

Add the possibility to don't acquire locks during `gnt-debug delay`.
This allows to run many delay jobs in parallel instead of having
them run sequentially.
Signed-off-by: default avatarThomas Thrainer <thomasth@google.com>
Reviewed-by: default avatarHelga Velroyen <helgav@google.com>
Reviewed-by: default avatarPetr Pudlak <pudlak@google.com>
parent c374ceab
......@@ -64,7 +64,8 @@ def Delay(opts, args):
op = opcodes.OpTestDelay(duration=delay,
on_master=opts.on_master,
on_nodes=opts.on_nodes,
repeat=opts.repeat)
repeat=opts.repeat,
no_locks=opts.no_locks)
SubmitOrSend(op, opts)
return 0
......@@ -631,6 +632,9 @@ commands = {
action="append", help="Select nodes to sleep on"),
cli_option("-r", "--repeat", type="int", default="0", dest="repeat",
help="Number of times to repeat the sleep"),
cli_option("-l", "--no-locks", default=False, dest="no_locks",
action="store_true",
help="Don't take locks while performing the delay"),
DRY_RUN_OPT, PRIORITY_OPT] + SUBMIT_OPTS,
"[opts...] <duration>", "Executes a TestDelay OpCode"),
"submit-job": (
......
......@@ -54,7 +54,7 @@ class LUTestDelay(NoHooksLU):
"""
self.needed_locks = {}
if self.op.on_nodes or self.op.on_master:
if not self.op.no_locks and (self.op.on_nodes or self.op.on_master):
self.needed_locks[locking.LEVEL_NODE] = []
if self.op.on_nodes:
......@@ -63,9 +63,10 @@ class LUTestDelay(NoHooksLU):
# more information.
(self.op.on_node_uuids, self.op.on_nodes) = \
GetWantedNodes(self, self.op.on_nodes)
self.needed_locks[locking.LEVEL_NODE].extend(self.op.on_node_uuids)
if not self.op.no_locks:
self.needed_locks[locking.LEVEL_NODE].extend(self.op.on_node_uuids)
if self.op.on_master:
if not self.op.no_locks and self.op.on_master:
# The node lock should be acquired for the master as well.
self.needed_locks[locking.LEVEL_NODE].append(self.cfg.GetMasterNode())
......
......@@ -423,6 +423,7 @@ doRepair client delay instData (rtype, opcodes) =
, opDelayOnNodes = []
, opDelayOnNodeUuids = Nothing
, opDelayRepeat = fromJust $ mkNonNegative 0
, opDelayNoLocks = False
} : opcodes
else
opcodes
......
......@@ -836,6 +836,7 @@ $(genOpCode "OpCode"
, pDelayOnNodes
, pDelayOnNodeUuids
, pDelayRepeat
, pDelayNoLocks
],
"duration")
, ("OpTestAllocator",
......
......@@ -216,6 +216,7 @@ module Ganeti.OpParams
, pDelayOnNodes
, pDelayOnNodeUuids
, pDelayRepeat
, pDelayNoLocks
, pIAllocatorDirection
, pIAllocatorMode
, pIAllocatorReqName
......@@ -1447,6 +1448,12 @@ pDelayRepeat =
defaultField [| forceNonNeg (0::Int) |] $
simpleField "repeat" [t| NonNegative Int |]
pDelayNoLocks :: Field
pDelayNoLocks =
withDoc "Don't take locks during the delay" .
renameField "DelayNoLocks" $
defaultTrue "no_locks"
pIAllocatorDirection :: Field
pIAllocatorDirection =
withDoc "IAllocator test direction" .
......
......@@ -122,7 +122,7 @@ instance Arbitrary OpCodes.OpCode where
case op_id of
"OP_TEST_DELAY" ->
OpCodes.OpTestDelay <$> arbitrary <*> arbitrary <*>
genNodeNamesNE <*> return Nothing <*> arbitrary
genNodeNamesNE <*> return Nothing <*> arbitrary <*> arbitrary
"OP_INSTANCE_REPLACE_DISKS" ->
OpCodes.OpInstanceReplaceDisks <$> genFQDN <*> return Nothing <*>
arbitrary <*> arbitrary <*> arbitrary <*> genDiskIndices <*>
......
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