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 Apr 8, 2021
1 parent c375d5d commit 808a3a9
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions pkg/controller/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,40 @@ func (c *Controller) handleDeletePod(key string) error {
return nil
}

func (c *Controller) getPodPorts(pod, namespace string) (ports []string, err error) {
defaultPort := ovs.PodNameToPortName(pod, namespace, util.OvnProvider)
if c.ovnClient.IsLogicalSwitchPortExist(defaultPort) {
ports = append(ports, defaultPort)
}

allNs, err := c.namespacesLister.List(labels.Everything())
if err != nil {
return nil, err
}
for _, ns := range allNs {
attachNets, err := c.config.AttachNetClient.K8sCniCncfIoV1().NetworkAttachmentDefinitions(ns.Name).List(context.Background(), metav1.ListOptions{})
if err != nil {
if k8serrors.IsForbidden(err) {
return nil, nil
} else {
klog.Errorf("failed to list attach-net-def, %v", err)
return nil, err
}
}
for _, attachNet := range attachNets.Items {
netCfg, err := loadNetConf([]byte(attachNet.Spec.Config))
if err != nil || netCfg.Type != util.CniTypeName {
continue
}
port := ovs.PodNameToPortName(pod, namespace, fmt.Sprintf("%s.%s.ovn", attachNet.Name, attachNet.Namespace))
if c.ovnClient.IsLogicalSwitchPortExist(port) {
ports = append(ports, port)
}
}
}
return ports, nil
}

func (c *Controller) handleUpdatePod(key string) error {
c.podKeyMutex.Lock(key)
defer c.podKeyMutex.Unlock(key)
Expand Down

0 comments on commit 808a3a9

Please sign in to comment.