Cool stuff for Raspberry Pi, Arduino and all electronics hobby projects
Notifications
Clear all

[Solved / Archived] Chrony NTP service disabled by WittyPi functions (and reboot)

3 Posts
2 Users
0 Likes
231 Views
(@arjenr)
Posts: 28
Eminent Member Customer
Topic starter
 

I have full terminal output from the original situation of my Pi4B without WittyPi (L3v7), the installation of WittyPi software and eventually running the Pi with the WittyPi module installed.

It is very long, but I can probably get to what I assume is a bug by pasting the following terminal output showing the problem that the use of two particular functions in WittyPi software causes.

First a general description of my setup:

This Raspberry Pi 4B is intended as DNS server on another LAN.
It has Pi-Hole and Unbound installed already, among other software like
Mutt (email), TimeShift, PiApps (More RAM, Conky, Sublime editor and a few others).

It is currently on a LAN which already has an NTP server and so it is
just an NTP client here. Also PiHole & Unbound are not being used by client machines
on this LAN.

Eventually I will also install Wireguard on this machine and
once I get to the other, remote, LAN, I will replace its current DNS server PiHole0,
because PiHole2 will have the WittyPi UPS installed for protection against blackouts.

The routers on my LANs will also use PiHole2 as their NTP server. As DNSSEC is used in PiHole,
getting the correct time from an RTC for the router at boot up after a blackout is essential.

That is the plan ...

So I installed the wittypi software, and then the board and checked at every stage, keeping the terminal output of essential commands like

timedatectl

sudo systemctl status chrony

sudo systemctl status systemd-timesyncd

But I keep that log for later, if needed.

And this is the short 'bug report' from after setting it all up:

If in wittypi software either of these 2 functions is used:
1. RPI time < RTC time
2. Synchronize
the result is not good: chrony ends up disabled and timedatectl will show accordingly:

pi@PiHole2:~ $ sudo systemctl status chrony
○ chrony.service - chrony, an NTP client/server
Loaded: loaded (/lib/systemd/system/chrony.service; disabled; preset: enabled)
Active: inactive (dead)
Docs: man:chronyd(8)
man:chronyc(1)
man:chrony.conf(5)

sep 18 15:42:57 PiHole2 chronyd[1842]: Selected source 178.215.228.24 (nl.pool.ntp.org)
sep 18 15:42:57 PiHole2 chronyd[1842]: System clock wrong by 10.787711 seconds
sep 18 15:43:08 PiHole2 chronyd[1842]: System clock was stepped by 10.787711 seconds
sep 18 15:43:09 PiHole2 chronyd[1842]: System clock TAI offset set to 37 seconds
sep 18 15:44:15 PiHole2 chronyd[1842]: Selected source 158.101.213.248 (nl.pool.ntp.org)
sep 18 15:55:01 PiHole2 chronyd[1842]: Selected source 185.80.247.36 (nl.pool.ntp.org)
sep 18 15:56:15 PiHole2 chronyd[1842]: chronyd exiting
sep 18 15:56:15 PiHole2 systemd[1]: Stopping chrony.service - chrony, an NTP client/server...
sep 18 15:56:14 PiHole2 systemd[1]: chrony.service: Deactivated successfully.
sep 18 15:56:14 PiHole2 systemd[1]: Stopped chrony.service - chrony, an NTP client/server.
pi@PiHole2:~ $ timedatectl
Local time: wo 2024-09-18 15:57:52 CEST
Universal time: wo 2024-09-18 13:57:52 UTC
RTC time: n/a
Time zone: Europe/Amsterdam (CEST, +0200)
System clock synchronized: no
NTP service: inactive
RTC in local TZ: no

Now re-enable and start chrony service:

pi@PiHole2:~ $ sudo systemctl enable --now chrony
Synchronizing state of chrony.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable chrony
Created symlink /etc/systemd/system/chronyd.service → /lib/systemd/system/chrony.service.
Created symlink /etc/systemd/system/multi-user.target.wants/chrony.service → /lib/systemd/system/chrony.service.

