<div dir="ltr"><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Mon, Jan 6, 2025 at 8:08 AM Paul Menzel <<a href="mailto:pmenzel%2Bsystemd-devel@molgen.mpg.de">pmenzel+systemd-devel@molgen.mpg.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Dear systemd folks,<br>
<br>
<br>
fwupd allows to update device firmware, and ships `fwupd-refresh.timer` <br>
and `fwupd-refresh.service` to refresh the fwupd metadata by downloading <br>
things over the network, and to update motd.<br>
<br>
Currently, if there is no network connecting during this time, the <br>
service is shown as failed. That downloading the metadata is not <br>
possible with no network connection is expected in my opinion, so the <br>
service should not be shown as failed [1]. Do you have a recommendation <br>
how to deal with this? Should `/usr/bin/fwupdmgr refresh` return a <br>
special exit code in this case, or should a condition be added? What <br>
would be used for the condition as different network manager can be used <br>
like NetworkManager or systemd-networkd.<br></blockquote><div><br></div><div>I'd say probably nothing, as systemd [as in pid1] has no idea what each system considers "a network connection is available". (For the same reason network-online.target only delegates to helper services provided by each network manager – and even those are often customized locally, e.g. I've seen people edit the *-wait-online units to take always-on VPNs into account, etc.) There may be multiple network managers, or none at all; there may be an IPv4 default route or it may be an IPv6-only network; etc.</div><div><br></div><div>Looking at Debian, its apt-daily.service (which does a similar refresh + unattended upgrade) brings its own "apt-helper wait-online" (I haven't checked what it does internally) as an ExecCondition. Maybe systemd could have a similar wait-online helper that bundles together all of the manager-specific *-wait-online tools, but currently there's no such thing [that I know of].<br></div><div><br></div><div>IMO, fwupd-refresh as a .timer seems to be somewhat of a "best effort" feature, so I would rather just make the process *not report failure at all* when the best-effort refresh fails (and maybe rename it to "fwupd-maybe-refresh"?). That is, log an error to syslog but exit with a success code of 0 (or have ExecStart=-/bin/foo to have systemd ignore the exit code).</div><div><div><br></div><div>(My line of thought was that 1) 'online' is a bit
unnecessarily broad, much like systemd also tries to avoid 'after all
devices' and such – a better check would be for the specific server that
is needed – and 2) what better check than actually trying to connect to
that server?)</div><div><br></div><div>That would certainly be less silly than 'checking for the existence of the NetworkManager binary' as someone suggested on GitHub...<br><div></div><div><br></div><div>Alternatively, since fwupd overall uses a lot of GLib2, maybe it could use its g_network_monitor_can_reach() functions? It seems that it can either talk to NM or directly check kernel routes for the specified server.<br></div></div></div><div><br></div></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr">Mantas Mikulėnas</div></div></div>