Repository navigation
feat(time): time zone and NTP settings; DHCP NTP servers are used - #38
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The menu keeps the time zone and the NTP servers in [time] of config.toml and renders them into generated/time (zone= and ntp= lines), which the initramfs and thinfloe-time read as root. Zones come from zone.tab plus UTC; servers are IP literals or LDH host names, at most 8. A broken config.toml rebuilds [time] from generated/time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
thinfloe-time apply (run by the menu through sudo -n) reads generated/time of tfuser's home, found through the passwd entry, refuses links, non-regular files, files over 64 KiB and any bad line, and only then installs /etc/thinfloe/time, the zone (timedatectl) and the chrony sources. Menu servers replace the Ubuntu pools, whose file is renamed aside and back. The DHCP watcher is restarted so automatic mode takes the lease again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
chrony reads DHCP servers from /run/chrony-dhcp, which only dhclient hooks or NetworkManager fill; ThinFloe has neither, so the NTP= of the lease (option 42) was never used and a network without internet access never synced the clock. dhcp-timezone now writes those addresses (IP literals only, at most 8) to /run/chrony-dhcp/thinfloe.sources and reloads chrony on a change. With a zone or servers set in the menu (/etc/thinfloe/time) the DHCP zone is not set and the DHCP servers are removed. The zone it sets is kept in /run/thinfloe/state/dhcp-timezone for the menu's "from DHCP" label. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…h-root install_local_time reads generated/time of the restored home and writes /etc/thinfloe/time, the /etc/localtime link and the chrony sources (with the Ubuntu pools set aside) into the new root, so chrony and the clock start with the menu's choice. A zone must be UTC or listed in zone.tab; a bad line is logged and skipped, a link on the path is refused, and the function always returns 0. Only builtins and ln, mv, mkdir, printf. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Network tab's status poll also reads the zone behind /etc/localtime, where it comes from (the menu's /etc/thinfloe/time, the zone dhcp-timezone recorded, or neither), and chrony's tracking and sources through chronyc -c, as the user, 2 s each. timetab.rs parses and words them; the offset is kept in microseconds so the job result stays Eq. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… smoke check Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The band after DNS holds the zone selects (region, then city), the NTP servers field and the clock's sync lines. A choice is saved at once as [time] and installed with `sudo -n thinfloe-time apply` (Job::TimeSave, one at a time, a newer one waits), outside the Network Apply group: it takes clicks before the network files are read and while an Apply runs. The NTP field shares the lookup address's pending-event slot; the public IP field no longer overwrites that slot, so a commit of the NTP field and a click on the public IP switch in one frame both arrive. Back drops NTP servers typed and not taken, as it does the lookup address. The Network tab tests draw on a 2400-point screen (NET_SCREEN_H): with the Time band the page no longer fits on 1600 points and the public IP band scrolled out of the tests' view. The 1080p scroll test now also reaches the Time zone, NTP servers and Lookup address rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The from_generated round trip now carries a [time] setting, so a lost read-back of generated/time fails it; tracking_not_synced gains a line with a source and a stratum whose leap status is "Not synchronised", which only the leap-status check refuses. Both were found by breaking the code under test (the TDD red step tasks 1 and 5 had skipped). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ntp_ok accepted any string of hex digits, colons and dots that held a colon. It now also wants at least two colons and one hex digit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e DHCP servers thinfloe-time apply ran chronyc reload sources on every apply and failed when it failed, so a zone change could fail on a chrony problem. It now reloads only when a sources file was written, renamed or removed, or when the last reload failed (/run/thinfloe/time.reload-pending), and only then is a failed reload fatal. When the menu names servers, the tool removes /run/chrony-dhcp/thinfloe.sources itself before the reload; before, only the watcher removed it, so a failed watcher restart left chrony on the DHCP servers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TIME_APPLY_TIMEOUT was 70 s, below thinfloe-time's worst case of LOCK_WAIT 30 s plus three calls of TOOL_TIMEOUT 20 s (90 s). It is now 100 s, and test-thinfloe-time.sh compares the menu constant with the tool's constants. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The comment said values are never logged; only rejected ones are not. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
render("time") checked the servers but not the zone, so a zone the
image's zone.tab no longer lists reached generated/time, and the root
tools refused the whole file, servers included. The zone is now left out
of generated/time (the system falls back to the DHCP zone, else UTC),
the store notes it once at open, and the Time band shows Automatic with
a warning line naming the saved zone. config.toml keeps it; the next real
change in the band saves without it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The region select showed Automatic over a zone the zone list does not have, so picking Automatic was no change, and the band's save compared against the shown setting too: the zone stayed in config.toml and the warning and the start note came back on every start. The select now chooses no entry there (its placeholder reads Automatic), and Region(0) over an unknown zone saves the setting without it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
set_ntp reloaded chrony only when its sources file changed, so after a failed reload the next read found the file unchanged and never reloaded. A marker, /run/thinfloe/state/dhcp-ntp-reload-pending, is now set before each reload and removed after a good one; while it is there the next read reloads although the file is unchanged. It is the watcher's own file, apart from thinfloe-time's marker, which that tool keeps under a lock the watcher does not take. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reload-pending marker was written after the sources files, so when its write failed the apply failed with the servers already installed, and a retry found nothing changed and skipped the reload. The marker is now written first; a failed write fails the apply with nothing changed. It is removed at once when no sources file changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Over an unknown saved zone the region select always showed no entry (placeholder Automatic), also after the user picked a region: the select jumped back to Automatic while the city select of that region showed. It now shows no entry only while no region is picked (TimeBand::region_picked). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The panels tests merged in #37 build netdetail::Details by hand; the time field this branch adds was missing there after the rebase. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Time zone and NTP settings (owner's 4.6.0 feedback, item D).
Changes
/run/chrony-dhcp/thinfloe.sources; before, they were ignored, so a network without internet never synchronised the clock.[time]inconfig.tomlandgenerated/time; it applies live withsudo -n thinfloe-time apply(lock, 100 s menu timeout above the tool's 90 s worst case, reload of chrony only when a sources file changed, a reload-pending marker so a retry after a failed reload reloads).install_local_time()in the initramfs installs zone and servers before switch-root.generated/time, logged once and shown as Automatic with a warn line; the NTP part still applies.chronyc reload sources(own marker) and drops malformed IPv6 NTP values.docs/notes/time-zone.md,home-persistence.md,menu.md,CLAUDE.md; image guards intest-session-packages.sh; the time zone smoke tests check the DHCP NTP servers.Review
Whole-branch review (ready to merge), three fix waves for every minor finding and two scoped re-reviews.
Gates (rebased on main after #37)
cargo clippy --all-targets -D warnings,cargo fmt --check: clean (5924670 adds the newtimefield to three panel tests from fix(menu): Settings names the graphics chip again; labelled info panels on Network, Screen and This machine #37).make test: 1403 ok lines, 0 failed; Python 971 tests OK; menu cargo test 1241 passed, 0 failed.make test-runtime: 68 ok, 0 failed.make qemu-smoke-timezone,qemu-smoke-timezone-netboot,qemu-smoke: PASSED.🤖 Generated with Claude Code