Skip to content

Commit

Permalink
fix: CleanLogicalSwitchPortMigrateOptions
Browse files Browse the repository at this point in the history
Signed-off-by: bobz965 <zhangbingbing2_yewu@cmss.chinamobile.com>
  • Loading branch information
zbb88888 committed Mar 3, 2024
1 parent 2c0a57c commit 40e0f32
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions pkg/controller/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -729,13 +729,6 @@ func (c *Controller) reconcileAllocateSubnets(cachedPod, pod *v1.Pod, needAlloca
DHCPv4OptionsUUID: subnet.Status.DHCPv4OptionsUUID,
DHCPv6OptionsUUID: subnet.Status.DHCPv6OptionsUUID,
}
if isVMPod && !isMigrate {
if err := c.OVNNbClient.CleanLogicalSwitchPortMigrateOptions(portName); err != nil {
err = fmt.Errorf("failed to clean migrate options for lsp %s, %v", portName, err)
klog.Error(err)
return nil, err
}
}
if err := c.OVNNbClient.CreateLogicalSwitchPort(subnet.Name, portName, ipStr, mac, podName, pod.Namespace,
portSecurity, securityGroupAnnotation, vips, podNet.Subnet.Spec.EnableDHCP, dhcpOptions, subnet.Spec.Vpc); err != nil {
c.recorder.Eventf(pod, v1.EventTypeWarning, "CreateOVNPortFailed", err.Error())
Expand Down Expand Up @@ -1149,6 +1142,19 @@ func (c *Controller) handleDeletePod(key string) error {
return err
}
}
} else if isVMPod {
ports, err := c.OVNNbClient.ListNormalLogicalSwitchPorts(true, map[string]string{"pod": podKey})
if err != nil {
klog.Errorf("failed to list lsps of pod '%s', %v", pod.Name, err)
return err
}
for _, port := range ports {
if err := c.OVNNbClient.CleanLogicalSwitchPortMigrateOptions(port.Name); err != nil {
err = fmt.Errorf("failed to clean migrate options for lsp %s, %v", port.Name, err)
klog.Error(err)
return err
}
}
}
for _, podNet := range podNets {
c.syncVirtualPortsQueue.Add(podNet.Subnet.Name)
Expand Down

0 comments on commit 40e0f32

Please sign in to comment.