pi@PiHole2:~ $ timedatectl
Local time: wo 2024-09-18 15:58:19 CEST
Universal time: wo 2024-09-18 13:58:19 UTC
RTC time: n/a
Time zone: Europe/Amsterdam (CEST, +0200)
System clock synchronized: no
NTP service: active
RTC in local TZ: no

and a few seconds later synchronization is OK ...

pi@PiHole2:~ $ timedatectl
Local time: wo 2024-09-18 15:58:22 CEST
Universal time: wo 2024-09-18 13:58:22 UTC
RTC time: n/a
Time zone: Europe/Amsterdam (CEST, +0200)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no

Somewhere in the wittypi code I noticed a command for timedatectl setting NTP service to false,
which struck me as odd ... Maybe this is where to look for the cause of the chrony NTP service getting disabled by wittypi commands.

Because chrony is also disabled whenever a pi with a WittyPI module reboots, I have had to add this command to cron:

@reboot sleep 15; sudo systemctl enable --now chrony

It is only a work-around. Chrony should be left enabled by wittypi, I think.

I would also be interested to hear from other users how they have fared with WittyPi and chrony ...

Thanks for reading this far ...

This topic was modified 2 months ago by ArjenR
 
Posted : 18/09/2024 4:35 pm
(@admin)
Posts: 479
Member Admin
 

As shown here: https://github.com/uugear/Witty-Pi-4/blob/main/Software/wittypi/utilities.sh#L357-L365

Witty Pi's softwre intentionly disables NTP service. We found that having NTP service running could cause other problems. Disabling NTP service was the simplest solution we found to avoid those problems. If you really need to get time from the network, the "Synchronize with network time" option does exactly that.

You may of couse change the utilities.sh file and don't let it to disable NTP service, however we do not recommend it.

 
Posted : 18/09/2024 4:55 pm
(@arjenr)
Posts: 28
Eminent Member Customer
Topic starter
 

Aha. That is just the place in the code that I stumbled upon by accident 😉 (Complicated bash code is not for me).

My purpose of having WittyPi UPS on this Pi (and one other) is not just keeping the system drive safe from sudden blackouts.

Since the Pi serves the local network as its only DNS server (PiHole & Unbound), and it uses DNSSEC, it needs to always have the correct time after a power out (not from the fake hwclock).

After a shutdown and later startup - now generally speaking - a Pi without RTC would have its clock way off. Too much for DNSSEC to work.

In that situation therefore the LAN DNS server will not find the IP for the NTP server on the WAN that it needs to use as an NTP client.

It is a catch-22 situation. Incorrect DNS server time > no DNS(SEC) > cannot connect to WAN NTP server > NO recovery without operator intervention ...

That is why I tried the DS3231 module first. But that doesn't take care of blackouts, of course.

Better plan: a WittyPi L3V7 not only has an RTC, but it adds UPS functionality protecting from blackouts. That is why I chose this Witty Pi.

I don't need to run the DNS server when there is no power, because the cable modem and the router will also be 'dead' (so the cut-off voltage is set to 4.2 V)

My network routers, while booting up, cannot do DNS, so they must have at least one IP-address of an NTP server (on LAN or WAN) to synchronize with.

If on my LAN there is a local DNS server with RTC I add its IP as the first on the list in the router, so it should always start up.

 

It would be interesting to know what sort of problems to expect from having an NTP service like chrony running on the Pi (as I re-enable it at reboot).

I have not yet experienced problems with the other PiHole server (PiZero 2) with a WittyPi board which is set up the same as the one I reported on in this thread with chrony.

That PiZero 2 DNS server (PiHole, Unbound) is in active use on my LAN here at my cottage, albeit not for many weeks yet.

 
Posted : 18/09/2024 5:36 pm
Join Waitlist We will inform you when the product arrives in stock. Please leave your valid email address below.