fix: use name of interface instead of relying on idx - #458
Conversation
|
Check where you would like a Mattermost message to be sent to when CI completes and this PR is merged
|
There was a problem hiding this comment.
[maas-code-reviewer review]
LLM-generated review from https://github.com/canonical/maas-code-reviewer.
Intended to assist a human reviewer, not replace one — suggestions may be
incorrect, please verify before acting.
The proposed fix correctly addresses the issue where LXD returns machine interfaces sorted alphabetically (likely due to map serialization in Go). By checking discovered_nic.name and falling back to the ordered interface_names for drivers like virsh, the code ensures network interfaces are accurately mapped to the configurations specified in constraints without breaking existing hypervisor support. The included unit test additions properly validate the changes. Good job!
|
|
||
| elif device["type"] == "nic": | ||
| interfaces.append( | ||
| _get_discovered_interface(name, device, not interfaces) |
There was a problem hiding this comment.
just curious about this. we set boot.priority on the first requested NIC at compose time, but discovery marks boot from list order here. With custom names, would that still be the same NIC?
tanzin8r
left a comment
There was a problem hiding this comment.
left a couple of comments.
When creating a machine, we do some song and dance with LXD and the interfaces that are specified seem to be retrieved in alphabetical order of their names, even though we assume same-order of the listing. This is likely an artifact of the fact that LXD is written in Go, and marshalling sorts keys.
We now store and use the name directly later, if available. It may not be available since that same code path is run for virsh as well.
Resolves: LP:2160526