-
Notifications
You must be signed in to change notification settings - Fork 292
Adapt network interfaces sorting #6456
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
Adapt network interfaces sorting #6456
Conversation
@@ -420,6 +420,18 @@ module Interface_API (R : RPC) = struct | |||
["Get list of all interface names"] | |||
(debug_info_p @-> unit_p @-> returning iface_list_p err) | |||
|
|||
let get_interface_positions = |
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.
Could this be done within Interface.get_all
?
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 prefer to add a new interface to keep the interface function simple and not modify the old one for potential break.
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.
OK. I thought it's would be simpler to include this in the Interface.get_all
from the interface design's point of view. But I'm not sure about this.
Hi @robhoes @psafont @lindig
May I please have your thoughts on this?
BTW, a minor comment on the name: Interface.get_interface_positions
seems a bit redundant. If we are going to use this, how about Interface.get_order
?
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 do prefer the name Interface.get_{positions,order,slots}
, But I would keep the function separate, because they have different semantic meaning. was there only a single user of get_all
?
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.
Yes. There is only one single user of Net.Interface.get_all
, which is xapi_pif.make_tables.
c455eb0
to
3b21c30
Compare
b694365
to
d95662a
Compare
ocaml/xapi/helpers.ml
Outdated
let choose_network_name_for_pif device pos_opt = | ||
let pos_str = | ||
match pos_opt with None -> "" | Some pos -> Printf.sprintf "[%d]" pos | ||
in | ||
Printf.sprintf "Pool-wide network associated with %s%s" device pos_str |
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 will be user visible, might be worth explaining what that number is:
let choose_network_name_for_pif device pos_opt = | |
let pos_str = | |
match pos_opt with None -> "" | Some pos -> Printf.sprintf "[%d]" pos | |
in | |
Printf.sprintf "Pool-wide network associated with %s%s" device pos_str | |
let choose_network_name_for_pif device pos_opt = | |
let pos_str = | |
match pos_opt with None -> "" | Some pos -> Printf.sprintf "(slot %d)" pos | |
in | |
Printf.sprintf "Pool-wide network associated with %s %s" device pos_str |
Does this rename the existing PIFs? we probably should start picking words for the user-visible concepts, so "slot" might not be the right one.
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.
It's just the name label of network, not the PIF. It's all right to add slot to show its meaning explicitly.
@minglumlu I come up with a new question here that if we should change the name of network in xs8? I want to change it with adding slot x. I think no one will/should rely on network name label.
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 word used in XenCenter is NIC
. They could be consistent now.
Yeah, I think the name is only a default one. A user can change it later anyway.
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.
Or in XS 8, the the networkd could not return the positions (hence dropping the get_index_from_ethx
and sort_based_on_ethx
) to keep the original naming of network.
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 current solution is designed to limit the compatibility in networkd. We don't want to check and write two logics in xapi_pif again like networkd does. So, it's better to keep the main changes of get position method in networkd. If there is really a particular corner demand like the network name label to keep unchanged. I think it is ok to check and write two logics about it then.
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.
That's why the position is of int option
.
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.
option here is mainly for ibft and non-physical devices.
The changes look good, but the commits need to be squashed, there are too many of them |
Yes, of course. I have planned to do it before merge. Done. Compare the diffs:
=> They are identical. |
`Network_utils.is_sorted_by_script` checks interface-rename-data dir. When true: Follow the legacy behavior, the new added interface_order field is always None. When false: Use `Network_device_order.sort` to sort the interfaces, store the result in config.interface_order. Signed-off-by: Changlei Li <changlei.li@cloud.com>
When xapi start, networkd config will be reset, see Xapi_pif.start_of_day_best_effort_bring_up. In fact, the interface_order is only maintained by networkd, it shouldn't be cleared. Signed-off-by: Changlei Li <changlei.li@cloud.com>
If networkd config.interface_order is None, then sort based on the renamed interfaces name "ethx" to indicate its position, else get positions from config.interface_order. Signed-off-by: Changlei Li <changlei.li@cloud.com>
Xapi get interface position from `get_interface_positions`, instead of getting position from "ethx" name. Signed-off-by: Changlei Li <changlei.li@cloud.com>
Some devices like ibft may not be in networkd sort result but need to build pif, network for it. So the devices need be got by `get_all`. Signed-off-by: Changlei Li <changlei.li@cloud.com>
Pif device name maybe change. Look up device_to_position table to get the new device name in pif refresh. Then update to db. This function is called by pif.scan and resynchronise_pif_params. Signed-off-by: Changlei Li <changlei.li@cloud.com>
ac02a4a
to
dbd1a3e
Compare
ce4de83
into
xapi-project:feature/host-network-device-ordering
This PR is the adaption of #6381 in networkd and xapi.
XS8: Keep the legacy behaviour, use host-installer, sort-script to sort and rename the network interfaces to
ethx
.XS9: Use
Network_device_order.sort
to sort the interfaces, store the result in networkdconfig.interface_order
.Compatibility is offered by check the sort-script
interface-rename-data
dir.Add new interface Interface.get_interface_positions to pass interfaces and positions from networkd to xapi.