antrea icon indicating copy to clipboard operation
antrea copied to clipboard

Add networkStatus annotation with primary network interface for secondaryNetwork Pod

Open wenqiq opened this issue 8 months ago • 16 comments

Add network status annotation with the primary network interface for Pod

This PR enhances the handling of network interfaces for Pods with secondary networks by ensuring the k8s.v1.cni.cncf.io/network-status annotation includes both secondary and primary network interface information.

Key Changes:

  • Comprehensive Network Interface Annotation: For Pods utilizing secondary networks, the PR modifies the annotation update process to incorporate details of the primary network interface alongside the secondary ones within the k8s.v1.cni.cncf.io/network-status field.
  • Targeted Logic Adjustment: The primary modification occurs in the cniserver's CmdAdd logic. After configuring the secondary network interface, add the primary network interface details to the network-status annotation.

Test Done:

  • Unit Tests: Validated the annotation update logic to ensure it correctly includes both primary and secondary network interfaces.
  • e2e Tests: Verified the end-to-end functionality by testing annotation updates on Pods with secondary networks and checking for the presence of both interface types in the network-status annotation.
k8s.v1.cni.cncf.io/network-status:[{
    "name": "antrea",
    "interface": "eth0",
    "ips": [
        "10.244.1.3"
    ],
    "mac": "ca:3c:97:e7:24:ff",
    "default": true,
    "dns": {},
    "gateway": [
        "10.244.1.1"
    ]
}]

wenqiq avatar Apr 10 '25 13:04 wenqiq

@tnqn @antoninbas ~~I noticed that Pod's primary IP information is already in Pod's status, so I am now confused now why do we want to have the primary IP of Pod in the network status annotation at the very beginning, could you help here?~~ Ignore me, I recalled that Multus also have the primary info, so it should be for the annotation parity.

status:
  conditions:
...
  hostIP: 172.18.0.2
  hostIPs:
  - ip: 172.18.0.2
  phase: Running
  podIP: 172.2.1.4
  podIPs:
  - ip: 172.2.1.4
  qosClass: BestEffort
  startTime: "2025-04-18T02:53:20Z"

luolanzone avatar Apr 18 '25 03:04 luolanzone

@tnqn @antoninbas ~I noticed that Pod's primary IP information is already in Pod's status, so I am now confused now why do we want to have the primary IP of Pod in the network status annotation at the very beginning, could you help here?~ Ignore me, I recalled that Multus also have the primary info, so it should be for the annotation parity.

status:
  conditions:
...
  hostIP: 172.18.0.2
  hostIPs:
  - ip: 172.18.0.2
  phase: Running
  podIP: 172.2.1.4
  podIPs:
  - ip: 172.2.1.4
  qosClass: BestEffort
  startTime: "2025-04-18T02:53:20Z"

Right. Multus has the primary network interface info: https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/docs/quickstart.md#network-status-annotations

wenqiq avatar Apr 18 '25 03:04 wenqiq

Can one of the admins verify this patch?

antrea-bot avatar Apr 18 '25 13:04 antrea-bot

I assume that https://github.com/antrea-io/antrea/pull/7069 should be merged first?

antoninbas avatar Apr 21 '25 22:04 antoninbas

I assume that #7069 should be merged first?

Yes. This PR depends on #7069. #7069 should be merged first

wenqiq avatar Apr 22 '25 03:04 wenqiq

Hi @antoninbas @luolanzone @tnqn could you help take a look at this PR again? Thanks

wenqiq avatar May 21 '25 17:05 wenqiq

@wenqiq make sure the unit test coverage for the patch is over 70%.

luolanzone avatar Jun 03 '25 09:06 luolanzone

/test-all

wenqiq avatar Jun 03 '25 16:06 wenqiq

Addressed comments. Could you take a look? Thanks @antoninbas @luolanzone

wenqiq avatar Jun 16 '25 15:06 wenqiq

/test-sriov-secondary-network-e2e

wenqiq avatar Jun 17 '25 02:06 wenqiq

/test-sriov-secondary-network-e2e

wenqiq avatar Jun 17 '25 05:06 wenqiq

/test-sriov-secondary-network-e2e

wenqiq avatar Jun 17 '25 06:06 wenqiq

Squashed commits and rebased.

wenqiq avatar Jun 17 '25 06:06 wenqiq

/test-sriov-secondary-network-e2e

wenqiq avatar Jun 25 '25 16:06 wenqiq

/test-sriov-secondary-network-e2e

wenqiq avatar Jun 27 '25 03:06 wenqiq

/test-sriov-secondary-network-e2e

wenqiq avatar Jun 27 '25 12:06 wenqiq

/test-sriov-secondary-network-e2e

wenqiq avatar Jun 27 '25 18:06 wenqiq

/test-all

tnqn avatar Jun 28 '25 11:06 tnqn

@jianjuns @antoninbas @luolanzone please let me know if you have other comments.

tnqn avatar Jun 30 '25 02:06 tnqn

Merging this PR first to unblock its dependent changes. If there are additional comments, Wenqi can address them in a follow-up PR.

tnqn avatar Jun 30 '25 08:06 tnqn