From 03ed6719b057421ab6e46c407c7b13c23faa6d4e Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Wed, 11 Nov 2026 21:52:39 +0900 Subject: [PATCH] feat(host): start k3s only after the clock is synchronized The desktop dual-boots Windows, which writes local time (KST) to the RTC, while Ubuntu reads the RTC as UTC. On 2026-11-11 the boot started 9 hours ahead; k3s issued its certificates at that time, timesyncd then set the clock back, the certificates were not yet valid, and every Ingress returned 502 until k3s was restarted by hand. Add a k3s.service drop-in with Wants= and After=time-sync.target, and a drop-in that caps systemd-time-wait-sync.service at 10 minutes. Enabling systemd-time-wait-sync makes time-sync.target wait for the first NTP sync; its packaged TimeoutStartSec=infinity would keep k3s down forever when NTP is unreachable, so after 10 minutes it fails, the target is reached anyway and k3s starts as it does today. Risk: the order only applies at boot, so nothing changes until the next reboot. If NTP is down at boot, k3s starts 10 minutes later. The Windows side still writes local time until RealTimeIsUniversal is set there; the host guide covers that step. Verification: systemd-analyze verify passes for k3s.service and systemd-time-wait-sync.service with the drop-ins, and an unknown key added to each drop-in is reported, so both files are read. --- .../host/systemd/k3s.service.d/10-after-time-sync.conf | 9 +++++++++ .../systemd-time-wait-sync.service.d/10-timeout.conf | 5 +++++ 2 files changed, 14 insertions(+) create mode 100644 infrastructure/host/systemd/k3s.service.d/10-after-time-sync.conf create mode 100644 infrastructure/host/systemd/systemd-time-wait-sync.service.d/10-timeout.conf diff --git a/infrastructure/host/systemd/k3s.service.d/10-after-time-sync.conf b/infrastructure/host/systemd/k3s.service.d/10-after-time-sync.conf new file mode 100644 index 0000000..05b4891 --- /dev/null +++ b/infrastructure/host/systemd/k3s.service.d/10-after-time-sync.conf @@ -0,0 +1,9 @@ +# Start k3s only after the system clock is synchronized. +# k3s writes certificates with the current time at start. If the clock is +# wrong at boot (RTC read 9 hours ahead on 2026-11-11) and NTP corrects it +# later, those certificates are "not yet valid" and every Ingress returns 502. +# time-sync.target is reached only when systemd-time-wait-sync.service is +# enabled. See infrastructure/host/README.md. +[Unit] +Wants=time-sync.target +After=time-sync.target diff --git a/infrastructure/host/systemd/systemd-time-wait-sync.service.d/10-timeout.conf b/infrastructure/host/systemd/systemd-time-wait-sync.service.d/10-timeout.conf new file mode 100644 index 0000000..3d1993d --- /dev/null +++ b/infrastructure/host/systemd/systemd-time-wait-sync.service.d/10-timeout.conf @@ -0,0 +1,5 @@ +# The packaged unit waits forever (TimeoutStartSec=infinity). If NTP is not +# reachable at boot, k3s would never start. After 10 minutes this unit fails, +# time-sync.target is reached anyway, and k3s starts with the clock it has. +[Service] +TimeoutStartSec=10min