From e9c27c60556c4a115df0b06996919d3ca8ec5517 Mon Sep 17 00:00:00 2001 From: xujunjie-cover Date: Fri, 22 Jul 2022 12:12:29 +0800 Subject: [PATCH] fix: If pod has snat or eip, also need delete staticRoute when delete pod. (#1731) Signed-off-by: xujunjie-cover (cherry picked from commit ce40f7ed000da1ddfbb75e297eaec7dd9f48b99c) --- pkg/controller/pod.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/controller/pod.go b/pkg/controller/pod.go index a4e07f34e62..ee4c33dddd3 100644 --- a/pkg/controller/pod.go +++ b/pkg/controller/pod.go @@ -646,8 +646,14 @@ func (c *Controller) handleDeletePod(pod *v1.Pod) error { } else if err != nil { return err } + // If pod has snat or eip, also need delete staticRoute when delete pod + if vpc.Name == util.DefaultVpc { + if err := c.ovnLegacyClient.DeleteStaticRoute(address.Ip, vpc.Name); err != nil { + return err + } + } if exGwEnabled == "true" { - if err := c.ovnLegacyClient.DeleteNatRule(address.Ip, vpc.Status.Router); err != nil { + if err := c.ovnLegacyClient.DeleteNatRule(address.Ip, vpc.Name); err != nil { return err } }