Skip to content

Commit 6011b90

Browse files
committed
fix: clean up garbage lsp (#5172)
* clean up garbage lsp Signed-off-by: clyi <[email protected]> * fix Signed-off-by: clyi <[email protected]> * fix Signed-off-by: clyi <[email protected]> * fixx Signed-off-by: clyi <[email protected]> --------- Signed-off-by: clyi <[email protected]>
1 parent 05b7d83 commit 6011b90

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pkg/controller/node.go

+8
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ func (c *Controller) handleAddNode(key string) error {
130130
}
131131

132132
var v4IP, v6IP, mac string
133+
133134
portName := util.NodeLspName(key)
134135
if node.Annotations[util.AllocatedAnnotation] == "true" && node.Annotations[util.IPAddressAnnotation] != "" && node.Annotations[util.MacAddressAnnotation] != "" {
135136
macStr := node.Annotations[util.MacAddressAnnotation]
@@ -145,6 +146,13 @@ func (c *Controller) handleAddNode(key string) error {
145146
klog.Errorf("failed to alloc random ip addrs for node %v: %v", node.Name, err)
146147
return err
147148
}
149+
150+
// Clean up potentially existing logical switch ports to avoid leftover issues from previous failed configurations
151+
if err := c.OVNNbClient.DeleteLogicalSwitchPort(portName); err != nil {
152+
klog.Errorf("failed to delete stale logical switch port %s: %v", portName, err)
153+
return err
154+
}
155+
klog.Infof("deleted stale logical switch port %s", portName)
148156
}
149157

150158
ipStr := util.GetStringIP(v4IP, v6IP)

0 commit comments

Comments
 (0)