You are not logged in.

#1 2018-01-20 03:43:28

luser
Member
Registered: 2016-08-27
Posts: 114

[solved] reflector.timer fails after suspend

I have followed the reflector.service (and timer) wiki, and I'm using the following files:

reflector.service

[Unit]
Description=Pacman mirrorlist update
Requires=network-online.target
After=network-online.target

[Service]
Type=oneshot
ExecStart=/usr/bin/reflector --country 'United States' --age 24 --protocol http --protocol https --sort rate --save /etc/pacman.d/mirrorlist

reflector.timer

[Unit]
Description=Run reflector every day

[Timer]
OnCalendar= *-*-* 18:50:00
RandomizedDelaySec=5min
Persistent=true

[Install]
WantedBy=timers.target

I enabled reflector.timer and NetworkManager-wait-online.service
I typically suspend and resume when I use my machine, this seems to work as long as I resume the machine before 18:50. But after the timer has triggered, there is a problem when the system resumes. It appears that immediately upon resuming, the network is detected as being up, but then it goes down for 3 seconds before it's up again. As soon as the service detects that the network is up, it tries to execute, but it fails, because the network goes down for 3 seconds at that point. Here are excerpts from journalctl that lead me to believe this is the problem:

journalctl output:

Jan 19 18:51:19 random6 NetworkManager[362]: <info>  [1516416679.1984] manager: NetworkManager state is now CONNECTED_SITE
Jan 19 18:51:19 random6 NetworkManager[362]: <info>  [1516416679.1989] dns-mgr: Removing DNS information from /usr/bin/resolvconf
Jan 19 18:51:19 random6 NetworkManager[362]: <info>  [1516416679.3026] manager: NetworkManager state is now CONNECTED_LOCAL
Jan 19 18:51:19 random6 NetworkManager[362]: <info>  [1516416679.4147] manager: NetworkManager state is now DISCONNECTED

reflector.service status:

Jan 19 18:51:19 random6 systemd[1]: Starting Pacman mirrorlist update...
Jan 19 18:51:19 random6 reflector[8779]: error: failed to retrieve mirror data: (<urlopen error [Errno -2] Name or servic
Jan 19 18:51:19 random6 systemd[1]: reflector.service: Main process exited, code=exited, status=1/FAILURE
Jan 19 18:51:19 random6 systemd[1]: reflector.service: Failed with result 'exit-code'.
Jan 19 18:51:19 random6 systemd[1]: Failed to start Pacman mirrorlist update.

journalctl output 3 seconds later:

Jan 19 18:51:22 random6 NetworkManager[362]: <info>  [1516416682.7465] manager: NetworkManager state is now CONNECTED_LOCAL
Jan 19 18:51:22 random6 kdeinit5[730]: networkmanager-qt: virtual void NetworkManager::ActiveConnectionPrivate::propertyChanged(const QString&, const QVariant&) Unhandled property "StateFlags"
Jan 19 18:51:22 random6 plasmashell[828]: networkmanager-qt: virtual void NetworkManager::ActiveConnectionPrivate::propertyChanged(const QString&, const QVariant&) Unhandled property "StateFlags"
Jan 19 18:51:22 random6 NetworkManager[362]: <info>  [1516416682.8567] manager: NetworkManager state is now CONNECTED_SITE
Jan 19 18:51:22 random6 NetworkManager[362]: <info>  [1516416682.8569] policy: set 'Wired connection 1' (enp0s25) as default for IPv4 routing and DNS
Jan 19 18:51:22 random6 NetworkManager[362]: <info>  [1516416682.8571] dns-mgr: Writing DNS information to /usr/bin/resolvconf
Jan 19 18:51:22 random6 NetworkManager[362]: <info>  [1516416682.9415] device (enp0s25): Activation: successful, device activated.
Jan 19 18:51:24 random6 NetworkManager[362]: <info>  [1516416684.3261] manager: NetworkManager state is now CONNECTED_GLOBAL

Does anyone have any suggestions for making this work when resuming after the timer has expired? I suspend my machines frequently rather than powering them off. I may well have a machine suspended when the timer would trip. When it wakes up, the mirrorlist is not updated, but the timer is reset, and the same issue may recur the next day. So this is not a satisfactory solution so far. Note that 18:50 is not my preferred time; I just used it to illustrate the problem.

The essential problem lies with network-online.target which is clarified in man systemd.special:
          "Note that this unit is only useful during the original system start-up logic. After the system has
           completed booting up, it will not track the online state of the system anymore. Due to this it cannot
           be used as a network connection monitor concept, it is purely a one-time system start-up concept."

There really ought to be a way to set a timer on a service and have it reliably triggered at the set time or the next time the machine resumes or restarts after the set time. The recommended way only seems to work reliably if you reboot rather than suspend. . . So, does anyone know how to make it reliable when also suspending?

Last edited by luser (2018-03-14 21:34:32)


luser: an epithet applied by Windows users to linux users

Offline

#2 2018-03-14 21:33:52

luser
Member
Registered: 2016-08-27
Posts: 114

Re: [solved] reflector.timer fails after suspend

I've resolved this issue by giving up on reflector.timer and simply using the reflector service to update the mirrorlist every time I update pacman. I have found that running the reflector service once a day is actually not enough, if you update twice a day; a mirrorlist even 12 hours old can be too old to give optimum results on a pacman update. Lately, there have been a lot of updates for the software I use, and updating twice a day isn't nearly as ridiculous as I once thought. Anyway, however frequently or infrequently you update, you better make sure your mirrorlist is fresh when you do.

This way, whether I update twice a day or twice a week, the mirrorlist is always up to date. I put a little script in /usr/local/bin to save typing.

pu.sh

#!/bin/bash
sudo systemctl start reflector
sudo pacman -Syyu

Last edited by luser (2018-03-14 21:41:34)


luser: an epithet applied by Windows users to linux users

Offline

Board footer

Powered by FluxBB