Skip to content

Commit 2505c88

Browse files
authored
Merge pull request #1762 from stgraber/ovn
incusd/network/ovn: Skip existing static routes
2 parents 7bba71e + 5ce9370 commit 2505c88

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

internal/server/network/ovn/ovn_nb_actions.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,7 @@ func (o *NB) CreateLogicalRouterRoute(ctx context.Context, routerName OVNRouter,
509509
operations := []ovsdb.Operation{}
510510
for i, route := range routes {
511511
// Check if already present.
512+
exists := false
512513
for _, existing := range existingRoutes {
513514
if existing.IPPrefix != route.Prefix.String() {
514515
continue
@@ -531,12 +532,18 @@ func (o *NB) CreateLogicalRouterRoute(ctx context.Context, routerName OVNRouter,
531532
}
532533

533534
if mayExist {
534-
continue
535+
exists = true
536+
break
535537
}
536538

537539
return ErrExists
538540
}
539541

542+
// Don't add duplicate entries.
543+
if exists {
544+
continue
545+
}
546+
540547
// Create the new record.
541548
staticRoute := ovnNB.LogicalRouterStaticRoute{
542549
UUID: fmt.Sprintf("route_%d", i),

0 commit comments

Comments
 (0)