Fix DNS in NetworkState (SC-133)#923
Conversation
blackboxsw
left a comment
There was a problem hiding this comment.
Thanks @TheRealFalcon minor rename needed for _handle_individual_nameserver I think but beyond that +1.
Maybe worth expanding the doc example to use the interface key?
diff --git a/doc/rtd/topics/network-config-format-v1.rst b/doc/rtd/topics/network-config-format-v1.rst
index d379b437..71d5f000 100644
--- a/doc/rtd/topics/network-config-format-v1.rst
+++ b/doc/rtd/topics/network-config-format-v1.rst
@@ -356,6 +356,7 @@ the following keys:
address:
- 192.168.23.2
- 8.8.8.8
-
interface: interface0 # Ties nameserver to interface0 only search: - exemplary
| dns['search'].extend(search) | ||
|
|
||
| @ensure_command_keys(['address']) | ||
| def handle_individual_nameserver(self, command, iface): |
There was a problem hiding this comment.
We might want to rename this because of ugly magic of CommandHandlerMeta which will attempt to map any 'handle_' method of NetworkStateInterpreter as a viable "command"
Note we've done the same with _handle_bond_bridge to avoid "registering" and handler for the top-level network config key "bond_bridge"
| def handle_individual_nameserver(self, command, iface): | |
| def _handle_individual_nameserver(self, command, iface): |
| version: 1 | ||
| config: | ||
| - type: nameserver | ||
| interface: {} |
There was a problem hiding this comment.
Can we specifically name this format variable or give it an index so it's more clear that we will probably be using this as a format string. Initial glance at the string made me think we were expecting a dict type in tests.
| interface: {} | |
| interface: {0} # or {int_name} |
v1 network config currently has no concept of interface-specific DNS, which is required for certain renderers. To fix this, added an optional 'interface' key on the v1 nameserver definition. If specified, it makes the DNS settings specific to the interface. Otherwise, it will be defined as global DNS as it always has. Additionally, DNS for v2 wasn't being recognized correctly. For DNS defined on a particular interface, these settings now also go into the global DNS settings as they were intended.
2f35c54 to
dc4e57f
Compare
Proposed Commit Message
Additional Context
These changes would help enable a systemd-networkd renderer.
Test Steps
Added new unit tests. This can't be integration tested yet as a renderer would need to pick up these changes.
Checklist: