History | View | Annotate | Download (28.6 kB)
Enable auto-unit formatting in script output
This patch enables by default the old 'human-readable' option, but in aslightly different model.
The option is now called "units" and takes either: - 'h' for automatic formatting - 'm', 'g' or 't' for mebi/gibi/tebibytes...
Move FieldSet class to utils.py
Since we can use the FieldSet class in cli.py to nicely format disksizes and such, we move it to utils.py and also move its associatedunittest. I didn't remove the cmdlib.py unittest file as that's not thegood direction :)...
Remove zombie special case from IsProcessAlive
Based on the discussion on the mailing list, we remove the specialcasing of zombie processes.
Note we don't use kill -0 since that has a different meaning than "checkprocess is alive", so this function is still linux-specific....
Add cleanup of processes to utils.KillProcess
In case the process we want to signal is our own process, and the signalwe send is a deadly one, we should also cleanup after the process.
This patch adds a new parameter waitpid to this function that does this,...
Implement working directory for utils.RunCmd
In order to replace usage of the shell just for 'cd %s; ...' we need tobe able to specify the working directory for childs.
The patch also changes the default working directory (when notspecified) to "/", as opposed to the current dir; since the daemos run...
Modify utils.RunCmd to write output to file
Currently we launch processes via the shell in a few places only toredirect standard output and error to a log file ("&> $file"). It isbetter to do such redirection from within RunCmd itself.
This patch splits RunCmd in two parts, the setup and the execution part,...
Really fix with the zombie test (hopefully)
So, instead of any timeouts for synchronization, we move to actualevents. We still have one (huge) timeout for pathological cases (just tocleanup), but we don't sleep at all in normal usage.
The patch moves the zombie/cleaned up child creation out from setUp(),...
Abstract checking own address into a function
Currently, we check if we have a given ip address (i.e. it's alive onone of our interfaces) but manually calling TcpPing(source=localhost).This works, but having it spread all over the code makes it hard to...
utils.SplitTime: More rounding fixes
SplitTime didn't round the same on different platforms. This patch changesit to use microseconds and not care about rounding.
Reviewed-by: iustinp
utils.SplitTime: Fix rounding of milliseconds
Reported by Iustin.
It used to return this:
utils.SplitTime(1234.999999999999)
(1234, 1000)
while it should've returned this:
(1235, 0)
Reviewed-by: ultrotter
Add functions to split time into tuple and merge it back
These will be used for job logs.
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)
Expose utils.DaemonPidFileName
Since we need to compute this from outside utils.py, we change this to apublic function.
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....
Add utils unittests for new functions
The submitted WritePidFile, RemovePidfile and IsPidFileAlive functionsmiss unit tests. Adding a simple one which covers their basicfunctionality.
Fix utils.py unittest
Reviewed-by: imsnah
Remove the old locking functions
This removes (hopefully) all traces of the old locking functions anduses.
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).
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...
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...
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...
Split GanetiUnitTest into testutils.py
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.
Reviewed-by: schreiberal
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
Add functions to modify /etc/hosts.
Rename utils.GetUUID to utils.NewUUID.
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)...
Add function to list files in a directory, excluding those beginning with adot.
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.