#1044133 apt-cacher-ng: please provide a native systemd .timer

Package:
apt-cacher-ng
Source:
apt-cacher-ng
Description:
caching proxy server for software repositories
Submitter:
Alexandre Detiste
Date:
2023-09-04 06:21:03 UTC
Severity:
normal
#1044133#5
Date:
2023-08-13 14:41:57 UTC
From:
To:
/etc/cron.daily/apt-cacher-ng seems to work when
run through Vixie-cron + run-parts
but fails when run through systemd-cron.

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1040304

After a lot of trial and error I still
can't grasp what ACNG expected in the environment.

I works ok when run manually from a root shell.

Providing your own .timer & .service for the daily
task would solve this problem but also
make this job easier to debug.

Greetings,



Here are the generated .timer & .service that trigger this behaviour.

# /run/systemd/generator/cron-daily-apt-cacher-ng.timer
[Unit]
Description=[Timer] "/etc/cron.daily/apt-cacher-ng"
Documentation=man:systemd-crontab-generator(8)
PartOf=cron.target
SourcePath=/etc/cron.daily/apt-cacher-ng

[Timer]
OnCalendar=*-*-* 6:10:0
Persistent=true

# /run/systemd/generator/cron-daily-apt-cacher-ng.service
[Unit]
Description=[Cron] "/etc/cron.daily/apt-cacher-ng"
Documentation=man:systemd-crontab-generator(8)
SourcePath=/etc/cron.daily/apt-cacher-ng
OnFailure=cron-failure@%i.service

[Service]
Type=oneshot
IgnoreSIGPIPE=false
KillMode=process                                    # -> does it needs "forking" ???
ExecStart=/etc/cron.daily/apt-cacher-ng
User=root

#1044133#10
Date:
2023-09-04 06:19:02 UTC
From:
To:
Notice that the cron package is not installed by default in Debian 12
bookworm, so a systemd .timer unit will make acng maintenance script
working even in minimal configuration.

I think, the approach used by apt is applicable to apt-cacher-ng as
well: /lib/systemd/system/apt-daily.timer and
/lib/systemd/system/apt-daily.service files for systemd and
/etc/cron.daily/apt-compat has the following check

if [ -d /run/systemd/system ]; then
     exit 0
fi

Both the .service unit and the cron job execute
/usr/lib/apt/apt.systemd.daily helper.

I do not see the issue with pure systemd timer.

May it happen that apt-cacher-ng process was not running for some reason
when the maintenance task was started? Another hypothesis is that
generated systemd unit is running in so strict isolation that network is
unavailable to it.

Check Protect*, Private* and similar properties in the output of

   systemctl show cron-daily-apt-cacher-ng.service
   systemctl cat cron-daily-apt-cacher-ng.service