History | View | Annotate | Download (23.1 kB)
utils: Drop RemovePidFile
It's equivalent to a simple RemoveFile now.
Signed-off-by: Michael Hanselmann <hansmi@google.com>Reviewed-by: Iustin Pop <iustin@google.com>
utils: Use function to disable fork
Use a function instead of a variable written by another module.
utils: Change RemovePidFile to take path, not name
This avoids having to monkey-patch the utils module for unittests.Monkey patching is evil and caused a bug while moving code around.
Fix a rare bug in StartDaemonChild and GenericMain
I've seen cases where the result from str(sys.exc_info()[1]) is ""; thisbreaks the error reporting as the parent relies on non-empty errormessages to properly detect child status (otherwise it will try to read...
Enhance the error reporting
Since daemon startup error will be often related to socket errors, so itmakes sense to change the original reporting:
Error when starting daemon process: "(98, 'Address already in use')"
Into:
Error when starting daemon process: 'Socket-related error: Address...
Change daemon.GenericMain/utils.Daemonize workflow
This patch copies the pipe-based error reporting functionality fromutils.StartDaemon (I gave up for now on tryin to merge the two).
This patch will fix two longstanding bugs:
- if we fork, we lose all error reporting from the child to the original...
Change utils.GenericMain protocol
Currently, GenericMain does a two-staged workflow:
- Check, before forking- then Exec, after forking
This means we don't have any possibility to treat preparation work(before the daemon is ready for work) different from the actual work....
Use only one version of WritePidFile
This patch merges the pid file handling used for ganeti-* daemons andimpexp daemons. The latter version is used, since it's more reliable:uses locked pid files as opposed to checking 'live' processes.
Signed-off-by: Iustin Pop <iustin@google.com>...
Bail out if daemon gets fired up under wrong uid
This patch bails out in early stage, if the user invoking the daemondoesn't match the user set at configure time.
Signed-off-by: René Nussbaumer <rn@google.com>Reviewed-by: Michael Hanselmann <hansmi@google.com>
Remove utils.EnsureDir as this is done by ensure-dirs.in now
Revert "Make it possible to call utils.Daemonize with uid and gid to run as"
This reverts commit 743b53d4eb9f3de46edb5e54738dab287b1979ac.
Conflicts:
lib/daemon.py
Trivial conflict resolved. This patch reverts changes from earlier permissionsseparation stage. This is not needed anymore as start-stop-daemon takes care...
Handle ENOENT case in ssconf.GetPrimaryIPFamily
This patch adds an optional default parameter to SimpleStore._ReadFile. Thiscan be used to default the return value of this method in case the ssconf fileis not present.
In this particular case it is used to return AF_INET in case...
Make family argument in FormatAddress optional
By doing this we delegate the task of finding the correct address familyto the FormatAddress method.
Signed-off-by: Manuel Franceschini <livewire@google.com>Reviewed-by: Iustin Pop <iustin@google.com>
Support IPv6 cluster init
rapi.client, http.client: Format url correctly when using IPv6
This patch moves the FormatAddress helper function from daemon.py tonetutils.py. This enables its use in http.client as well as inrapi.client. Furthermore this adds functionality to format IPv6...
Confd IPv6 support
This patch series basically adds a new parameter 'family' to the constructorsof daemon.AsyncUDPSocket and confd.client.ConfdUDPClient. This enables theusers of these two classes to support IPv6.
In ganeti-confd.ConfdAsyncUDPClient a method to check the address families of...
Introduce lib/netutils.py
This patch moves network utility functions to a dedicated module.
Replace '0.0.0.0' with constant
Signed-off-by: Manuel Franceschini <livewire@google.com>Reviewed-by: Guido Trotter <ultrotter@google.com>
AsyncTerminatedMessageStream: send_message
This function adds the ability for a AsyncTerminatedMessageStream tohave a thread-safe message delivery function.
Signed-off-by: Guido Trotter <ultrotter@google.com>Reviewed-by: Michael Hanselmann <hansmi@google.com>
AsyncTerminatedMessageStream: limit message count
Currently the message stream can process any number of messages inparallel (if they get dispatched to different threads or processes).In order to limit their number we only handle messages and read from...
AsyncAwaker: use shutdown on the socketpair
This makes sure the out_socket can only be used for writing, and thein_socket for reading.
Make it possible to call utils.Daemonize with uid and gid to run as
Signed-off-by: René Nussbaumer <rn@google.com>Reviewed-by: Guido Trotter <ultrotter@google.com>
daemon.AsyncAwaker
This new asyncore dispatcher can be used to force a thread running theasyncore loop to awake from the select, by signaling it on one of itsselected sockets.
daemon.AsyncStreamServer
This is a new asyncore server which handles listening stream sockets bycalling a non-implemented function for each connection it accepts. It'sthe stream-oriented cousing of the AsyncUDPSocket.
Signed-off-by: Guido Trotter <ultrotter@google.com>...
daemon.AsyncTerminatedMessageStream
This is the counterpart of the AsyncStreamServer can be used to handleconnected sockets returned from connected clients if the protocol is aterminator separated message stream. Nothing in this class is serverspecific though: it can be used as a client as well, if the client is...
Merge remote branch 'origin/devel-2.1'
Conflicts: test/ganeti.daemon_unittest.py...
AsyncUDPSocket: fix IgnoreSignals usage and test
This bug was found in the asyncore master patch series, but actuallyapplies to 2.1 for AsyncUDPSocket as well.
Merge branch 'devel-2.1'
Signed-off-by: Guido Trotter <ultrotter@google.com>Reviewed-by: Iustin Pop <iustin@google.com>
daemon.GanetiBaseAsyncoreDispatcher
Abstract a few common functionalities between all ganeti asyncoredispatchers: - Handle errors by logging them, and then continue - By default check sockets only for readability
Signed-off-by: Guido Trotter <ultrotter@google.com>Reviewed-by: Balazs Lecz <leczb@google.com>
Mainloop: handle SIGINT as well (and terminate)
This is needed if daemons are in the foreground, and get ctrl+c-ed bythe user. Also add unittests to make sure the correct signals terminatethe mainloop.
Remove unused import from daemon.py
Signed-off-by: Guido Trotter <ultrotter@google.com>Reviewed-by: Luca Bigliardi <shammash@google.com>
Add a forgotten comment about overriding a method
AsyncUDPSocket.handle_error
By overriding the default asyncore handle_error (which closes thesocket) with our own version, which logs what happened but tries toproceed, we can get rid of a couple of try/except blocks. The resultingchurn is deindentation of the internal code....
utils.IgnoreSignals
Remove duplicate code between a couple of asyncore related function byhaving a function in charge of handling EINTR errors. Unittests included.
Conflicts: daemons/ganeti-noded lib/daemon.py lib/rapi/baserlib.py lib/rapi/rlib2.py lib/utils.py
Signed-off-by: Luca Bigliardi <shammash@google.com>Reviewed-by: Michael Hanselmann <hansmi@google.com>
Daemons conditionally setup console logging
daemon.GenericMain: fix docstring
The docstring reports a wrong type for the "dirs" argument. Fixing.
Fix utils.WaitForFdCondition inner retry loop
Commit dfdc4060 added WaitForFdCondition which uses utils.Retry withouthandling timeout exceptions. This breaks any nested retry loops.
This patch fixes the above function, and also changes utils.Retry todetect and warn future similar cases. In addition, we add a few small...
AsyncUDPSocket.process_next_packet
This function allows receiving socket data synchronously.
AsyncUDPSocket: abstract do_read function
This basically implements read handling, without catching allexceptions. When using the socket in synchronous mode, it's useful toavoid losing exception data (which, in an async daemon, can only belogged)
Add capability to use syslog for logging
This patch adds a configure-time parameter that will set the defaultsused by all programs, and command-line parameters in the daemons thatallow overriding it.
Syslog 'yes' enables syslog in addition to file-based logging, 'only'...
Merge remote branch 'devel-2.1'
Add targeted pylint disables
This patch should have only:
- pylint disables- docstring changes- whitespace changes
Signed-off-by: Iustin Pop <iustin@google.com>Reviewed-by: Olivier Tharan <olive@google.com>
daemon.GenericMain: Don't use dict for SSL paths, improve CLI options
Pass SSL certificate and key paths from ganeti-* instead of using a dict. Thepatch also improves the --ssl-{key,cert} options by giving the default in--help output and changes the validation a bit....
daemon.GenericMain: Don't use list of multithreaded daemons
Passing it in as a parameter seems more logical.
Signed-off-by: Michael Hanselmann <hansmi@google.com>Reviewed-by: Guido Trotter <ultrotter@google.com>
daemon.GenericMain: Improve --bind and --port options a bit
Another round of pylint-related style fixes
A newer version of pylint, more warnings…
Signed-off-by: Iustin Pop <iustin@google.com>Reviewed-by: Michael Hanselmann <hansmi@google.com>
Code and docstring style fixes
Found using pylint and epydoc.
Add missing import sys to lib/daemon.py
It does “print >> sys.stderr, …” but there is no import sys.
Signed-off-by: Iustin Pop <iustin@google.com>Reviewed-by: Michael Hanselmann <hansmi@google.com>Reviewed-by: Guido Trotter <ultrotter@google.com>
Abstract AsyncUDPSocket to daemon
This allows this extended asyncore+udp module to be used also in otherdaemons, and in the confd client library
AsyncUDPSocket: Move to a well defined UDP size
Currently we read maximum 4K packets, and don't check packets whensending them. With this patch we move to a well defined maximum size of60K.
Merge branch 'next' into branch-2.1
Reinsert simple timers in Mainloop
This time we use the standard python sched module, rather than doing itall by ourselves. The scheduler in mainloop can be manipulated directlyby callers, to enter new events.
Convert the http server/mainloop to asyncore
We can avoid most of the Mainloop.Run() code if we use asyncorefor delivering I/O events, and just concentrate on what's missing inasyncore: singnal handling and timers. This way confd can be ported touse Mainloop as well....
Pass the correct signal to handlers
Mainloop currently calls all handlers with the signal number harcoded tosigchild. Fixing this.
Signed-off-by: Guido Trotter <ultrotter@google.com>Reviewed-by: Olivier Tharan <olive@google.com>
Convert daemon.Mainloop to @SignalHandled
This makes the function a lot simpler, since it used to install twodifferent signal handlers, which are now transparently handled by thedecorator. The code is unindented, but remains unchanged apart from thepart that checks the signal handlers (which is now collapsed toghether)....
Simplify IO waiting in Mainloop
IO is never unregistered in our current usage, so dropping thatfunctionality for now. Also putting the poller outside of the Run()function allows us to avoid the double step of adding tuples to an_io_wait_add queue and adding them later in the main loop....
Remove timers from Mainloop
Timers are currently unused, slightly buggy (for example timeout doesn'tget updated correctly), and unneeded in the current form. Confd willhave timeouts in more simple fashion, and is not a mainloop useranyway.
Collapse SSL key checking/overriding for daemons
Signed-off-by: Guido Trotter <ultrotter@google.com>
Collapse daemon's main function
With three ganeti daemons, and one or two more coming, the daemon's mainfunction started becoming too much cut&pasted code. Collapsing most ofit in a daemon.GenericMain function. Some more code could be collapsedbetween the two http-based daemons, but since the new daemons won't be...
Mainloop: avoid calculating timeout every time
set timeout_needs_update to False after calculating the timeout.
Reviewed-by: imsnah
ganeti.daemon: Add timers to Mainloop
This is a fallout from my work on the HTTP client class. Repeatingtimers are prepared, but not yet implemented.
Reviewed-by: iustinp
ganeti.daemon: Make Mainloop more flexible
While working on the HTTP client class, I wanted to use Mainloopbefore deciding to use threads instead.
- Add docstrings- Rename "quit" to "running", move it to a local variable- Support adding and removing I/O listeners while running...
daemon.py: Don't wake up every second
We don't have timers yet, hence waking up is not needed at all.
Reviewed-by: ultrotter
Mainloop: handle sigterm
This fixes removals of the pid files and clean exit in the init script
Mainloop: init sigchld_handler as None
There is no point in initializing sigchld_handler as an empty dict, whenit will be overwritten by an instance of utils.SignalHandlerimmediately after.
Add daemon library with mainloop
This mainloop can be used in daemons like ganeti-noded.