[systemd-devel] Antw: [EXT] Re: Q: handling generator-like dependency: target won't start on boot
Ulrich Windl
Ulrich.Windl at rz.uni-regensburg.de
Thu Sep 29 06:41:01 UTC 2022
>>> Andrei Borzenkov <arvidjaar at gmail.com> schrieb am 28.09.2022 um 20:34 in
Nachricht <f287dedb-a58d-d4db-d25e-9bac20d585f7 at gmail.com>:
> On 28.09.2022 09:25, Ulrich Windl wrote:
>> Hi!
>>
>> I'm trying to establish a mechanism that uses a generator-like mechanism as
> described below. Unfortunately it starts when triggering the target manually,
> but it never starts on system boot. I could need some advice how to make it
> work.
>>
>> Basically I have a generator-like unit, say "g.servive", that creates other
> instance-like services like i at .service.
>> Finally I have a target, say "t.target", that wants (among others) those
> instance-like services and is wanted by default.target.
>>
>> As said in the beginning: When booting the target does not start (and I
> don't see any errors logged), but when I "systemctl start t.target",
> everything starts up fine.
>>
>> More details:
>>
>> generator-like services:
>> WantedBy default.target and t.target, and it "Wants=nss-user-lookup.target
> time-sync.target paths.target" (the Before= list is identical). In addition
> it has "Before=default.target t.target".
>> It starts a "oneshot" script that creates the instance-like services with
> RemainAfterExit=true.
>>
>> instance-like services:
>> PartOf=t.target, Requires generator-like.service (also After that service).
> In addition it "Wants=nss-user-lookup.target time-sync.target paths.target"
> (After= uses the same list). The service is Type=forking, and the unit is
> WantedBy=t.target
>>
>> The script used in the generator-like service creates the unit files in
> /run/systemd/system, and it runs "/usr/bin/systemctl daemon-reload" whenever
> a unit file had been created or changed.
>>
>
> daemon-reload does not re-evaluate initial "transaction" and your new
> units are not used because they did not exist when this transaction was
> computed.
Hi!
I don't quite understand what an "initial transaction" is, but is sounds like a design deficit:
The "real generators" (initially I wanted to use those) are too limited (i.e..: started too early in the boot process) to be useful. I also noticed that daemon-reload seems to re-run the generators (like systemd-sysv-generator), so I wonder what use it will be if such generated units are being ignored.
At least what you write seems to explain what I see so far.
Would it work to write yet another unit that starts t.target? If that would work, it clearly demonstrates the design problem in systemd.
Regards,
Ulrich
>
> So the only way to squeeze it into your scheme is to manually start
> newly created units.
>
>> Could be problem be a race-condition, caused by daemon-reload being run
> asynchronously, i.e.: The generator-like service unit ends while the actual
> daemon-reload is still in progress?
>>
>> systemd version is from SLES12 SP5 (systemd-228-157.40.1.x86_64).
>>
>> Regards,
>> Ulrich
>>
>>
>>
More information about the systemd-devel
mailing list