-
Notifications
You must be signed in to change notification settings - Fork 647
i/builtin: allow timeserver-control to manage per-link ntp settings via systemd-networkd #16378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR extends the timeserver-control interface to support per-link NTP configuration through systemd-networkd. The changes enable snaps to use timedatectl ntp-servers and timedatectl revert commands by granting necessary D-Bus permissions to interact with systemd-networkd's Manager interface.
- Adds D-Bus permissions for SetLinkNTP, RevertLinkNTP, and GetLinkByName methods on the network1 Manager interface
- Implements test coverage for the new ntp-servers and revert subcommands
- Updates interface tests to verify the new AppArmor rules are properly generated
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| interfaces/builtin/timeserver_control.go | Adds D-Bus permission rules for systemd-networkd per-link NTP management |
| interfaces/builtin/timeserver_control_test.go | Adds test assertions to verify new D-Bus paths and methods in AppArmor snippets |
| tests/main/interfaces-timeserver-control/task.yaml | Adds integration tests for ntp-servers and revert commands when systemd-networkd is enabled |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
6f26436 to
ce86bd1
Compare
|
Thu Dec 18 17:35:07 UTC 2025 Failures:Preparing:
Executing:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #16378 +/- ##
==========================================
- Coverage 77.82% 77.48% -0.34%
==========================================
Files 1327 1339 +12
Lines 184888 183042 -1846
Branches 2438 2438
==========================================
- Hits 143884 141830 -2054
- Misses 32418 32615 +197
- Partials 8586 8597 +11
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…ia systemd-networkd
ce86bd1 to
71a4d69
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| exit 1 | ||
| fi | ||
| if systemctl list-unit-files | grep systemd-networkd | awk '{print $2}' | MATCH "enabled"; then |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The systemd-networkd detection logic is fragile. If systemd-networkd appears multiple times in list-unit-files output (e.g., systemd-networkd.service and systemd-networkd.socket), this will print multiple state values, potentially causing MATCH to fail unexpectedly. Consider using systemctl is-enabled systemd-networkd.service instead for a more reliable single-value check.
| if systemctl list-unit-files | grep systemd-networkd | awk '{print $2}' | MATCH "enabled"; then | |
| if systemctl is-enabled systemd-networkd.service 2>/dev/null | MATCH "enabled"; then |
| test-snapd-timedate-control-consumer.timedatectl-timeserver ntp-servers "${iface}" 127.0.0.1 | ||
| test-snapd-timedate-control-consumer.timedatectl-timeserver revert "${iface}" | ||
| elif os.query is-core-ge 20; then | ||
| echo "Error: insufficient test coverage of timedatectl per-link NTP commands" |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error message could be more actionable. It indicates a test configuration issue but doesn't explain why the test can't run or what the user should do. Consider clarifying that systemd-networkd is required but not enabled, e.g., 'systemd-networkd is not enabled but is required for per-link NTP command testing on Core 20+'.
| echo "Error: insufficient test coverage of timedatectl per-link NTP commands" | |
| echo "Error: systemd-networkd is not enabled but is required for per-link NTP command testing on Core 20+" |
This change enables the usage of
timedatectl ntp-serversandtimedatectl revertwhen a snap is connected to thetimeserver-controlinterface.Review usage of
bus_network_mgrto see how these are used intimedatectl: https://github.com/systemd/systemd/blob/main/src/timedate/timedatectl.cThis is coming from a request from field.
SNAPDENG-36147