From 141c4c3556e4753ea89c9fcb565e5ccffe557111 Mon Sep 17 00:00:00 2001 From: Oilbeater Date: Sun, 4 Dec 2022 21:30:10 +0800 Subject: [PATCH] fix: eip deletion (#2118) When eip and routed annotation deleted the nat and route rule are not deleted. --- pkg/controller/pod.go | 4 ++++ pkg/ovs/ovn-nbctl-legacy.go | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/controller/pod.go b/pkg/controller/pod.go index 63a7a7a810f..382237827c5 100644 --- a/pkg/controller/pod.go +++ b/pkg/controller/pod.go @@ -879,6 +879,10 @@ func (c *Controller) handleUpdatePod(key string) error { klog.Errorf("failed to add static route, %v", err) return err } + } else { + if err := c.ovnLegacyClient.DeleteStaticRoute(podIP, c.config.ClusterRouter); err != nil { + return err + } } } diff --git a/pkg/ovs/ovn-nbctl-legacy.go b/pkg/ovs/ovn-nbctl-legacy.go index 6a174e390e5..79982a6ecfd 100644 --- a/pkg/ovs/ovn-nbctl-legacy.go +++ b/pkg/ovs/ovn-nbctl-legacy.go @@ -1169,8 +1169,8 @@ func parseLrRouteListOutput(output string) (routeList []*StaticRoute, err error) func (c LegacyClient) UpdateNatRule(policy, logicalIP, externalIP, router, logicalMac, port string) error { // when dual protocol pod has eip or snat, will add nat for all dual addresses. - // will failed when logicalIP externalIP is different protocol. - if util.CheckProtocol(logicalIP) != util.CheckProtocol(externalIP) { + // will fail when logicalIP externalIP is different protocol. + if externalIP != "" && util.CheckProtocol(logicalIP) != util.CheckProtocol(externalIP) { return nil }