feat(time-sync): keep DHCP's NTP servers and read them apart #37

Merged
christianmanivong merged 1 commits from feat/time-sync-dhcp-ntp-2380 into main 2026-11-11 22:01:33 +00:00
Owner

Summary

DHCP option 42 counts (NetOrk/netork#2380, decided 2026-11-11): a router that gets the site's time giver from its lease is aligned, so the driver stops switching DHCP NTP off.

  • configure_time_sync no longer sets use_dhcp=0; the option stays as the router has it. The "already has these servers" check no longer rewrites a router only because use_dhcp is on.
  • get_time_sync() reports dhcp_ntp_servers: what /etc/init.d/sysntpd adds to ntpd's list while use_dhcp is on -- each interface's data.ntpserver in ubus call network.interface dump (netifd's /lib/netifd/dhcp.script stores udhcpc's ntpsrv there; sysntpd's get_dhcp_ntp_servers reads exactly that), only the dhcp_interface list's where it names any, in netifd's order, each once. Read in the same round trip as uci -q show system; the exit code stays uci's. [] while use_dhcp or the client is off; None where netifd gives no answer.
  • Floor napalm_device_types>=4.36.0 (TimeSyncDict.dhcp_ntp_servers, NAPALM/napalm-device-types#105).

A router the first time sync commit (#36) already wrote keeps use_dhcp=0 until it is set back -- the driver leaves the option alone, as decided.

Related Issue

Part of NetOrk/netork#2380 (epic NetOrk/netork#2360). Depends on NAPALM/napalm-device-types#105: CI fails until napalm-device-types 4.36.0 is released -- expected.

Testing

TDD: the new tests (lease servers read apart, dhcp_interface, use_dhcp/disabled client, no or broken netifd answer, write keeps use_dhcp, no rewrite with DHCP on) written first and seen red.

Against napalm-device-types from the #105 branch:

  • pytest -q --cov: 339 passed; time_sync_mixin.py 100%.
  • ruff format --check, ruff check: clean. mypy (napalm-device-types installed non-editable): clean.
  • napalm-standard check: meets the standard; ratchet: within the baseline.
## Summary DHCP option 42 counts (NetOrk/netork#2380, decided 2026-11-11): a router that gets the site's time giver from its lease is aligned, so the driver stops switching DHCP NTP off. - `configure_time_sync` no longer sets `use_dhcp=0`; the option stays as the router has it. The "already has these servers" check no longer rewrites a router only because `use_dhcp` is on. - `get_time_sync()` reports `dhcp_ntp_servers`: what `/etc/init.d/sysntpd` adds to ntpd's list while `use_dhcp` is on -- each interface's `data.ntpserver` in `ubus call network.interface dump` (netifd's `/lib/netifd/dhcp.script` stores udhcpc's `ntpsrv` there; sysntpd's `get_dhcp_ntp_servers` reads exactly that), only the `dhcp_interface` list's where it names any, in netifd's order, each once. Read in the same round trip as `uci -q show system`; the exit code stays uci's. `[]` while `use_dhcp` or the client is off; None where netifd gives no answer. - Floor `napalm_device_types>=4.36.0` (`TimeSyncDict.dhcp_ntp_servers`, NAPALM/napalm-device-types#105). A router the first time sync commit (#36) already wrote keeps `use_dhcp=0` until it is set back -- the driver leaves the option alone, as decided. ## Related Issue Part of NetOrk/netork#2380 (epic NetOrk/netork#2360). Depends on NAPALM/napalm-device-types#105: **CI fails until napalm-device-types 4.36.0 is released** -- expected. ## Testing TDD: the new tests (lease servers read apart, `dhcp_interface`, `use_dhcp`/disabled client, no or broken netifd answer, write keeps `use_dhcp`, no rewrite with DHCP on) written first and seen red. Against napalm-device-types from the #105 branch: - `pytest -q --cov`: 339 passed; `time_sync_mixin.py` 100%. - `ruff format --check`, `ruff check`: clean. `mypy` (napalm-device-types installed non-editable): clean. - `napalm-standard check`: meets the standard; `ratchet`: within the baseline.
christianmanivong added 1 commit 2026-11-11 21:13:30 +00:00
feat(time-sync): keep DHCP's NTP servers and read them apart
driver / lint (pull_request) Successful in 15s
driver / standard (pull_request) Successful in 16s
driver / types (pull_request) Successful in 1m2s
driver / test (3.13) (pull_request) Successful in 1m3s
driver / test (3.12) (pull_request) Successful in 1m6s
driver / lowest (pull_request) Successful in 33s
driver / build (pull_request) Successful in 42s
driver / security (pull_request) Successful in 1m17s
CI / driver (pull_request) Successful in 2m36s
driver / publish (pull_request) Skipped
85a679fe1a
DHCP option 42 counts (NetOrk/netork#2380): a router that gets the
site's time giver from its lease is aligned. The first time sync commit
set use_dhcp=0 on every write, which cut a router off from the giver its
DHCP server hands out.

A write now leaves use_dhcp as the router has it, and the "already has
these servers" check no longer rewrites a router only because use_dhcp
is on. get_time_sync() reads what sysntpd adds to ntpd's list while
use_dhcp is on -- each interface's data.ntpserver in ubus call
network.interface dump, which /lib/netifd/dhcp.script fills from
udhcpc's ntpsrv, only the dhcp_interface list's where it names any -- in
the same round trip as uci, into dhcp_ntp_servers: [] while use_dhcp or
the client is off, None where netifd gives no answer.

Needs napalm-device-types 4.36.0 (TimeSyncDict.dhcp_ntp_servers).
christianmanivong merged commit 522720f818 into main 2026-11-11 22:01:33 +00:00
christianmanivong deleted branch feat/time-sync-dhcp-ntp-2380 2026-11-11 22:01:33 +00:00
Sign in to join this conversation.