k8snetworkplumbingwg / network-attachment-definition-client

A Golang Kubernetes client
Apache License 2.0
12 stars 37 forks source link

Adds CreateNetworkStatuses for CNI results with multiple pod interfaces #68

Closed dougbtv closed 2 months ago

dougbtv commented 2 months ago

Essentially, the gist is that the current singular CreateNetworkStatus method isn't aware of CNI results that have multiple pod interfaces returned.

This approach adds a new method (to not break current implementations, as it needs to return a list instead of a single Network Status)

With the existing method, this is somewhat buggy. If multiple pod interfaces are present, it returns the last one -- and groups all of the IP addresses to that address.

This method returns a list, still limited to interface results that have the sandbox present, and it maps the IPs to the interface using the ips.interface index property in the CNI result.

From the spec (in ADD Success):

sandbox (string): The isolation domain reference (e.g. path to network namespace) for the interface, or empty if on the host. For interfaces created inside the container, this should be the value passed via CNI_NETNS.

For replication of the error yourself, and to see the fix in action, see this gist: https://gist.github.com/dougbtv/1eb8ac2d61d494b56d65a6b236a86e61

For the related suggested update to the NPWG net-attach-def specification, see this proposal @ https://docs.google.com/document/d/1DUTV-o6E6zlRTKZkxeDhAeyGrmq03qPgPbU580Rm7-g/edit

dougbtv commented 2 months ago

Review super appreciated! New commit up, thanks