On Thu, Feb 24, 2022, at 6:17 AM, Benjamin Berg wrote:

> network-online-waitonly.target with
>   After=network-online.target
>   StopWhenUnneeded=yes
>
> which is then used inside iscsi.service
>   ExecStartPre=/usr/bin/systemctl start network-online-waitonly.target

No, avoid such things unless absolutely necessary - it makes the dependency 
graph dynamic, which systemd does support but doing so brings a vast amount of 
complexity.

I think instead you can use e.g. a systemd generator:
https://www.freedesktop.org/software/systemd/man/systemd.generator.html
The generator (which can be the same binary) can then enable iscsi.service only 
if the directory is non-empty.

(Which is making things dynamic, but all dynamic computation happens at a 
well-defined eraly fixed point and is acted on together thereafter)

Now I'd agree this behavior is not obvious, and perhaps systemd should gain 
something like
EnableConditionDirectoryNotEmpty= that is defined to be evaluated at the same 
time as generators or so, and if the conditions evaluate to false then none of 
the unit dependencies will be pulled in either.

_______________________________________________
devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/[email protected]
Do not reply to spam on the list, report it: 
https://pagure.io/fedora-infrastructure

Reply via email to