Skip to content

Commit

Permalink
ignore pod without lsp when add pod to port-group
Browse files Browse the repository at this point in the history
  • Loading branch information
hongzhen-ma committed Sep 21, 2022
1 parent 6df23c2 commit ff176b8
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions pkg/controller/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ func (c *Controller) reconcileOvnRoute(subnet *kubeovnv1.Subnet) error {
}
}

_, idNameMap, err := c.ovnLegacyClient.ListLspForNodePortgroup()
nameIdMap, idNameMap, err := c.ovnLegacyClient.ListLspForNodePortgroup()
if err != nil {
klog.Errorf("failed to list lsp info, %v", err)
return err
Expand All @@ -906,6 +906,10 @@ func (c *Controller) reconcileOvnRoute(subnet *kubeovnv1.Subnet) error {
if c.config.EnableEipSnat && (pod.Annotations[util.EipAnnotation] != "" || pod.Annotations[util.SnatAnnotation] != "") {
continue
}
// Pod will add to port-group when pod get updated
if pod.Spec.NodeName == "" {
continue
}

podNets, err := c.getPodKubeovnNets(pod)
if err != nil {
Expand Down Expand Up @@ -948,10 +952,6 @@ func (c *Controller) reconcileOvnRoute(subnet *kubeovnv1.Subnet) error {
if pod.Annotations[util.NorthGatewayAnnotation] != "" {
continue
}
// Pod will add to port-group when pod get updated
if pod.Spec.NodeName == "" {
continue
}

pgName := getOverlaySubnetsPortGroupName(subnet.Name, pod.Spec.NodeName)
c.ovnPgKeyMutex.Lock(pgName)
Expand All @@ -964,6 +964,11 @@ func (c *Controller) reconcileOvnRoute(subnet *kubeovnv1.Subnet) error {

portsToAdd := make([]string, 0, len(podPorts))
for _, port := range podPorts {
if _, ok := nameIdMap[port]; !ok {
klog.Errorf("lsp does not exist for pod %v, please delete the pod and retry", port)
continue
}

if _, ok := pgPorts[port]; !ok {
portsToAdd = append(portsToAdd, port)
}
Expand Down

0 comments on commit ff176b8

Please sign in to comment.