Skip to content
Snippets Groups Projects
Commit 1f1188c3 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

cmdlib: Opportunistic locking on instance creation


Adds a new parameter to “OpInstanceCreate” and “OpInstanceMultiAlloc” to
use opportunistic locks.

Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent b3c728dc
No related branches found
No related tags found
No related merge requests found
...@@ -217,7 +217,7 @@ instance Arbitrary OpCodes.OpCode where ...@@ -217,7 +217,7 @@ instance Arbitrary OpCodes.OpCode where
genMaybe (pure []) <*> genMaybe genNodeNameNE <*> genMaybe (pure []) <*> genMaybe genNodeNameNE <*>
arbitrary <*> genMaybe genNodeNameNE <*> arbitrary <*> genMaybe genNodeNameNE <*>
genMaybe genNodeNameNE <*> genMaybe genNameNE <*> genMaybe genNodeNameNE <*> genMaybe genNameNE <*>
arbitrary <*> (genTags >>= mapM mkNonEmpty) arbitrary <*> arbitrary <*> (genTags >>= mapM mkNonEmpty)
"OP_INSTANCE_MULTI_ALLOC" -> "OP_INSTANCE_MULTI_ALLOC" ->
OpCodes.OpInstanceMultiAlloc <$> genMaybe genNameNE <*> pure [] OpCodes.OpInstanceMultiAlloc <$> genMaybe genNameNE <*> pure []
"OP_INSTANCE_REINSTALL" -> "OP_INSTANCE_REINSTALL" ->
......
...@@ -294,6 +294,7 @@ $(genOpCode "OpCode" ...@@ -294,6 +294,7 @@ $(genOpCode "OpCode"
, pSrcNode , pSrcNode
, pSrcPath , pSrcPath
, pStartInstance , pStartInstance
, pOpportunisticLocking
, pInstTags , pInstTags
]) ])
, ("OpInstanceMultiAlloc", , ("OpInstanceMultiAlloc",
......
...@@ -71,6 +71,7 @@ module Ganeti.OpParams ...@@ -71,6 +71,7 @@ module Ganeti.OpParams
, pIgnoreConsistency , pIgnoreConsistency
, pStorageName , pStorageName
, pUseLocking , pUseLocking
, pOpportunisticLocking
, pNameCheck , pNameCheck
, pNodeGroupAllocPolicy , pNodeGroupAllocPolicy
, pGroupNodeParams , pGroupNodeParams
...@@ -607,6 +608,12 @@ pStorageName = ...@@ -607,6 +608,12 @@ pStorageName =
pUseLocking :: Field pUseLocking :: Field
pUseLocking = defaultFalse "use_locking" pUseLocking = defaultFalse "use_locking"
-- | Whether to employ opportunistic locking for nodes, meaning nodes already
-- locked by another opcode won't be considered for instance allocation (only
-- when an iallocator is used).
pOpportunisticLocking :: Field
pOpportunisticLocking = defaultFalse "opportunistic_locking"
-- | Whether to check name. -- | Whether to check name.
pNameCheck :: Field pNameCheck :: Field
pNameCheck = defaultTrue "name_check" pNameCheck = defaultTrue "name_check"
......
...@@ -159,6 +159,12 @@ _PDiskParams = \ ...@@ -159,6 +159,12 @@ _PDiskParams = \
_PHvState = ("hv_state", None, ht.TMaybeDict, "Set hypervisor states") _PHvState = ("hv_state", None, ht.TMaybeDict, "Set hypervisor states")
_PDiskState = ("disk_state", None, ht.TMaybeDict, "Set disk states") _PDiskState = ("disk_state", None, ht.TMaybeDict, "Set disk states")
#: Opportunistic locking
_POpportunisticLocking = \
("opportunistic_locking", False, ht.TBool,
("Whether to employ opportunistic locking for nodes, meaning nodes"
" already locked by another opcode won't be considered for instance"
" allocation (only when an iallocator is used)"))
_PIgnoreIpolicy = ("ignore_ipolicy", False, ht.TBool, _PIgnoreIpolicy = ("ignore_ipolicy", False, ht.TBool,
"Whether to ignore ipolicy violations") "Whether to ignore ipolicy violations")
...@@ -1241,6 +1247,7 @@ class OpInstanceCreate(OpCode): ...@@ -1241,6 +1247,7 @@ class OpInstanceCreate(OpCode):
_PWaitForSync, _PWaitForSync,
_PNameCheck, _PNameCheck,
_PIgnoreIpolicy, _PIgnoreIpolicy,
_POpportunisticLocking,
("beparams", ht.EmptyDict, ht.TDict, "Backend parameters for instance"), ("beparams", ht.EmptyDict, ht.TDict, "Backend parameters for instance"),
("disks", ht.NoDefault, ht.TListOf(_TDiskParams), ("disks", ht.NoDefault, ht.TListOf(_TDiskParams),
"Disk descriptions, for example ``[{\"%s\": 100}, {\"%s\": 5}]``;" "Disk descriptions, for example ``[{\"%s\": 100}, {\"%s\": 5}]``;"
...@@ -1300,6 +1307,7 @@ class OpInstanceMultiAlloc(OpCode): ...@@ -1300,6 +1307,7 @@ class OpInstanceMultiAlloc(OpCode):
""" """
OP_PARAMS = [ OP_PARAMS = [
_POpportunisticLocking,
_PIAllocFromDesc("Iallocator used to allocate all the instances"), _PIAllocFromDesc("Iallocator used to allocate all the instances"),
("instances", ht.EmptyList, ht.TListOf(ht.TInstanceOf(OpInstanceCreate)), ("instances", ht.EmptyList, ht.TListOf(ht.TInstanceOf(OpInstanceCreate)),
"List of instance create opcodes describing the instances to allocate"), "List of instance create opcodes describing the instances to allocate"),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment