- Dec 19, 2012
-
-
Michael Hanselmann authored
This is not a trivial s/frozenset/compat.UniqueFrozenset/, but rather only replaces “frozenset” where appropriate. Most of the places are “static” information that doesn't change after the module has been loaded. Some docstrings and code formatting (e.g. empty lines) issues are addressed as well. Some lines got too long and were wrapped. Signed-off-by:
Michael Hanselmann <hansmi@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
- Dec 03, 2012
-
-
Michael Hanselmann authored
Just forwarding the parameter, nothing more. Signed-off-by:
Michael Hanselmann <hansmi@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com>
-
Michael Hanselmann authored
This patch adds a new parameter to “LockSet.acquire” named “opportunistic”. When enabled the lockset will try to acquire as many locks as possible, but it won't wait for them (with the exception of the lockset-internal lock in case the whole set is acquired). This is implemented by using a timeout of 0 seconds when acquiring individual locks. Commit 03c5291c made such acquisitions significantly cheaper. The most complicated code included in this patch is probably the helper function used to determine which mode to use and which timeout functions are needed. Full unit tests are included for the new and changed code (“locking.py”'s overall coverage is at 97%). Signed-off-by:
Michael Hanselmann <hansmi@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
- Nov 29, 2012
-
-
Michael Hanselmann authored
Some opcodes, for example LUInstanceFailover and LUInstanceMigrate, can't know whether they need to acquire all nodes until they have a lock on the instance. In turn they would have to acquire the node allocation lock “just in case” and could only release it once the instance had been acquired. Since there is no good reason for the node allocation lock to be before instances in the locking order, this patch changes the order so that instances are locked first. Signed-off-by:
Michael Hanselmann <hansmi@google.com> Reviewed-by:
Helga Velroyen <helgav@google.com>
-
- Nov 26, 2012
-
-
Michael Hanselmann authored
A new method is added to check whether the LockSet-internal lock is held. This is the case after LockSet.acquire was called with locking.ALL_SET. Unit tests are updated, including one where the list of names must be empty. Signed-off-by:
Michael Hanselmann <hansmi@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com>
-
- Nov 23, 2012
-
-
Michael Hanselmann authored
The new lock is similar to the BGL in the sense that it has its own level and there is only one. It is called “node allocation lock”. Logical units will use it to synchronize with instance creations, which in turn will start using opportunistic locks on nodes. Additionally, an assertion in GanetiLockManager gained a message. Signed-off-by:
Michael Hanselmann <hansmi@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com>
-
- Nov 21, 2012
-
-
Michael Hanselmann authored
Upcoming changes will add opportunistic locking to “locking.LockSet”. Doing so will require additional code in “LockSet.__acquire_inner”, at which point the existing “want_all” parameter does not always apply. This patch replaces it with a “mode” parameter. For opportunistic locking a new mode will be added. Signed-off-by:
Michael Hanselmann <hansmi@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
Michael Hanselmann authored
In this case “frozenset” is good enough as the result's order doesn't matter--it is the input to “sorted” (“utils.UniqueSequence” preserves the order). “frozenset” is ca. 25% faster for this use-case. Signed-off-by:
Michael Hanselmann <hansmi@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com>
-
- Nov 20, 2012
-
-
Dimitris Aragiorgis authored
Implement LUs for corresponding opcodes: * LUNetworkAdd: - Check for IP validity - Reserves all necessary IPs - Create new Network config object * LUNetworkRemove: - Checks if connected to any nodegroup - Remove a Network config object Implement basic config methods: * LookupNetwork() - Given the network name return the network UUID * AddNetwork() - Add a new network to the config * RemoveNetwork() - Remove a network from the config Add new locking level: LEVEL_NETWORK Add various useful config methods for retrieving network info. Signed-off-by:
Apollon Oikonomopoulos <apollon@noc.grnet.gr> Signed-off-by:
Dimitris Aragiorgis <dimara@grnet.gr> Reviewed-by:
Iustin Pop <iustin@google.com>
-
- Nov 19, 2012
-
-
Michael Hanselmann authored
Signed-off-by:
Michael Hanselmann <hansmi@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com>
-
Michael Hanselmann authored
Scheduling a pending acquisition is relatively expensive and lot of code is involved. Unless there is already one, a new pipe needs to be opened. Data structures need to be updated as well, only to be undone shortly after. This patch adds a small condition to return straight away if the timeout is shorter than 1ms and the lock couldn't be acquired right away. Blocking acquisitions are not affected, as are acquisitions with longer timeouts. While I tried hard, I could not find a way of writing a test specifically for this case which wouldn't have involved making significant other modifications. Other tests already exercise the new code, though. Signed-off-by:
Michael Hanselmann <hansmi@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com>
-
- Nov 13, 2012
-
-
Helga Velroyen authored
Signed-off-by:
Helga Velroyen <helgav@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com>
-
- Aug 23, 2012
-
-
Iustin Pop authored
Debian Wheezy will ship with this version, and it has many improved checks compared to 0.6, so let's: - bump version in the docs - silence some new checks that are wrong due to our indent=2 instead of 4 - fix lots of errors in the code where the indentation was wrong by 1 or 2 spaces - fix a few cases of == True, False, None and replace with 'is' - re-indent some cases where the code is OK, but pep8 complains Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
René Nussbaumer <rn@google.com>
-
- Mar 30, 2012
-
-
Michael Hanselmann authored
No longer used after commit 09037780. Signed-off-by:
Michael Hanselmann <hansmi@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
- Mar 22, 2012
-
-
Michael Hanselmann authored
Don't notify for every released lock in shared mode. The last one is enough. Signed-off-by:
Michael Hanselmann <hansmi@google.com> Reviewed-by:
Bernardo Dal Seno <bdalseno@google.com>
-
Michael Hanselmann authored
This was already a TODO since the implementation of lock priorities in September 2010. Under certain conditions a waiting acquire can be notified at a time when it can't actually get the lock. In this case it would try and fail to acquire the lock and then return to the caller before the timeout ends. While this is not bad (nothing breaks), it isn't nice either. A separate patch will prevent unnecessary notifications when shared locks are released. Signed-off-by:
Michael Hanselmann <hansmi@google.com> Reviewed-by:
Bernardo Dal Seno <bdalseno@google.com>
-
Michael Hanselmann authored
While working on another SharedLock fix I realized timeouts on lock deletion don't work very well if the timeout actually expires. This patch fixes the issue and adds a new unittest. Signed-off-by:
Michael Hanselmann <hansmi@google.com> Reviewed-by:
Bernardo Dal Seno <bdalseno@google.com>
-
- Feb 21, 2012
-
-
Michael Hanselmann authored
In at least two cases "%s" is replaced with str(), too. Signed-off-by:
Michael Hanselmann <hansmi@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
- Dec 19, 2011
-
-
Michael Hanselmann authored
These help when debugging. Signed-off-by:
Michael Hanselmann <hansmi@google.com> Reviewed-by:
Andrea Spadaccini <spadaccio@google.com>
-
- Nov 30, 2011
-
-
Michael Hanselmann authored
With this patch the “LockSet” and “GanetiLockManager” classes have a new function to check if a single or a group of locks (at a certain level) have been acquired in a specific mode. This will be used for additional assertions. Until now they could only check if a lock has been acquired, but not in which mode. One use-case will be updating the node state in various places, where the node lock must be acquired in exclusive mode. Signed-off-by:
Michael Hanselmann <hansmi@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
- Nov 15, 2011
-
-
Michael Hanselmann authored
Some methods, such as “_is_owned” and “list_owned”, have been aliased to make them public for a while now. This patch makes the actual implementation public. SharedLock's “is_owned” needs to be aliased to “_is_owned” to remain compatible with Python's built-in threaded.Condition class. Signed-off-by:
Michael Hanselmann <hansmi@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
- Nov 02, 2011
-
-
Michael Hanselmann authored
- Change all lock level names to their singular form - Add assertion checking consistency between level names and lockset name Signed-off-by:
Michael Hanselmann <hansmi@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
Michael Hanselmann authored
This is in preparation for implementing a new resource model. Signed-off-by:
Michael Hanselmann <hansmi@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
- Aug 30, 2011
-
-
Andrea Spadaccini authored
In version 0.21, pylint unified all the disable-* (and enable-*) directives to disable (resp. enable). This leads to a lot of DeprecationWarning being emitted even if one uses the recommended version of pylint (0.21.1, as stated in devnotes.rst). This commit changes all the disable-msg directives to disable. Signed-off-by:
Andrea Spadaccini <spadaccio@google.com> Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
- Aug 03, 2011
-
-
Iustin Pop authored
It turns out that the only use of the operator module was for itemgetter, so patch eb62069e should have removed that import too. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
René Nussbaumer <rn@google.com>
-
Iustin Pop authored
operator.itemgetter(0) → fst operator.itemgetter(1) → snd snd is not used yet, but it makes sense to add both. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com>
-
- Jul 21, 2011
-
-
Michael Hanselmann authored
This will be used for exporting job dependencies through the lock monitor. Signed-off-by:
Michael Hanselmann <hansmi@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
Michael Hanselmann authored
With this change it'll be possible to register other lock information providers. One usecase for this are job dependencies, which can be shown in the output of “gnt-debug locks”, too. The lock monitor is changed to accept more than one return value from the function providing the information. Unfortunately it's hard to keep weak references to bound methods, so that I settled on keeping a weak reference on the object instead (see note in docstring). Signed-off-by:
Michael Hanselmann <hansmi@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
- Jul 15, 2011
-
-
Michael Hanselmann authored
This will be useful for assertions. GanetiLockManager._is_owned is exported, too. Signed-off-by:
Michael Hanselmann <hansmi@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
- May 13, 2011
-
-
Michael Hanselmann authored
If a job needs to modify a resource and then wait for a result, it must acquire the resource lock in exclusive mode. In some cases it would be possible to only have a shared lock for waiting. Until now it was not possible to change a lock's mode once it'd been acquired. Releasing and re-acquiring might have been possible, but would require many more checks and can introduce new issues. With this patch a new method, named “downgrade”, is added to Ganeti's own SharedLock class. It can only be called when the lock is held in exclusive mode and changes it to shared. If there are any pending shared acquires on the same priority, they're moved to the front of the queue and notified (jumping ahead of exclusive acquires). In a lockset the internal lock will be downgraded if, and only if, all individual locks owned by the current thread are either released or acquired in shared mode. Unittests are provided. Signed-off-by:
Michael Hanselmann <hansmi@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com>
-
- May 09, 2011
-
-
Michael Hanselmann authored
When all locks contained in a set are acquired, the lockset's internal lock is acquired with the same mode. With this patch the internal lock will show up on the lock monitor, named e.g. “instances/[lockset]”. Signed-off-by:
Michael Hanselmann <hansmi@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com>
-
Michael Hanselmann authored
It is always used in the locking code. Unittests are updated. Signed-off-by:
Michael Hanselmann <hansmi@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com>
-
Michael Hanselmann authored
In some rare cases new shared acquires could sneak in through the condition cached in “__pending_shared” while the code was still notifying acquires. This was only working because such a condition would be on top of the queue. Signed-off-by:
Michael Hanselmann <hansmi@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com>
-
- Apr 29, 2011
-
-
Michael Hanselmann authored
This is analog to “is_owned” and will be used for assertions. Signed-off-by:
Michael Hanselmann <hansmi@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
- Mar 16, 2011
-
-
Michael Hanselmann authored
In some rare cases it can happen that a lock is re-created very soon after deletion, while the old instance hasn't been destructed yet. In such a case the code would detect a duplicate name and raise an exception. We have seen at least one case where this happened during the creation of many instances. It is not exactly clear how it came to be, but it appears to have occurred while different jobs fought for locks with short timeouts (in the case of instance creation locks are added at this stage and removed shortly after if not all locks can be acquired). The issue is fixed by removing the check for duplicate names. To still guarantee a stable sort order for the lock information as shown by “gnt-debug locks”, a registration number is recorded for each lock in the monitor. A unittest is included to check for the situation. Signed-off-by:
Michael Hanselmann <hansmi@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
- Jan 06, 2011
-
-
Michael Hanselmann authored
Locks can now be queried using “Query(what="lock", …)” over LUXI. Signed-off-by:
Michael Hanselmann <hansmi@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
- Dec 06, 2010
-
-
Guido Trotter authored
This also changes masterd to initialize the ganeti's manager with the current list of nodegroup uuids, and updates unittests Signed-off-by:
Guido Trotter <ultrotter@google.com> Reviewed-by:
Michael Hanselmann <hansmi@google.com>
-
- Dec 01, 2010
-
-
Michael Hanselmann authored
Just being told that a lock doesn't exist can be confusing. One case were this happens is when a job (e.g. instance modify) waits for a job removing the instance (e.g. export with remove). Signed-off-by:
Michael Hanselmann <hansmi@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
- Nov 16, 2010
-
-
René Nussbaumer authored
As we need this functionality in other places than just locking it makes sense to move it to utils rather than keeping it in locking Signed-off-by:
René Nussbaumer <rn@google.com> Reviewed-by:
Michael Hanselmann <hansmi@google.com>
-
- Oct 28, 2010
-
-
Guido Trotter authored
The nodes and instances parameters to the constructor are mandatory anyway, as a value of None will fail when creating the LockSet. Rather than fixing this adding code lines, since we never used the default value, let's remove them and require that the parameters are passed. This also fixes the only places where we inited GanetiLockManager with keyed parameters and without arguments. Signed-off-by:
Guido Trotter <ultrotter@google.com> Reviewed-by:
Michael Hanselmann <hansmi@google.com>
-