Bug#1120743: apt.systemd.daily update fails because it runs before network interfaces are ready
On Sat, Nov 15, 2025 at 08:22:23PM +0100, Julian Andres Klode wrote:
> On Sat, Nov 15, 2025 at 10:20:07AM -0800, Petter H wrote:
> > Package: apt
> > Version: 3.0.3
> >
> > (Likely affects multiple versions)
> >
> > unattended-upgrades was not working (I let it try and fail for over a month
> > while there were known updates available, it never worked). The problem was
> > with /usr/lib/apt/apt.systemd.daily.
> >
> > 'apt.systemd.daily update' was invoked, by systemd, after system wake from
> > suspend, before the network was available. Even though it was unsuccessful,
> > it still touched the timestamp file indicating it had already ran that day.
> > Subsequent attempts to run would simply be skipped, since apt.systemd.daily
> > checks the timestamp file, and aborts if the stamp file indicates it has
> > already ran that day.
> >
> > The update failing because the script was run before network interfaces were
> > up, after a suspend/wake, was apparently a known issue, as a partial work
> > around was already included in apt-daily.service.
> >
> > apt-daily.service includes the line:
> > ExecStartPre=-/usr/lib/apt/apt-helper wait-online
> >
> > But, 'apt-helper wait-online' does nothing when using ifupdown. You can
> > down the interface entirely, and 'apt-helper wait-online' will still,
> > immediately, return with a zero exit code, the apt.systemd.daily script will
> > attempt, unsuccessfully, to do the apt update, but the script will set the
> > flag, as if it was successful, so no further attempts will run that same
> > day.
> >
> > Per this Ubuntu bug report where it appears 'apt-helper wait-online' was
> > introduced, there was no attempt to make it work for anything but systemd
> > networkd and network manager.
> >
> > https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1699850
>
> This is wrong, we also support connman.
>
> >
> > Per that bug report, 'apt-helper wait-online' waits up to 60 minutes for the
> > network to become available. The following hacky line, added to
> > apt-daily.service, accomplishes the same, and works regardless of how
> > network interfaces are managed.
> >
> > # try once per minute for 60 minutes to see if network ready, if yes,
> > continue
> > ExecStartPre=/bin/bash -c "for ((i=1; i<60; i++)); do nc -z -w 1
> > deb.debian.org 80 2>/dev/null && break || sleep 60; done"
>
> This is not an acceptable way of waiting for online connectiveness.
Sorry I did not add detail; I'm in a terrible stressed out place from
the boredom of a week off work.
So we can't go randomly phone home for privacy reasons; the
real solution is to check if a source is online and then update it
which is I think where we might just go once the daemon exists.
--
debian developer - deb.li/jak | jak-linux.org - free software dev
ubuntu core developer i speak de, en
Reply to: