If the post-start job takes longer than the primary job no "started" event is emitted

Bug #1277737 reported by Ted Gould
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
upstart
New
Undecided
Unassigned

Bug Description

If I create a job that looks like this:

script
    sleep 5
end script
post-start script
    sleep 10
end script

Then what I see is these state transitions:

$ dbus-monitor member=StateChanged
signal sender=org.freedesktop.DBus -> dest=:1.307 serial=2 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameAcquired
   string ":1.307"
signal sender=:1.0 -> dest=(null destination) serial=712 path=/com/ubuntu/Upstart/jobs/slow_2dpost/_; interface=com.ubuntu.Upstart0_6.Instance; member=StateChanged
   string "starting"
signal sender=:1.0 -> dest=(null destination) serial=713 path=/com/ubuntu/Upstart/jobs/slow_2dpost/_; interface=com.ubuntu.Upstart0_6.Instance; member=StateChanged
   string "security"
signal sender=:1.0 -> dest=(null destination) serial=714 path=/com/ubuntu/Upstart/jobs/slow_2dpost/_; interface=com.ubuntu.Upstart0_6.Instance; member=StateChanged
   string "pre-start"
signal sender=:1.0 -> dest=(null destination) serial=715 path=/com/ubuntu/Upstart/jobs/slow_2dpost/_; interface=com.ubuntu.Upstart0_6.Instance; member=StateChanged
   string "spawned"
signal sender=:1.0 -> dest=(null destination) serial=716 path=/com/ubuntu/Upstart/jobs/slow_2dpost/_; interface=com.ubuntu.Upstart0_6.Instance; member=StateChanged
   string "post-start"
signal sender=:1.0 -> dest=(null destination) serial=719 path=/com/ubuntu/Upstart/jobs/slow_2dpost/_; interface=com.ubuntu.Upstart0_6.Instance; member=StateChanged
   string "stopping"
signal sender=:1.0 -> dest=(null destination) serial=720 path=/com/ubuntu/Upstart/jobs/slow_2dpost/_; interface=com.ubuntu.Upstart0_6.Instance; member=StateChanged
   string "killed"
signal sender=:1.0 -> dest=(null destination) serial=721 path=/com/ubuntu/Upstart/jobs/slow_2dpost/_; interface=com.ubuntu.Upstart0_6.Instance; member=StateChanged
   string "post-stop"
signal sender=:1.0 -> dest=(null destination) serial=722 path=/com/ubuntu/Upstart/jobs/slow_2dpost/_; interface=com.ubuntu.Upstart0_6.Instance; member=StateChanged
   string "waiting"

The result of not ever going into the running state is that we don't get the "started" signal emitted onto DBus. It seems to me that it was started, and it ran, so the started signal should be emitted.

Ted Gould (ted)
description: updated
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

Main process has finished, before post-start managed to complete. Arguably, we should only emit "started" if there still was a main process still around. The job is quite artificial as it's not a long running process/daemon. But even with "task" stanza started is not emitted.

<xnox> tedg: what's the real-world usecase ?
<tedg> The case I'm seeing it is in the security confinement tests.
<tedg> They test to ensure that the started applications are confined. But they do so rather quicly.
<tedg> xnox, https://wiki.ubuntu.com/Touch/Testing#Running_Security_tests

So i believe we should fix those tests suites to not be racy and actually leave the main process around for long enough to be inspected & validated.

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

Minimal test case:
exec sleep 1
post-start exec sleep 2

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

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.