Sort the endpoints such that eth0 is first #2231
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This addresses an issue where when adding multiple interfaces, the eth0 interface in the guest does not correspond correctly to the primary NIC that the CNI intended. This happens because hcsshim queries HNS to get the list of endpoints for the network namespace and adds the endpoints sequentially based on what is returned from HNS. HNS guarantees no specific ordering of endpoints returned from this query.
CNI names the interfaces such that they have the suffix
-ethX
where X is the index for the interface. We could leverage this information in the future to sort all the endpoints according to index. However, I didn't think that was necessary here since we are only working with two endpoints added to the UVM and the CNI team confirmed they do not care about the ordering of the non-eth0 endpoints for now. We are working on a better long-term solution for that scenario.Without this change, if an endpoint is incorrectly added first as the eth0 when it should not be, the pod may not be able to communicate with other pods as expected since the eth0 interfaces on other pods may be using endpoints from different subnets.