On Mi, 18.01.23 10:19, Gordon Messmer (gordon.mess...@gmail.com) wrote:

> There was also discussion of disabling the service by default and using a
> generator to enable the service, and Lennart thought this was the best
> solution.  I started work to add a simple generator, but the documentation
> for systemd.generator states "Non-essential file systems like /var/ and
> /home/ are mounted after generators have run," and the purpose of the
> generator would be to enable the service when there are files in
> /var/lib/iscsi/nodes.

So yeah, this is a mess, indeed.

We have been thinking in systemd if we shouldn't tighten the
requirements a bit and dictate that in future /var/ has to be mounted
at the moment of the initrd → host transition. That would make the
problem go away. We currently require that the root fs and /usr/ are
already mounted during the transition. It's not *thaaaaat* much more
to require /var/, too.

But I guess that is more a long term thing.

What you could do is split up the problem: have iscsi-starter.service
or so, that is separate from the iscsi.service main service. The
former's job would be to scan if iscsi volumes are configured. If it
finds configured ones, it would then issue "systemctl start --no-block
iscsi.service" to enqueue a start job for the real thing.

Then, the starter unit would not be ordered after the wait-online
service, but the real iscsi one would be.

Finally, iscsi.service's [Install] section would not carry any
WantedBy= lines or so, i.e. would not hook itself into anything if
enabled. Instead it would only carry Also=iscsi-starter.service there,
which would basically "redirect" enablement to the starter
service. And the starter service would then do
WantedBy=sysinit.target to hook itself into the early boot.

Both services would use DefaultDependencies=no, and the starter
service would use RequiresMountsFor=/var/lib/iscsi/nodes so that it
waits exactly until its /var/ dir is up, but not more.

The starter service could probably look roughly like this btw:

<snip>
[Unit]
DefaultDependencies=no
Before=sysinit.target iscsi.service
RequiresMountsFor=/var/lib/iscsi/nodes
ConditionDirectoryNotEmpty=/var/lib/iscsi/nodes

[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/usr/bin/systemctl start --no-block --job-mode=fail iscsi.service
</snip>

Lennart

--
Lennart Poettering, Berlin
_______________________________________________
devel mailing list -- devel@lists.fedoraproject.org
To unsubscribe send an email to devel-le...@lists.fedoraproject.org
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/devel@lists.fedoraproject.org
Do not reply to spam, report it: 
https://pagure.io/fedora-infrastructure/new_issue

Reply via email to