Skip to content

Commit

Permalink
udn, cni: Report UDN iface info on network-status
Browse files Browse the repository at this point in the history
Before this commit, this was the network status we reported for a UDN
pod:
```
kubectl get pods pod -ojsonpath="{@.metadata.annotations.k8s\.v1\.cni\.cncf\.io\/network-status}" | jq
[
  {
    "name": "ovn-kubernetes",
    "interface": "eth0",
    "ips": [
      "10.244.1.9",
      "fd00:10:244:2::9"
    ],
    "mac": "0a:58:0a:f4:01:09",
    "default": true,
    "dns": {}
  }
]
```

With it, we now report:
```
[
 {
    "name": "ovn-kubernetes",
    "interface": "ovn-udn1",
    "ips": [
      "10.128.0.3"
    ],
    "mac": "0a:58:0a:80:00:03",
    "default": true,
    "dns": {}
  },
  {
    "name": "ovn-kubernetes",
    "interface": "eth0",
    "ips": [
      "10.244.1.6",
      "fd00:10:244:2::6"
    ],
    "mac": "0a:58:0a:f4:01:06",
    "default": false,
    "dns": {}
  }
 ]
```

This way, applications complying to the k8snetworkplumbingwg de-facto
standard can be aware of the UDN interface information.

We report the primary UDN first so the
network-attachment-definition-client can identify which of the 2
interfaces to report as primary [0].

[0] k8snetworkplumbingwg/network-attachment-definition-client#71

Signed-off-by: Miguel Duarte Barroso <[email protected]>
Signed-off-by: Ram Lavi <[email protected]>
  • Loading branch information
maiqueb authored and RamLavi committed Sep 16, 2024
1 parent 25679a1 commit 31a0536
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion go-controller/pkg/cni/cni.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,24 @@ func (pr *PodRequest) cmdAddWithGetCNIResultFunc(kubeAuth *KubeAPIAuth, clientse
if err != nil {
return nil, err
}
if _, err := getCNIResultFn(primaryUDNPodRequest, clientset, primaryUDNPodInfo); err != nil {
primaryUDNResult, err := getCNIResultFn(primaryUDNPodRequest, clientset, primaryUDNPodInfo)
if err != nil {
return nil, err
}

defaulClusterNetworkResult := response.Result
originalNumberOfIfaces := len(primaryUDNResult.Interfaces)
response.Result.Interfaces = append(primaryUDNResult.Interfaces, response.Result.Interfaces...)
for i := range response.Result.IPs {
ifaceIPConfig := defaulClusterNetworkResult.IPs[i].Copy()

if ifaceIPConfig.Interface != nil {
ifaceIPConfig.Interface = current.Int(*ifaceIPConfig.Interface + originalNumberOfIfaces)
}
response.Result.IPs = append(primaryUDNResult.IPs, ifaceIPConfig)
}

response.Result.Routes = append(primaryUDNResult.Routes, response.Result.Routes...)
}
} else {
response.PodIFInfo = podInterfaceInfo
Expand Down

0 comments on commit 31a0536

Please sign in to comment.