Skip to content

Commit cf4fcf1

Browse files
committed
incusd/network/ovn: Clear all existing records
Occasionaly we end up with some duplicate DB records, so make sure that our logic clearly removes any existing record as part of refreshing the load balancer. Signed-off-by: Stéphane Graber <[email protected]>
1 parent 6417fde commit cf4fcf1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

internal/server/network/ovn/ovn_nb_actions.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2975,8 +2975,12 @@ func (o *NB) CreateLoadBalancer(ctx context.Context, loadBalancerName OVNLoadBal
29752975
}
29762976

29772977
err := o.get(ctx, &lb)
2978-
if err == nil {
2979-
// Delete the load balancer.
2978+
if err == nil || err == ErrTooMany {
2979+
// Delete the load balancer (by name in case there are duplicates).
2980+
lb := ovnNB.LoadBalancer{
2981+
Name: name,
2982+
}
2983+
29802984
deleteOps, err := o.client.Where(&lb).Delete()
29812985
if err != nil {
29822986
return err

0 commit comments

Comments
 (0)