Skip to content

Commit

Permalink
feat: multus ovn nic
Browse files Browse the repository at this point in the history
Add cniType&ifName to the CNI request

fix: nil pointer error, release ports after pod was del
  • Loading branch information
fanriming committed Mar 28, 2021
1 parent 40ef0e3 commit ec7f742
Show file tree
Hide file tree
Showing 10 changed files with 254 additions and 88 deletions.
5 changes: 4 additions & 1 deletion cmd/cni/cni.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func cmdAdd(args *skel.CmdArgs) error {
client := request.NewCniServerClient(netConf.ServerSocket)

response, err := client.Add(request.CniRequest{
CniType: netConf.Type,
PodName: podName,
PodNamespace: podNamespace,
ContainerID: args.ContainerID,
Expand Down Expand Up @@ -117,10 +118,12 @@ func cmdDel(args *skel.CmdArgs) error {
}

return client.Del(request.CniRequest{
CniType: netConf.Type,
PodName: podName,
PodNamespace: podNamespace,
ContainerID: args.ContainerID,
NetNs: args.Netns,
IfName: args.IfName,
Provider: netConf.Provider,
DeviceID: netConf.DeviceID,
})
Expand All @@ -146,7 +149,7 @@ func loadNetConf(bytes []byte) (*netConf, string, error) {
return nil, "", fmt.Errorf("failed to load netconf: %v", err)
}

if n.IPAM != nil {
if n.Type != util.CniTypeName && n.IPAM != nil {
n.Provider = n.IPAM.Provider
n.ServerSocket = n.IPAM.ServerSocket
}
Expand Down
2 changes: 1 addition & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -961,4 +961,4 @@ sigs.k8s.io/structured-merge-diff/v4 v4.0.2 h1:YHQV7Dajm86OuqnIR6zAelnDWBRjo+YhY
sigs.k8s.io/structured-merge-diff/v4 v4.0.2/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw=
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
11 changes: 9 additions & 2 deletions pkg/controller/gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,15 @@ func (c *Controller) markAndCleanLSP() error {
}
ipNames := make([]string, 0, len(pods)+len(nodes))
for _, pod := range pods {
if isPodAlive(pod) && pod.Annotations[util.AllocatedAnnotation] == "true" {
ipNames = append(ipNames, fmt.Sprintf("%s.%s", pod.Name, pod.Namespace))
if !isPodAlive(pod) {
continue
}
for k, v := range pod.Annotations {
if !strings.Contains(k, util.AllocatedAnnotationSuffix) || v != "true" {
continue
}
providerName := strings.ReplaceAll(k, util.AllocatedAnnotationSuffix, "")
ipNames = append(ipNames, ovs.PodNameToPortName(pod.Name, pod.Namespace, providerName))
}
}
for _, node := range nodes {
Expand Down

0 comments on commit ec7f742

Please sign in to comment.