bitsy-ai / printnanny-os

Image repository, change logs, and issue tracking for PrintNanny OS
GNU Affero General Public License v3.0
23 stars 2 forks source link

System time gets reset on reboot #267

Closed leigh-johnson closed 1 year ago

leigh-johnson commented 1 year ago

Describe the bug

We need to configure an NTP server.

Original report:

The time keeps getting reset on the OS. This results in cloud sync, Tailscale, etc. breaking due to errors similar to "certificate is not yet valid". I can set the clock fine using "date" but it gets reset on reboot to some time on the day 2022-11-08. I was trying to set the hardware clock using "hwclock" as I do in other Linux distributions but it can't find the clock for printnanny-os. Do you know of a way to permanently set the clock?

leigh-johnson commented 1 year ago

I'm seeing the correct system time reported during kernel boot stages:

Feb 15 19:38:25 travelpi syslogd[397]: syslogd v2.4.4: restart.
Feb 15 19:38:25 travelpi systemd[1]: Finished IPv6 Packet Filtering Framework.
Feb 15 19:38:10 travelpi kernel: Booting Linux on physical CPU 0x0000000000 [0x410fd083]
Feb 15 19:38:10 travelpi kernel: Linux version 5.15.87-v8 (oe-user@oe-host) (aarch64-bitsy-linux-gcc (GCC) 12.2.0, GNU ld (GNU Binutils) 2.39.0.20220819) #1 SMP PREEMPT Fri Jan 13 16:51:07 UTC 2023

ntpd is now running:

Feb 15 19:38:25 travelpi systemd[1]: Finished Network Time Service (one-shot ntpdate mode).
Feb 15 19:38:26 travelpi ntpd[463]: ntpd 4.2.8p15@1.3728-o Tue Jun 23 09:22:22 AM UTC 2020 (1): Starting
Feb 15 19:38:26 travelpi ntpd[463]: Command line: /usr/sbin/ntpd -u ntp:ntp -p /run/ntpd.pid -g
Feb 15 19:38:26 travelpi ntpd[463]: ----------------------------------------------------
Feb 15 19:38:26 travelpi ntpd[463]: ntp-4 is maintained by Network Time Foundation,
Feb 15 19:38:26 travelpi ntpd[463]: Inc. (NTF), a non-profit 501(c)(3) public-benefit
Feb 15 19:38:26 travelpi ntpd[463]: corporation.  Support and training for ntp-4 are
Feb 15 19:38:26 travelpi ntpd[463]: available at https://www.nwtime.org/support
Feb 15 19:38:26 travelpi ntpd[463]: ----------------------------------------------------
Feb 15 19:38:26 travelpi ntpd[471]: proto: precision = 0.444 usec (-21)
Feb 15 19:38:26 travelpi ntpd[471]: basedate set to 2020-06-11
Feb 15 19:38:26 travelpi ntpd[471]: gps base set to 2020-06-14 (week 2110)
Feb 15 19:38:26 travelpi ntpd[471]: Listen and drop on 0 v6wildcard [::]:123
Feb 15 19:38:26 travelpi ntpd[471]: Listen and drop on 1 v4wildcard 0.0.0.0:123
Feb 15 19:38:26 travelpi ntpd[471]: Listen normally on 2 lo 127.0.0.1:123
Feb 15 19:38:26 travelpi ntpd[471]: Listen normally on 3 lo [::1]:123
Feb 15 19:38:26 travelpi ntpd[471]: bind(20) AF_INET6 fe80::dea6:32ff:feb0:65d%3#123 flags 0x11 failed: Cannot assign requested address
Feb 15 19:38:26 travelpi ntpd[471]: unable to create socket on wlan0 (4) for fe80::dea6:32ff:feb0:65d%3#123
Feb 15 19:38:26 travelpi ntpd[471]: failed to init interface for address fe80::dea6:32ff:feb0:65d%3
Feb 15 19:38:26 travelpi ntpd[471]: Listening on routing socket on fd #20 for interface updates
Feb 15 19:38:26 travelpi ntpd[471]: kernel reports TIME_ERROR: 0x41: Clock Unsynchronized
Feb 15 19:38:28 travelpi ntpd[471]: Listen normally on 5 wlan0 [fe80::dea6:32ff:feb0:65d%3]:123
Feb 15 19:38:34 travelpi ntpd[471]: Listen normally on 6 wlan0 192.168.18.69:123
Feb 15 19:39:10 travelpi systemd-timesyncd[310]: Contacted time server 89.140.186.3:123 (2.pool.ntp.org).

Since Raspberry Pi doesn't have a lithium battery RTC, you'll still see inconsistent system times on a Pi without an internet connection. We're using a public NTP server pool to configure system time. I'll add a distro-specific NTP server pool for PrintNanny Linux once we hit ~500 DAU.

I have an enterprise customer with an air-gapped setup, who will configure NTP servers using cloud-init.

leigh-johnson commented 1 year ago

Follow-up: I'm going to disable ntpd and rely on systemd-timesyncd, since we just need an ntp client. I think ntpd is getting pulled in via the base ntp yocto package.