-
Notifications
You must be signed in to change notification settings - Fork 510
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
netdog: Add write-primary-interface-status for networkd #2984
Conversation
de94a82
to
4158877
Compare
Could we expand on the commit message a little bit? What is this wicked hook, and why do we need something similar in networkd? Also, who is meant to call this new CLI command? |
540e6b7
to
686ecb9
Compare
686ecb9
to
d9edb7b
Compare
d9edb7b
to
28617c5
Compare
Before this gets merged - be sure to rustfmt it and ensure clippy is happy! |
wicked provides a hook when interfaces are configured to run extra actions. These actions are used to write additional configuration needed by other services and tools in the system. systemd-networkd does not have the same hook so new functionality is needed to accomplish the same tasks. For now, the code is parallel to the wicked-specific install.rs but adds a new cli argument write-primary-interface-status to netdog. This command is intended to be called when the primary network interface moves to configured, at that point networkctl status is called for that configured interface to fetch the required info and IP Address and DNS configuration is written to the desired files like /etc/resolv.conf. This cli argument is only built in if the variant has systemd-networkd as a backend. It will be called by a yet to be built daemon that will watch for these configured events on D-Bus and replicate the same functionality wicked currently provides with its install hooks. Signed-off-by: Matthew Yeazel <[email protected]>
28617c5
to
033596e
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.
I think we've gotten this to a good spot!
🫕
/// Persist the current IP address to file | ||
fn write_current_ip(ip: &IpAddr) -> Result<()> { | ||
fs::write(CURRENT_IP, ip.to_string()) | ||
.context(error::CurrentIpWriteFailedSnafu { path: CURRENT_IP }) | ||
} |
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.
write_current_ip
could also be turned into a shared function, and potentially write_resolv_conf
too if it took a DnsSettings
parameter instead of the more specialized inputs.
Issue number:
Related to #2449
Description of changes:
systemd-networkd does not have the same hook that wicked has so new functionality is needed to accomplish the same tasks. For now, the code is parallel to install.rs but adds a new cli command
write-primary-interface-status
fornetdog
. This command is intended to be called when the primary network interface moves to configured, at that point networkctl is called to fetch the required info and written to the desired places. This cli argument is only built in if the variant has systemd-networkd as a backend.Testing done:
Built with additional logic to hard code systemd-networkd functionality enabled with the default interface, then called manually to setup dns.
The full branch can be found at develop...yeazelm:bottlerocket:update-resolver which covers the additional hardcoding. From that - unit tests and clippy also pass:
Note: this testing output uses the previous cli argument
update-responder
instead ofwrite-primary-interface-status
and I will run some additional tests now to ensure the new CLI (and all the updates of the code since then are still working as intended).Terms of contribution:
By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.