History | View | Annotate | Download (29.7 kB)
locking.LockSet: don't modify input arguments
Currently LockSet.acquire() sorts in place it's input argument if it's alist. This is not good, since callers might depend on a specificordering of the input data, and this is a 'hidden' modification.
We fix it by simply using a sorted copy, instead of sorting in place....
Re-wrap some lines to keep them under 80 chars
This non-code change rewraps some lines in locking.py to keep them under80 chars.
Reviewed-by: ultrotter
Fix epydoc format warnings
This patch should fix all outstanding epydoc parsing errors; as such, weswitch epydoc into verbose mode so that any new errors will be visible.
Reviewed-by: imsnah
LockSet: forbid add() on a partially owned set
This patch bans add() on a half-acquired set. This behavior waspreviously possible, but created a deadlock if someone tried to acquirethe set-lock in the meantime, and thus is now forbidden. ThetestAddRemove unit test is fixed for this new behavior, and includes a...
Fix typo in a locking.py comment
Add GanetiLockManager.is_owned function
This is a public version of the private function we already had.We don't just change the previous version because it had lots of usersin the library itself and in the testing code.
Fix LockSet._names() to work with the set-lock
If the set-lock is acquired, currently, the _names function will fail ona double acquire of a non-recursive lock. This patch fixes the behavior,and some lines of code added to the testAcquireSetLock test check that...
Add locking.ALL_SET constant and use it
Rather than specifying None in needed_locks every time, with a nicecomment saying to read what we mean rather than what we write, and thatNone actually means All, in our magic world, we'll hide this secretunder the ALL_SET constant in the locking module, which has value, you...
LockSet: allow lists with duplicate values
If a list with a duplicate value is passed to a lockset what the codenow does is to try to acquire the lock twice, generating adouble-acquire exception in the SharedLock code. This is definitely anissue. In order to solve it we can either forbit double values in a list...
Invert nodes/instances locking order
An implementation mistake from the original design caused nodes to belocked before instances, rather than after. This patch inverts the levelnumbering, changing also the relevant unittests and the recursivelocking function starting point....
Locking: remove LEVEL_CONFIG lockset
Since the ConfigWriter now handles its own locking it's not necessary tohave a specific level for the config in the Locking Manager anymore.This patch thus removes it, and all the unittest calls that used it, ordepended on it being present....
Locking: add ssynchronized decorator
This patch creates a new decorator function ssynchronized in the lockinglibrary, which takes as input a SharedLock, and synchronizes access tothe decorated functions using it. The usual SharedLock semantics apply,so it's possible to call more than one synchronized function at the same...
SharedLock: restrict assertion condition
When we release a shared lock if there are no exclusive waiter then the numberof shared waiters must be exactly equal to the ones scheduled to pass.
Reviewed-by: iustinp
Locking: fix one indentation error (codestyle)
Locking: fix superlong lines (codestyle)
Locking: remove an empty space at End Of Line
Increase SharedLock fairness
Previously if a shared thread was notified, together with the rest, and was notfast enough in waking up and acquiring the lock, another one could release it,decide there were no more sharers, and let an exclusive one in instead. With...
LockSet: handle empty case
A LockSet is mostly useful when it has some locks in it. On the other handthere are cases in which it must function even when empty. For example if acluster has no instances in it there's no reason why locking all of themshouldn't work anyway. This patch adds test code for that situation and...
LockSet: collapse two try/except into one
SharedLock: remove wrong assertion in code
r644 contained some cleanup code for LockSet. Among other things it removed asyntax error that allowed an assertion that previously wan't really checked totrigger. It turns out that even though the spirit of that assertion was correct...
Codestyle updates for locking code
LockSet: make acquire() able to get the whole set
This new functionality makes it possible to acquire a whole set, by passing"None" to the acquire() function as the list of elements. This will avoid newadditions to the set, and then acquire all the current elements. The list of...
LockSet: encapsulate acquire() in try-except
This patch adds a try/except area around most of the acquire() code (everythingafter the intial condition checks). Since the except: clause contains just a'raise' nothing really changes except the indentation of the code....
Make LockSet.__names() return a list, not a set
Previously the private version of the __names function returned directly a set.We'll keep this in the public interface but change the private version to alist in order to be able to sort() its result and then loop on it, even though...
LockSet: improve remove() api
Lockset's remove() function used to return a list of locks we failed to remove.Rather than doing this we'll return a list of removed locks, so it's moresimilar to how acquire() behaves. This patch also fixes the relevant unit tests....
LockSet: make acquire() return the set of names
In a LockSet acquire() returned True on success. This code changes that toreturn a set containing the names of the elements acquired. This is still atrue value if we acquired any lock but is slightly more useful (because if...
LockSet: invert try/for nesting in acquire()
This patch changes nothing to the functionality of a LockSet. Rather thantrying to do the whole for loop we try each of its steps. This opens the way tohandle differently a single failure.
Initial GanetiLockManager implementation
Includes some locking-related constants and explanations on how theLockManager should be used, the class itself and its test cases.
The class includes: - a basic constructor - functions to acquire and release lists of locks at the same level...
LockSet: make acquire() fail faster on wrong locks
This patch makes acquire() first look up all the locks in the dict and then tryto acquire them later. The advantage is that if a lockname is already wrongsince the beginning we won't need to first queue and acquire other locks to...
LockSet implementation and unit tests
A LockSet represents locking for a set of resources of the same type. A threadcan acquire multiple resources at the same time, and release some or all ofthem, but cannot acquire more resources incrementally at different times...
Add the delete() operation to SharedLock
This new operation lets a lock be cleanly deleted. The lock will be exclusivelyheld before deletion, and after it pending and future acquires will raise anexception. Other SharedLock operations are modify to deal with delete() and to...
Fix a couple of SharedLock docstrings
Use the actual class name rather than a spaced version of it.
Shared Lock implementation and unit tests.
Adding a locking.py file for the ganeti locking library. Its first component isthe implementation of a non-recursive blocking shared lock complete with atesting library.
Reviewed-by: imsnah, iustinp