Fix NTP client stratum selection via stratumweight directive #1378
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.
Description
Chrony's default
stratumweightof 0.001s makes stratum relevant only when synchronization distances differ by >1ms. On local networks where both servers have sub-millisecond distances, chrony selects based on sampling order rather than stratum level, causingntp/client_stratum_selectiontest to fail intermittently.Change: Set
stratumweight 0.0in/etc/chrony/chrony.confto make stratum the primary selection criterion.This ensures clients always prefer authoritative (low-stratum) sources regardless of network distance variations.
Checklist
Tick relevant boxes, this PR is-a or has-a:
Original prompt
This section details on the original issue you should resolve
<issue_title>ntp: client_stratum_selection: Fails to select lowest stratum sometimes</issue_title>
<issue_description>### Current Behavior
When failing:
When succeeding:
So it is really selecting the higher stratum, even if i wait for a while and check again, it still not changed.
Expected Behavior
Lowest stratum selected
Steps To Reproduce
No response
Additional information
No response</issue_description>
<agent_instructions>Please have a look at this one, it's quite possible you need to research the NTP server topic to get to the bottom of why the stratum selection test fails sometimes. It could also be a race-condition, or issue with too short runtime, or an unknown other factor that we've not understood about NTP that could affect the server selection process.
Background: Infix OS is modeled entirely with YANG using sysrepo, the test system (Infamy) randomly selects RESTCONF or NETCONF backend for a test case when talking to the DUTs. The each test has a test description derived from the test case's docstring and Infamy allocates physical DUTs according to the topology.dot required by each test. In the case of this particular test, one NTP server is emulated by the PC system, it is also the server that should be selected (lowest stratum).</agent_instructions>
Comments on the Issue (you are @copilot in this section)
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.