confd: actually fix stratum-weight semantics and flaky test

The setting 'stratumweight 0.0' disables stratum in Chrony source
selection (pure distance-based), making client_stratum_selection
non-deterministic on a LAN.  Setting it to 1.0 gives srv1 a 1-second
effective advantage per stratum level, which no realistic distance
fluctuation can overcome.

Also correct the YANG descriptions in infix-system and infix-ntp which
had the semantics backwards — claiming 0.0 "ensures lower stratum is
always preferred" when in fact higher values do that.

Fixes #1361

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2026-03-20 16:18:15 +01:00
parent 7b4e9b3366
commit abad3cedc6
3 changed files with 33 additions and 17 deletions
+16 -8
View File
@@ -33,8 +33,10 @@ module infix-ntp {
description "Add stratumweight to NTP server configuration.
Allows tuning the weight of stratum in NTP source selection
relative to measured distance. Setting to 0.0 ensures lower
stratum sources are always preferred regardless of distance.";
relative to measured distance. Higher values give more preference
to lower-stratum sources; use 1.0 to guarantee stratum-based
selection on local networks. Setting to 0.0 disables stratum
weighting (pure distance-based selection).";
reference "internal";
}
@@ -75,13 +77,19 @@ module infix-ntp {
description
"Weight of stratum in NTP source selection relative to measured distance.
A one-stratum difference counts as this many seconds of additional
distance when comparing candidates.
Each stratum level adds this many seconds of effective distance when
comparing candidates. Higher values give more preference to lower-stratum
sources.
The default (0.001 = 1ms) means stratum only wins when distance
differences are less than 1ms. Setting it to 0.0 ensures that a
lower-stratum source is always preferred over a higher-stratum source,
regardless of their measured distances.";
The default (0.001 = 1ms per stratum level) is suitable for most networks.
On a LAN where all servers have similar round-trip times, a lower-stratum
source wins unless its synchronization distance degrades (e.g., due to
missed polls) by more than this amount.
Use 1.0 or larger to guarantee stratum-based selection on local networks
regardless of transient distance fluctuations. Setting it to 0.0 disables
stratum weighting; selection is then based purely on measured
synchronization distance.";
}
container makestep {
+16 -8
View File
@@ -32,8 +32,10 @@ module infix-system {
description "Add stratumweight to NTP client configuration.
Allows tuning the weight of stratum in NTP source selection
relative to measured distance. Setting to 0.0 ensures lower
stratum sources are always preferred regardless of distance.";
relative to measured distance. Higher values give more preference
to lower-stratum sources; use 1.0 to guarantee stratum-based
selection on local networks. Setting to 0.0 disables stratum
weighting (pure distance-based selection).";
reference "internal";
}
@@ -327,13 +329,19 @@ module infix-system {
description
"Weight of stratum in NTP source selection relative to measured distance.
A one-stratum difference counts as this many seconds of additional
distance when comparing candidates.
Each stratum level adds this many seconds of effective distance when
comparing candidates. Higher values give more preference to lower-stratum
sources.
The default (0.001 = 1ms) means stratum only wins when distance
differences are less than 1ms. Setting it to 0.0 ensures that a
lower-stratum source is always preferred over a higher-stratum source,
regardless of their measured distances.";
The default (0.001 = 1ms per stratum level) is suitable for most networks.
On a LAN where all servers have similar round-trip times, a lower-stratum
source wins unless its synchronization distance degrades (e.g., due to
missed polls) by more than this amount.
Use 1.0 or larger to guarantee stratum-based selection on local networks
regardless of transient distance fluctuations. Setting it to 0.0 disables
stratum weighting; selection is then based purely on measured
synchronization distance.";
}
}
@@ -107,7 +107,7 @@ with infamy.Test() as test:
"system": {
"ntp": {
"enabled": True,
"infix-system:stratum-weight": 0.0,
"infix-system:stratum-weight": 1.0,
"server": [{
"name": "srv1",
"udp": {