antrea
antrea copied to clipboard
Add networkStatus annotation with primary network interface for secondaryNetwork Pod
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-statusfield. - Targeted Logic Adjustment: The primary modification occurs in the
cniserver'sCmdAddlogic. After configuring the secondary network interface, add the primary network interface details to thenetwork-statusannotation.
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-statusannotation.
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"
]
}]
@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"
@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
Can one of the admins verify this patch?
I assume that https://github.com/antrea-io/antrea/pull/7069 should be merged first?
I assume that #7069 should be merged first?
Yes. This PR depends on #7069. #7069 should be merged first
Hi @antoninbas @luolanzone @tnqn could you help take a look at this PR again? Thanks
@wenqiq make sure the unit test coverage for the patch is over 70%.
/test-all
Addressed comments. Could you take a look? Thanks @antoninbas @luolanzone
/test-sriov-secondary-network-e2e
/test-sriov-secondary-network-e2e
/test-sriov-secondary-network-e2e
Squashed commits and rebased.
/test-sriov-secondary-network-e2e
/test-sriov-secondary-network-e2e
/test-sriov-secondary-network-e2e
/test-sriov-secondary-network-e2e
/test-all
@jianjuns @antoninbas @luolanzone please let me know if you have other comments.
Merging this PR first to unblock its dependent changes. If there are additional comments, Wenqi can address them in a follow-up PR.