dockercompat: key inspect Networks by real CNI network name - #5164
Open
larrasket wants to merge 1 commit into
Open
dockercompat: key inspect Networks by real CNI network name#5164larrasket wants to merge 1 commit into
larrasket wants to merge 1 commit into
Conversation
nerdctl inspect keyed NetworkSettings.Networks by a synthesized "unknown-<iface>" name (e.g. "unknown-eth0") instead of the network the endpoint actually belongs to. go-cni names the i-th attached network's interface "eth<i>" in the order the networks were configured, and that ordered list is recorded in the nerdctl/networks spec annotation. Resolve each interface back to its network name through that list, falling back to the previous "unknown-<iface>" key when there is no match (host networking, an interface not created by CNI, or a missing networks annotation). Fixes containerd#2999 Signed-off-by: Saleh <root@lr0.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
nerdctl inspectcurrently shows a container's networks asunknown-eth0instead of the network nameIt comes from
networkSettingsFromNativein pkg/inspecttypes/dockercompat: the map key is built from the interface name with a hardcodedunknown-prefix, and it does not look at which network the interface belongs to. (There was already a// TODO: set CNI name when possiblesitting there).go-cni names the interfaces
eth0,eth1, ... in the same order the networks were attached, and nerdctl keeps that ordered list in thenerdctl/networksannotation. I read the list from the annotation and mapeth<i>back tonetworks[i].If an interface doesn't fit that pattern, host networking, something not set up by CNI, or an older container with no annotation, it keeps the old
unknown-<iface>key, so those cases are unchanged.Added single, and multi-network cases to
TestNetworkSettingsFromNative; the existing cases are untouched.Fixes #2999