[systemd-devel] Requires and After

Michael Chapman mike at very.puzzling.org
Thu Jan 3 07:06:10 UTC 2019


On Thu, 3 Jan 2019, Jonathon Kowalski wrote:
> On Wed, 2 Jan 2019, Jérémy Rosen wrote:
> > I'm pretty sure that there is something about Requires making a unit fail if
> > it's dependency has already failed when it is scheduled for startup...
> >
> > Again I may be wrong...
> 
> On Wed, 2 Jan 2019, Michael Chapman wrote
> >Make of that what you will. I was expecting a.service to stop because
> >b.service failed, but apparently my understanding of this isn't quite
> >right.
> 
> Requires= alone without After= has interesting interaction with
> systemd's job machinery.
> 
> When you use Requires= alone, say from a to b (as in Michael's
> example), two start jobs will be queued for both as part of the
> transaction, but the one for a will not wait for the one for b to
> complete running. Therefore, both go in parallel, and at one point, if
> a completes before b, it will start up as usual. However, if b fails
> before a completes, the start job for a is canceled with
> JOB_DEPENDENCY job result. Hence, in your case, the job is dispatched
> right away and completes before b fails.

For what it's worth, I was quite aware of the issues in omitting any 
ordering dependency with these units. However, I was expecting a.service 
to be stopped whether or not b.service failed before or after a.service 
had become active.

I'll have to do further testing to nail down the behaviour precisely. The 
documentation certainly seems to indicate that no matter how and no matter 
when b.service gets stopped, a.service would be stopped.


More information about the systemd-devel mailing list