Add FileLock utility class
This class is a wrapper around fcntl.flock and abstracts opening andclosing the lockfile. It'll used for the job queue.
(The patch also removes a duplicate import of tempfile into the unittest)
Reviewed-by: iustinp
First write operation (add tag) for Ganeti RAPI
Add instance tag handling, improved error logging....oh, yes adopt instance listing for RAPI2!
Expose utils.DaemonPidFileName
Since we need to compute this from outside utils.py, we change this to apublic function.
Reviewed-by: ultrotter
Add a KillProcess function
We cannot depend on all environments to have a start-stop-daemon orsimilar tool. We instead implement a KillProcess function that behavessimilar to “start-stop-daemon --retry”.
Note that the attached unittest can hang in foreground if the child...
Change IsPidFileAlive into ReadPidFile
We already have a function to test if a PID is alive, so it makes moresense to use function composition that force calling (since we need toread PIDs from files in other places too). Now IsProcessAlive returnsFalse for PIDs <= 0, since this is the error return from ReadPidFile....
Fix unittests for ganeti-rapi
The RESTHTTPServer module went the way of the dodo.
Switch RAPI to ganeti.http module
Reviewed-by: imsnah
Add utils unittests for new functions
The submitted WritePidFile, RemovePidfile and IsPidFileAlive functionsmiss unit tests. Adding a simple one which covers their basicfunctionality.
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....
Split RAPI resources to pieces
Copy the rest of the Restful-API files to trunk
Fix utils.py unittest
Remove the old locking functions
This removes (hopefully) all traces of the old locking functions anduses.
Add a more comment lines to testLockingConstants
This is to discourage even more whoever may think that this requirementis not really useful and can be lifted, and to at least know where it'sused before trying to break it.
Add a new LockSet unittest
This test checks the LockSet behaviour when an empty list is passed.The current behaviour is expected, but since this is a corner case,we're safer to keep it under a check, and if we need a different onemonitor that everything is as we expect it to be....
Pass context to LUs
Rather than passing a ConfigWriter to the LUs we'll pass the wholecontext, from which a ConfigWriter can be extracted, but we can alsoaccess the GanetiLockManager. This also fixes the places where a FakeLUis created.
mocks: create a FakeContext object
This will be passed to FakeLUs
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...
Add generic worker pool implementation
Add a FirstFree function to utils.py
This function will return the first unused integer based on a list ofused integers (e.g. [0, 1, 3] will return 2).
Remove duplicate code in hooks unittests
All the tests there used to creare a cfg, a sstore, an opcode and a LU.Put all the duplicate code in the setUp function.
Add unittests for ganeti.serializer
Fix the zombie process unittest
The failure is because in high load, the parent gets to run before thechild has the chance to os._exit(), and therefore it is still runningwhen the parent does the check.
The fix removes the chance of this happening by waiting to receive a SIGCHLD...
Add functions to calculate version number to constants.py
In cfgupgrade, we need to extract parts of and build new version numbers.
Use a single Makefile.am instead of many
This change allows us to use cleaner dependencies betweendirectories. The build system is basically rewritten in large partsand may contain bugs.
Fix bdev unittest when run under distcheck
The path to the filename for drbd8 proc data is not correctly computedwhen using distcheck. The patch duplicates it from the other drbd tests.
Rework the DRBD8 device status computation
Currently, compute the status of a drbd8 device in GetSyncStatus andreturn only the values that we need (and fit in the framework ofGetSyncStatus). However, the full status details are useful (and needed)in other places, so the patch attempts to improve this situation....
Add unittest for constants
locking: remove obsolete comment
Make testSignal unittest not depend on default shell
This patch changes the code executed when testing the signal handlingof RunCmd. Since sh does not always point to bash (e.g. on Ubuntu,where it points to /bin/dash) this test might fail due to the returned...
Add function to write cluster SSH key to known_hosts file
The whole Ganeti cluster has a single SSH key. Its fingerprint iswritten to Ganeti's known_hosts file, together with an alias. Thisallows us to always use that alias instead of the real hostname,...
Modify utils.TcpPing to make source address optional
This patch modifies TcpPing and its callers to make the source addressselection optional. Usually, the kernel will know better whatsource address to use, just in some cases we want to enforce a given...
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: add missing check code
This check that no operation had been performed before release() was missing inthe test code. Adding it.
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: 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...
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 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...
Split GanetiUnitTest into testutils.py
Add a few SharedLock delete() tests
- Check that even a shared acquire() fails on a deleted lock- Check that delete() fails on a lock you share (must own it or nothing)
These are assumptions I build on in future code, so better check for them.Currently no code change is necessary for them to be valid....
SharedLock: fix a wrong unit-test helper code
The _doItDelete helper code was supposed to be used to dispatch threads thatdeleted the SharedLock. It actually just acquired it exclusively. This remainedunnoticed as the helper thread is just used to test interaction, not the delete...
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
Fix the make dist rule
In revision 459 I added a bug in the make dist rule in the sense thatthe archive will include all of test/data directory, including the.svn directory if it exists.
This patch fixes that problem and adds a distcheck hook that tests for...
Fix ‘make distcheck’ breakage introduced in r455
This patch fixes the ‘make distcheck’ breakage caused by missing test data inthe archive and missing handling of builddir!=srcdir case.
Reviewed-by: schreiberal
Add unittest for DRBD8 drdbsetup show parser
This patch changes the bdev.DRBD8._GetDevInfo to take a string insteadof a minor, separates the `drbdsetup show` invocation into a newseparate method (bdev.DRBD8._GetShowData) and modifies the rest of theDRBD8 class to make the appropriate calls....
Fix the unittest for locking.
Make sure aliases written to /etc/hosts are unique.
Add function to return list with unique elements.
Fix typo in function name.
Use setUp/tearDown for tests using temporary files.
Wrap line longer than 80 characters.
Compare file contents directly in unittests.
Reviewed-by: schreiberal, ultrotter
Fix unittests broken by revision 360.
Fix functions for /etc/hosts.
- Combine hostname and aliases on one line- Fix bug with wrongfully removed newline characters- Use wrapper for SetEtcHostsEntry in cmdlib
Reviewed-by: iustin
Rollback commit 356.
Add functions for known_hosts files.
Reviewed-by: TODO
Soften the requirements for hooks execution
Currently, an unreachable node (or one that return undetermined failure)in the hooks pre-phase will abort the curren operation. This is notgood, as a down node could prevent many operation on the cluster.
This patch changes a RPC-level failure (and not a hook execution...
Add functions to modify /etc/hosts.
Rename utils.GetUUID to utils.NewUUID.
Fix unit tests for hooks.
Use the kernel's ability to generate UUIDs.
This removes the dependency on either the uuid module or e2fsprogs' uuidgen.
Remove fping as a dependency for Ganeti.
This patch completely gets rid of fping - replace all fping invocations with TcpPing calls - update documentation accordingly. - associated cleanups (use constant for localhost IP, use more sensible defaults for TcpPing and use those)...
Remove the shebang from modules
Since modules are not directly executables, remove the shebang fromthem. This helps with lintian warnings.
Also make the autogenerated _autoconf.py contain two comment lines atthe beginning, like the other modules.
Fix “make distcheck”.
- Move symlink to “ganeti” to top dir- Add ganeti.config_unittest.py to tests to be run- Make sure everything is built before tests are run
Add function to list files in a directory, excluding those beginning with adot.
Import utils into unittest.
Remove requirement that host names are FQDN
We currently require that hostnames are FQDN not short names(node1.example.com instead of node1). We can allow short names as longas: - we always resolve the names as returned by socket.gethostname() - we rely on having a working resolver...
Cleanup up selective imports for utils and utils unit test.
Reviewed-by: iustinp, imsnah
Added TcpPing to do ping-alike via TCP connect(2) with defined source address.To be used to replace the currently fping(8) based reachability test.
Fix typo in last commit.