[ovs-dev] [RFC] systemd notification integration

Ben Pfaff blp at ovn.org
Wed Aug 10 21:51:28 UTC 2016


On Wed, Aug 10, 2016 at 10:26:15PM +0200, Christian Svensson wrote:
> Hi,
> 
> On Wed, Aug 10, 2016 at 6:15 PM, Ben Pfaff <blp at ovn.org> wrote:
> 
> > This is how OVS works.
> >
> 
> Only when specifically launched with --detach. It's not the binary default,
> which I feel is important to note.
> 
> 
> > What's the advantage of sd_notify?  You say that sd_notify() is
> > "recommended".  By whom, and where?  And with what benefit?
> >
> The recommendation is by systemd developers argued in the threads I linked
> earlier.
> I think you actually quoted some of the drawbacks, but I'll explain some of
> the ones I'm aware off.
> 
> Basically the reason forking is not great is that you lose access to a
> bunch of things like:
> 1. return code of the process
> 2. which PID is the master process
> 
> Point 2 is solved by having PID files, but those are inherently painful and
> racy as well. Reading the PID to find out if the process is still running
> requires trickery like making sure the PID is:
> 1. Alive
> and
> 2. The same process as you expect (due to PID recycling).

Hmm.  I think that OVS actually solves all of these problems.  First,
the return code of the parent should be correct, in that if the child
fails to start properly the parent exits with a nonzero exit code.
Second, observers can ensure that the pidfile is tied to a running
process by checking that the pidfile is locked (with fcntl) by the
process.

> Furthermore, as you're doing a fork - you're limited in what you can do
> when. It's fundamentally more difficult to write software that uses threads
> that also need to use fork() for example.
> OVS has nice semantics for this, so assuming the developer uses the
> daemonize constructs provided correctly there should be no problem - but
> that could be said about a lot of things.
> 
> And finally, to return to my initial point, it provides a way to run a
> service in the default mode - non-detached.

I guess in the end it's probably not a big deal to me to add this
systemd integration, assuming that whatever library systemd requires for
it is easy to integrate with and has a stable API/ABI.

I suggest sending a patch.

Thanks,

Ben.



More information about the dev mailing list