Comment by jorvi

Comment by jorvi 5 days ago

17 replies

> like "at least one real IP address is available" or "time has been synced"

"network-online.target is a target that actively waits until the network is “up”, where the definition of “up” is defined by the network management software. Usually it indicates a configured, routable IP address of some kind. Its primary purpose is to actively delay activation of services until the network has been set up."

For time sync checks, I assume one of the targets available will effectively mean a time sync has happened. Or you can do something with ExecStartPre. You could run a shell command that checks for the most recent time sync or forces one.

blibble 5 days ago

it's the "usually" that's the problem

this service (untouched by me) had:

After=local-fs.target network-online.target remote-fs.target time-sync.target

but it was still started without an IP address, and then failed to bind

just like this sort of problem: https://github.com/systemd/systemd/issues/4880#issuecomment-...

the entire thing is unreliable and doesn't act like you'd expect

> Or you can do something with ExecStartPre. You could run a shell command that checks for the most recent time sync or forces one.

at that point I might as well go back to init=/etc/rc

  • jorvi 5 days ago

    Are you running this particular unit file as a user unit or a system unit? Some targets like network-online.target don't work from user unit files.

    You could also try targeting NetworkManager or networkd's "wait-online" services. Or if that doesn't work, something is telling systemd that you have an IP when you don't. NetworkManager has "ipv4.may-fail" and "ipv6.may-fail" that might be errenously true.

    > at that point I might as well go back to init=/etc/rc

    The difference is that systemd is much better at ensuring correctness. If you write the invoked shell command properly, it'll communicate failure or success correct and systemd will then communicate that state to the unit. It's still a lot more robust than before.

    • blibble 5 days ago

      it's a system service file

      the problem is systemd

      > The difference is that systemd is much better at ensuring correctness.

      yeah, whatever mate

      • jorvi 5 days ago

        Seems like you have an axe to grind with systemd because it replaced your familiar (but extremely cruddy) init system and now you refuse to debug the problem because you prefer being able to blame systemd.

        There is so much granularity and flexibility in what you can do it seems rather unlikely you cannot make it happen correctly. And if it is truly a bug... open an issue? They're rather responsive to it. And it isn't like the legacy init systems were bug free from inception (well, lord knows they were still chock full of bugs even when they were replaced).

        Edit: sitting here with a grin .. HN downvoting the advice of checking logs, debugging and opening an issue. I wish the companies y'all work at good luck.. they'll need it.

        • blibble 4 days ago

          > Seems like you have an axe to grind with systemd because it replaced your familiar (but extremely cruddy) init system and now you refuse to debug the problem because you prefer being able to blame systemd.

          I'm a pragmatist: I just want it to work

          my solution to MULTIPLE different services failing to IP bind is to turn on the non-local ip binding sysctl, bypassing systemd's brokenness entirely

          > There is so much granularity and flexibility in what you can do it seems rather unlikely you cannot make it happen correctly.

          I've written an init before (in C), I know how the netlink interface to set an IP address and add routing table entries works

          I understand the difference between monotonic and wall clocks

          I understand the difference between Wants and Require

          I know what's going on at every, single, level

          and I can't stand how unreliable systemd makes nearly every single one of my, bluntly, completely vanilla systems

          > And if it is truly a bug... open an issue?

          did you read the link I pasted earlier?

          I'm not wasting my time with that level of idiocy (from LP himself)

    • direwolf20 5 days ago

      > Some targets like network-online.target don't work from user unit files.

      So basically it just doesn't work sometimes for no particular reason.

      > The difference is that systemd is much better at ensuring correctness

      Uh, well, you just said that it isn't, because some targets like network-online.target don't work from user unit files.

  • magicalhippo 5 days ago

    > https://github.com/systemd/systemd/issues/4880

    I'm not a systemd hater or anything, but I continue to read stuff from Poettering which to me is deeply disturbing given the programs he works on.

    Saying it's not a bug that service is launched despite a stated required prerequisite dependency failed... WTF?

    Sure, I agree with him that most computers should probably boot despite NTP being unable to sync. But proposing that the solution to that is breaking Requires is just wild to me.

    • jcgl 5 days ago

      I'm not sure I understand why you think the solution proposed there is so bad.

      The question in that issue is around the semantics of time-sync.target. Targets are synchronization points for the system and don't (afaik) generally make promises about the units that are ordered before them (in this case chrony-wait.service.

      Does that answer your specific objection of "proposing that the solution to that is breaking Requires is just wild to me"? Basically, what is proposed in that issue is not breaking Requires=. The proposition is that the user add their own, specific Requires= as a drop-in configuration since that's not a generally-applicable default.

      • magicalhippo 5 days ago

        No, that does not make sense, because it goes against the systemd documentation.

        Targets[1]: Target units do not offer any additional functionality on top of the generic functionality provided by units. They merely group units, allowing a single target name to be used in Wants= and Requires= settings to establish a dependency on a set of units defined by the target, and in Before= and After= settings to establish ordering.

        boot-complete.target[2]: Order units that shall only run when the boot process is considered successful after the target unit and pull in the target from it, also with Requires=.

        Note use of "only run" with a reference to Requires=.

        time-sync.target[3]: This target provides stricter clock accuracy guarantees than time-set.target (see above), but likely requires network communication and thus introduces unpredictable delays. Services that require clock accuracy and where network communication delays are acceptable should use this target.

        Especially note the last sentence there.

        The documentation clearly indicates that targets can fail, and that services that needs the target to be successful, should use Requires= to specify that.

        If the above is not true, the Requires= and Targets documentation should be rewritten to explicitly say that targets might fulfill Requires= regardless of state. Also, the documentation for time-sync.target should explicitly remove the last sentence and instead state there is no functional difference between Requires=time-sync.target and Wants=time-sync.target, it is best-effort only.

        [1]: https://www.freedesktop.org/software/systemd/man/latest/syst...

        [2]: https://www.freedesktop.org/software/systemd/man/latest/syst...

        [3]: https://www.freedesktop.org/software/systemd/man/latest/syst...

  • [removed] 5 days ago
    [deleted]
direwolf20 5 days ago

Is it possible for network-online to mean that, or does network-on actually mean that?

It is possible for a specification to be so abstract that it's useless.

  • jcgl 5 days ago

    That's entirely defined by whatever units order themselves before network-online.target (normally a network management daemon like NetworkManager or systemd-networkd). systemd itself doesn't define the details; that's left up to how that distro and sysadmin have configured the network manager/system.

bandrami 5 days ago

Sysadmins really hate the word "usually", and that is at the root of just about every systemd headache I've had