[systemd-devel] Filtering logs of a single execution of a (transient) service

Lennart Poettering lennart at poettering.net
Fri Apr 6 10:27:31 UTC 2018


On Fr, 23.03.18 13:31, Filipe Brandenburger (filbranden at google.com) wrote:

> > systemd-run currently doesn't show you the invocation ID however, but
> > I figure this is something we should really fix.
> 
> I can look into pushing a PR for that...

That'd be excellent. It should be possible to simply query the field
off the unit bus object right after the startup job we enqueued
finished. This of course means this can only work if --non-block is
not used (because in that case we just enqueue the job to start the
unit, but don't wait for it to actually start, and thus don't wait for
the invocation ID to be determined).

It's also a tiny bit racy: in theory somebody could run a unit by the
same name right after we started ours, and then we possibly might
query the invocation of that second run. Fixing this racy is very hard
however (it would probably entail extending the JobDone bus message to
include the invocation ID, but dbus isn't really friendly to such
extensions). An alternative approach to fixing this race might be
instead strictly enforce that transient units are never started more
than once, and then making use of the "AddRef" concept which allows
clients to pin a unit into memory while the client runs. Both together
mean that the unit could not be started a second time, and that it
can't be GC'ed and replaced by a different but identically named unit
either.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list