-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add support for multiple connection files per logical interface #114
base: main
Are you sure you want to change the base?
Add support for multiple connection files per logical interface #114
Conversation
@atanasdinov Can you give your first thoughts on this change. Also, please indicate coding errors or weird constructs. As mentioned, I'm a new to rust. |
Thanks for this contribution! In fact, I was already looking at the culprit behind this and was going to push a fix. I'll take a look early next week but can you also fix the linter issues so the CI is happy? :) |
Addressing the clippy issues now |
a6e276f
to
094bacb
Compare
094bacb
to
425f1f5
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.
Thanks a lot for this contribution! The implementation idea is great - I left some comments about my concerns and some improvements that we can make before merging.
Please let me know what you think, thanks!
@@ -0,0 +1 @@ | |||
target/ |
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.
We can probably get rid of this file as we never build nmc in a container.
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.
Sure, I added it because the CI builds a container, and when I tried locally this was a speedup
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 is interesting, I wasn't aware it could be a speedup locally.
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.
When built locally, a lot of files are created in the target/
directory. When trying to build the dockerimage, all the files in the target/
directory are copied over to the docker build context. This takes "long" for > 1GB of data...
So this was just a quick fix to remediate this issue. I'm also fine by removing it as we don't need the docker image in the end.
src/apply_conf.rs
Outdated
let connections = &interface | ||
.connection_ids | ||
.clone() | ||
.unwrap_or(vec![interface.logical_name.clone()]); |
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.
Is it safer to always include the logical name? Do we anticipate that it will always be present in the connections_id
?
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 added the logical_name here as a fallback mechanism mainly for backwards compatibility. Although I doubt if we need backwards compatibility (I assume same NMC version is used for generating and applying).
No, the logical name won't be always present in the connection_ids
.
See also the example
- logical_name: ovs0
connection_ids:
- ovs0-port
- ovs0-if
interface_type: ovs-interface
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.
Isn't there an ovs0.nmconnection
file that we don't copy over with the current implementation?
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.
ovs0.nmconnection
is not generated by nmstate. When applying this configuration with the current implementation you'll get an error like described in #113 because the file is missing
src/generate_conf.rs
Outdated
.get(i.name()) | ||
.cloned() | ||
.or_else(|| Some(Vec::new())), |
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 confirms the initial concern about applying the configurations. We should do one of the following:
- Always include the logical name in this list since a connection file will be present for it
- Never include the logical name in the list and merge it with these connections when applying
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.
- is not true, see previous comment
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'm not saying that either of these is true, but that we should probably do one of those. However, the ovs
example you gave can be contradicting if ovs0.nmconnection
file is never created.
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.
indeed, ovs0.nmconnection
is never created
Signed-off-by: Koen de Laat <[email protected]>
fcaaa98
to
1bda6b4
Compare
Signed-off-by: Koen de Laat <[email protected]>
1bda6b4
to
13a168b
Compare
@atanasdinov, can you please have look at the modifications? |
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.
Sorry for the late response. Thanks for addressing the initial comments - I left a couple more but this is now very close to being ready, great job!
Signed-off-by: Koen de Laat <[email protected]>
3b1424d
to
d7a5d2b
Compare
let mut interfaces = extract_interfaces(&net_state); | ||
populate_connection_ids(&mut interfaces, &config_files).expect("populate ids"); |
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 believe we're fine to drop this. The test explicitly wants to verify that extract_interfaces
works as expected, not necessarily the complete state of the final output.
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.
True, however than in the assert, we've to specify empty vectors in connection_ids. Which is confusing from a developers perspective
src/generate_conf.rs
Outdated
) -> anyhow::Result<()> { | ||
config | ||
.iter() | ||
.filter(|(filename, _)| filename != "lo.nmconnection") |
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.
Would this cause an issue with validate_connection_ids
? 👀
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.
No, the current implementation removes the type=loopback
interfaces. So this code would fail for lo.nmconnection
because it cannot find a matching interface definition.
This is however not perfect I realize now, there could be more loopback connections with each their own connection file.
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.
Precisely because we filter it out, I'd expect the validate_connection_ids
to return an error and abort the generation in the cases where there are loopbacks.
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've tried to implement a better filter for loopback connections.
However I'm wondering why we exclude loopback connections at all. Current code will silently remove any loopback configuration during generation and therefor not apply any loopback connection.
Signed-off-by: Koen de Laat <[email protected]>
Signed-off-by: Koen de Laat <[email protected]>
Signed-off-by: Koen de Laat <[email protected]>
@atanasdinov, I've fixed the linter issues. Any other comments? |
Co-authored-by: Atanas Dinov <[email protected]> Signed-off-by: Koen de Laat <[email protected]>
Fix: #113
This PR addresses the fact that some interface types generate multiple connection files per logical interface.
I've added an openvswitch example that would fail without this fix.
There is a change to the
host_config.yaml
file, but I tried to make it backwards compatible. For each interface there is an additional field that specifies the connection ids belonging to this logical interface.An example
host_config.yaml
: