Skip to content

Commit

Permalink
fix: not update lsp into another ls
Browse files Browse the repository at this point in the history
Signed-off-by: bobz965 <[email protected]>
  • Loading branch information
bobz965 committed Dec 4, 2024
1 parent e642eef commit b06cad8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pkg/ovs/ovn-nb-logical_switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@ func (c *OVNNbClient) LogicalSwitchUpdatePortOp(lsName, lspUUID string, op ovsdb
return nil, nil
}

if lsName == "" && op == ovsdb.MutateOperationDelete {
if op == ovsdb.MutateOperationDelete {
// given ls for deleting lsp is not always real
lsList, err := c.ListLogicalSwitch(false, func(ls *ovnnb.LogicalSwitch) bool {
return slices.Contains(ls.Ports, lspUUID)
})
Expand Down
10 changes: 8 additions & 2 deletions pkg/ovs/ovn-nb-logical_switch_port.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,15 @@ func (c *OVNNbClient) CreateLogicalSwitchPort(lsName, lspName, ip, mac, podName,
return fmt.Errorf("failed to update logical switch port %s: %w", lspName, err)
}
return nil
}
if ops, err = c.LogicalSwitchUpdatePortOp(existingLsp.ExternalIDs[logicalSwitchKey], existingLsp.UUID, ovsdb.MutateOperationDelete); err != nil {
} else {
// delete lsp from the old logical switch
err := fmt.Errorf("logical switch port %s already exists in old logical switch %s, delete it", lspName, existingLsp.ExternalIDs[logicalSwitchKey])
klog.Error(err)
if err := c.DeleteLogicalSwitchPort(lspName); err != nil {
klog.Error(err)
return err
}
// enqueue to re-create lsp in the new logical switch
return err
}
}
Expand Down

0 comments on commit b06cad8

Please sign in to comment.