Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UDN: Design routes and policies on L2's GR correctly. #4694

Merged
merged 12 commits into from
Sep 18, 2024
Next Next commit
Layer2 UDN: Rename gateway switch ports
In Layer2 networks there is no join switch, only the cluster switch.
Ensure that the ports are named appropriately, this is important for
the logical router policies created for local node access.

Signed-off-by: Patryk Diak <pdiak@redhat.com>
(cherry picked from commit 967923e)
  • Loading branch information
kyrtapz authored and tssurya committed Sep 18, 2024
commit ea94a5aca5cd29f9db93015bb4d1df209d4fb0da
21 changes: 20 additions & 1 deletion go-controller/pkg/ovn/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,15 @@ func (gw *GatewayManager) GatewayInit(
gwSwitchPort := types.JoinSwitchToGWRouterPrefix + gatewayRouter
gwRouterPort := types.GWRouterToJoinSwitchPrefix + gatewayRouter

// In Layer2 networks there is no join switch and the gw.joinSwitchName points to the cluster switch.
// Ensure that the ports are named appropriately, this is important for the logical router policies
// created for local node access.
// TODO(kyrtapz): Clean this up for clarity as part of https://github.com/ovn-org/ovn-kubernetes/issues/4689
if gw.netInfo.TopologyType() == types.Layer2Topology {
gwSwitchPort = types.SwitchToRouterPrefix + gw.joinSwitchName
gwRouterPort = types.RouterToSwitchPrefix + gw.joinSwitchName
}

logicalSwitchPort := nbdb.LogicalSwitchPort{
Name: gwSwitchPort,
Type: "router",
Expand Down Expand Up @@ -1001,6 +1010,17 @@ func (gw *GatewayManager) Cleanup() error {
var nextHops []net.IP

gwRouterToJoinSwitchPortName := types.GWRouterToJoinSwitchPrefix + gw.gwRouterName
portName := types.JoinSwitchToGWRouterPrefix + gw.gwRouterName

// In Layer2 networks there is no join switch and the gw.joinSwitchName points to the cluster switch.
// Ensure that the ports are named appropriately, this is important for the logical router policies
// created for local node access.
// TODO(kyrtapz): Clean this up for clarity as part of https://github.com/ovn-org/ovn-kubernetes/issues/4689
if gw.netInfo.TopologyType() == types.Layer2Topology {
gwRouterToJoinSwitchPortName = types.RouterToSwitchPrefix + gw.joinSwitchName
portName = types.SwitchToRouterPrefix + gw.joinSwitchName
}

gwIPAddrs, err := libovsdbutil.GetLRPAddrs(gw.nbClient, gwRouterToJoinSwitchPortName)
if err != nil && !errors.Is(err, libovsdbclient.ErrNotFound) {
return fmt.Errorf(
Expand All @@ -1018,7 +1038,6 @@ func (gw *GatewayManager) Cleanup() error {
gw.policyRouteCleanup(nextHops)

// Remove the patch port that connects join switch to gateway router
portName := types.JoinSwitchToGWRouterPrefix + gw.gwRouterName
lsp := nbdb.LogicalSwitchPort{Name: portName}
sw := nbdb.LogicalSwitch{Name: gw.joinSwitchName}
err = libovsdbops.DeleteLogicalSwitchPorts(gw.nbClient, &sw, &lsp)
Expand Down
10 changes: 2 additions & 8 deletions go-controller/pkg/ovn/multihoming_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,7 @@ func (em *secondaryNetworkExpectationMachine) expectedLogicalSwitchesAndPorts(is
data = append(data, mgmtPort)
nodeslsps[switchName] = append(nodeslsps[switchName], mgmtPortUUID)

// there are multiple GRs in the cluster, thus their names must be scoped with the node name
gwRouterName := fmt.Sprintf(
"%s%s",
ovntypes.GWRouterPrefix,
ocInfo.bnc.GetNetworkScopedName(nodeName),
)
networkSwitchToGWRouterLSPName := ovntypes.JoinSwitchToGWRouterPrefix + gwRouterName
networkSwitchToGWRouterLSPName := ovntypes.SwitchToRouterPrefix + switchName
networkSwitchToGWRouterLSPUUID := networkSwitchToGWRouterLSPName + "-UUID"

data = append(data, &nbdb.LogicalSwitchPort{
Expand All @@ -201,7 +195,7 @@ func (em *secondaryNetworkExpectationMachine) expectedLogicalSwitchesAndPorts(is
"k8s.ovn.org/topology": ocInfo.bnc.TopologyType(),
"k8s.ovn.org/network": ocInfo.bnc.GetNetworkName(),
},
Options: map[string]string{"router-port": ovntypes.GWRouterToJoinSwitchPrefix + gwRouterName},
Options: map[string]string{"router-port": ovntypes.RouterToSwitchPrefix + switchName},
Type: "router",
})
nodeslsps[switchName] = append(nodeslsps[switchName], networkSwitchToGWRouterLSPUUID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ func expectedLayer2EgressEntities(netInfo util.NetInfo, gwConfig util.L3GatewayC
)
gwRouterName := fmt.Sprintf("GR_%s_test-node", netInfo.GetNetworkName())
staticRouteOutputPort := ovntypes.GWRouterToExtSwitchPrefix + gwRouterName
gwRouterToNetworkSwitchPortName := ovntypes.GWRouterToJoinSwitchPrefix + gwRouterName
gwRouterToNetworkSwitchPortName := ovntypes.RouterToSwitchPrefix + netInfo.GetNetworkScopedName(ovntypes.OVNLayer2Switch)
gwRouterToExtSwitchPortName := fmt.Sprintf("%s%s", ovntypes.GWRouterToExtSwitchPrefix, gwRouterName)
masqSNAT := newMasqueradeManagementNATEntry(masqSNATUUID1, "169.254.169.14", layer2Subnet().String(), netInfo)

Expand Down