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

Fix missing ICMP SNAT for L2 UDNs GR #4729

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions go-controller/pkg/ovn/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func WithLoadBalancerGroups(routerLBGroup, clusterLBGroup, switchLBGroup string)
// NOTE2: egressIP SNATs are synced in EIP controller.
// TODO (tssurya): Add support cleaning up even if disableSNATMultipleGWs=false, we'd need to remove the perPod
// SNATs in case someone switches between these modes. See https://github.com/ovn-org/ovn-kubernetes/issues/3232
func (gw *GatewayManager) cleanupStalePodSNATs(nodeName string, nodeIPs []*net.IPNet) error {
func (gw *GatewayManager) cleanupStalePodSNATs(nodeName string, nodeIPs []*net.IPNet, gwLRPIPs []net.IP) error {
if !config.Gateway.DisableSNATMultipleGWs {
return nil
}
Expand Down Expand Up @@ -209,6 +209,7 @@ func (gw *GatewayManager) cleanupStalePodSNATs(nodeName string, nodeIPs []*net.I
}

nodeIPset := sets.New(util.IPNetsIPToStringSlice(nodeIPs)...)
gwLRPIPset := sets.New(util.StringSlice(gwLRPIPs)...)
natsToDelete := []*nbdb.NAT{}
for _, routerNat := range routerNats {
routerNat := routerNat
Expand All @@ -221,14 +222,14 @@ func (gw *GatewayManager) cleanupStalePodSNATs(nodeName string, nodeIPs []*net.I
if podIPsOnNode.Has(routerNat.LogicalIP) {
continue
}
if gwLRPIPset.Has(routerNat.LogicalIP) {
continue
}
logicalIP := net.ParseIP(routerNat.LogicalIP)
if logicalIP == nil {
// this is probably a CIDR so not a pod IP
continue
}
if gw.containsJoinIP(logicalIP) {
continue
}
natsToDelete = append(natsToDelete, routerNat)
}
if len(natsToDelete) > 0 {
Expand Down Expand Up @@ -748,7 +749,7 @@ func (gw *GatewayManager) GatewayInit(
}
}

if err := gw.cleanupStalePodSNATs(nodeName, l3GatewayConfig.IPAddresses); err != nil {
if err := gw.cleanupStalePodSNATs(nodeName, l3GatewayConfig.IPAddresses, gwLRPIPs); err != nil {
return fmt.Errorf("failed to sync stale SNATs on node %s: %v", nodeName, err)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ func expectedLayer2EgressEntities(netInfo util.NetInfo, gwConfig util.L3GatewayC

var nat []string
if config.Gateway.DisableSNATMultipleGWs {
nat = append(nat, nat1, perPodSNAT, masqSNATUUID1)
nat = append(nat, nat1, nat3, perPodSNAT, masqSNATUUID1)
} else {
nat = append(nat, nat1, nat2, nat3, masqSNATUUID1)
}
Expand Down Expand Up @@ -457,6 +457,7 @@ func expectedLayer2EgressEntities(netInfo util.NetInfo, gwConfig util.L3GatewayC
expectedEntities = append(expectedEntities, expectedExternalSwitchAndLSPs(netInfo, gwConfig, nodeName)...)
if config.Gateway.DisableSNATMultipleGWs {
expectedEntities = append(expectedEntities, newNATEntry(nat1, dummyMasqueradeIP().IP.String(), gwRouterJoinIPAddress().IP.String(), standardNonDefaultNetworkExtIDs(netInfo)))
expectedEntities = append(expectedEntities, newNATEntry(nat3, dummyMasqueradeIP().IP.String(), layer2SubnetGWAddr().IP.String(), standardNonDefaultNetworkExtIDs(netInfo)))
expectedEntities = append(expectedEntities, newNATEntry(perPodSNAT, dummyMasqueradeIP().IP.String(), dummyL2TestPodAdditionalNetworkIP(), nil))
} else {
expectedEntities = append(expectedEntities, newNATEntry(nat1, dummyMasqueradeIP().IP.String(), gwRouterJoinIPAddress().IP.String(), standardNonDefaultNetworkExtIDs(netInfo)))
Expand Down
Loading