-
Notifications
You must be signed in to change notification settings - Fork 85
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
Support changing host veth name #1125
Conversation
234b37e
to
b66bb0f
Compare
08920e6
to
5dfe8af
Compare
I don't know why, but I can't get the issue linked properly. |
src/network/types.rs
Outdated
#[serde(rename = "options", default)] | ||
pub options: HashMap<String, String>, |
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.
instead of using default I think it is cleaner to wrap this in an Option<>. While that makes accessing values a step more I think it carries the intend better that there can be empty.
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.
Agree, fixed.
src/network/bridge.rs
Outdated
host_interface_name: self | ||
.info | ||
.per_network_opts | ||
.options | ||
.get("host_interface_name") | ||
.cloned() | ||
.unwrap_or_else(|| "".to_string()), |
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.
please use parse_option() as split out host_interface_name as constant like the other options
I know parsing a String cannot fail so the error handling is not needed technically but I think it better to use it consistently.
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.
Fixed. Do we need to make clear which options come from the network and which from the per-network-config? With the current code, the messages and variables look the same for both kinds of options.
And also this needs tests, please have a look at test/100-bridge-iptables.bats |
This will likely return a wrong/misleading error now. Given both interface are created in one call it would be impossible to know which name conflicted. Maybe we can check if veth_name not empty then chnage the message to hint at both possibilities |
Signed-off-by: Michael Zimmermann <[email protected]>
5dfe8af
to
2757061
Compare
Does this change cause the integration test failures? because they seem unrelated at first glance. |
Yes it is your new error message, it seems your condition in the code is inverted. |
src/network/bridge.rs
Outdated
if data.host_interface_name.is_empty() { | ||
format!( | ||
"create veth pair: interface {} already exists on container namespace or {} exists on host namespace", | ||
data.container_interface_name, data.host_interface_name, | ||
) | ||
} else { | ||
format!( | ||
"create veth pair: interface {} already exists on container namespace", | ||
data.container_interface_name | ||
) | ||
}, |
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.
need to use !is_empty() or better swap both branches around
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.
agree, fixed
} | ||
|
||
@test bridge - existing veth name { | ||
expected_rc=1 run_netavark --file ${TESTSDIR}/testfiles/bridge-vethname-exists.json setup $(get_container_netns_path) |
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.
please assert your exact expected error message here
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 gotta say, it's pretty cool that the tests can do this. done.
2757061
to
0d3c560
Compare
Fixes containers/netavark#24523 Signed-off-by: Michael Zimmermann <[email protected]>
0d3c560
to
dc99b01
Compare
LGTM |
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.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Luap99, M1cha The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Depends on:
containers/common#2245
containers/podman#24535