[systemd-devel] [RFC PATCH] service: add FailureAction= option

Michael Olbrich m.olbrich at pengutronix.de
Sat Apr 12 02:57:02 PDT 2014


On Fri, Apr 11, 2014 at 04:07:46PM +0200, Lennart Poettering wrote:
> On Fri, 11.04.14 09:48, Michael Olbrich (m.olbrich at pengutronix.de) wrote:
> > > > +        else if (allow_restart &&
> > > 
> > > I would drop the "else" here, I think. Is there a reason not to do the
> > > restart thing anyway? If it is configured, it should run I think, just
> > > in case the failure action doesn't work or so...
> > 
> > Are you sure? With Restart=always and FailureAction=reboot this would
> > try to start the unit while shutting down. Will the Conflicts= from the
> > default dependencies handle this correctly?
> 
> It should handle this correctly, and if it doesn't we should fix this. I
> mean, my thinking here is that combining FailureAction= and
> Restart=failure might not make much sense but there isn't really a
> strong reason to totally prohibit it...

With lots of debugging enabled it looks like this:

wd-test.service failed, rebooting.
Trying to enqueue job reboot.target/start/replace
Installed new job reboot.target/start as 157
Installed new job systemd-reboot.service/start as 158
Installed new job shutdown.target/start as 159
[...]
wd-test.service changed failed -> auto-restart
wd-test.service: cgroup is empty
Accepted new private connection.
wd-test.service holdoff time over, scheduling restart.
Trying to enqueue job wd-test.service/restart/fail
[...]
wd-test.service failed to schedule restart job: Transaction is destructive.
wd-test.service changed auto-restart -> failed
Unit wd-test.service entered failed state.
wd-test.service failed, rebooting.
Trying to enqueue job reboot.target/start/replace
Merged into installed job reboot.target/start as 157
Merged into installed job systemd-reboot.service/start as 158
Merged into installed job shutdown.target/start as 159
[...]

The restart is canceled and the new reboot jobs are merged into the already
running jobs. I'd say the falls under 'handle this correctly'.
I'll send out a new patch when I'm done testing.

Michael

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


More information about the systemd-devel mailing list