systemd sd_notify is sent before initialization is complete

Bug #1777882 reported by Matthew Booth on 2018-06-20
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo.service
Undecided
Unassigned

Bug Description

I implemented a systemd Before= constraint between ironic conductor and nova compute (for horrible reasons which aren't important here). I noticed that although ironic conductor always started first, nova compute started almost immediately after, and long before ironic conductor initialization was complete.

The manpage for systemd.service says:

Behavior of notify is similar to simple; however, it is expected that the daemon sends a notification message via sd_notify(3) or an equivalent call when it has finished starting up. systemd will proceed with starting follow-up units after this notification message has been sent.

However, both ServiceLauncher and ProcessLauncher call systemd.notify_once() at the start of the wait() call. Both of these launchers spawn a manager to run concurrently via some means and then wait() is called from the main thread, which means that the systemd notify is essentially sent immediately.

The behaviour we want is:

ServiceLauncher: notify is sent from the service thread after service.start()
ProcessLauncher: notify is sent from the main process after at least 1 (or perhaps all; discuss) worker process has run service.start()

So, for e.g. move systemd.notify_once() from ServiceLauncher.wait() to Services.run_service() after service.start(). I don't think this is quite right as I think it would interfere with ProcessLauncher, which would need a very different implementation, but you get the idea.

The systemd notifications are useless as implemented, and the behaviour of Type=notify is identical to the behaviour of Type=simple.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers