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

mcpu: Raise directly in _AcquireLocks


Removes code duplication.

Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 3d914585
No related branches found
No related tags found
No related merge requests found
...@@ -229,6 +229,8 @@ class Processor(object): ...@@ -229,6 +229,8 @@ class Processor(object):
@param shared: Whether the locks should be acquired in shared mode @param shared: Whether the locks should be acquired in shared mode
@type timeout: None or float @type timeout: None or float
@param timeout: Timeout for acquiring the locks @param timeout: Timeout for acquiring the locks
@raise LockAcquireTimeout: In case locks couldn't be acquired in specified
amount of time
""" """
if self._cbs: if self._cbs:
...@@ -237,6 +239,9 @@ class Processor(object): ...@@ -237,6 +239,9 @@ class Processor(object):
acquired = self.context.glm.acquire(level, names, shared=shared, acquired = self.context.glm.acquire(level, names, shared=shared,
timeout=timeout, priority=priority) timeout=timeout, priority=priority)
if acquired is None:
raise LockAcquireTimeout()
return acquired return acquired
def _ExecLU(self, lu): def _ExecLU(self, lu):
...@@ -306,10 +311,6 @@ class Processor(object): ...@@ -306,10 +311,6 @@ class Processor(object):
acquired = self._AcquireLocks(level, needed_locks, share, acquired = self._AcquireLocks(level, needed_locks, share,
calc_timeout(), priority) calc_timeout(), priority)
if acquired is None:
raise LockAcquireTimeout()
else: else:
# Adding locks # Adding locks
add_locks = lu.add_locks[level] add_locks = lu.add_locks[level]
...@@ -374,11 +375,9 @@ class Processor(object): ...@@ -374,11 +375,9 @@ class Processor(object):
# Acquire the Big Ganeti Lock exclusively if this LU requires it, # Acquire the Big Ganeti Lock exclusively if this LU requires it,
# and in a shared fashion otherwise (to prevent concurrent run with # and in a shared fashion otherwise (to prevent concurrent run with
# an exclusive LU. # an exclusive LU.
if self._AcquireLocks(locking.LEVEL_CLUSTER, locking.BGL, self._AcquireLocks(locking.LEVEL_CLUSTER, locking.BGL,
not lu_class.REQ_BGL, calc_timeout(), not lu_class.REQ_BGL, calc_timeout(),
priority) is None: priority)
raise LockAcquireTimeout()
try: try:
lu = lu_class(self, op, self.context, self.rpc) lu = lu_class(self, op, self.context, self.rpc)
lu.ExpandNames() lu.ExpandNames()
......
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