diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index cb228e49ed1..6805d4978d7 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -107,11 +107,10 @@ type Controller struct { resetIptablesEipQueue workqueue.RateLimitingInterface delIptablesEipQueue workqueue.RateLimitingInterface - podAnnotatedIptablesEipLister v1.PodLister - podAnnotatedIptablesEipSynced cache.InformerSynced - addPodAnnotatedIptablesEipQueue workqueue.RateLimitingInterface - updatePodAnnotatedIptablesEipQueue workqueue.RateLimitingInterface - delPodAnnotatedIptablesEipQueue workqueue.RateLimitingInterface + podAnnotatedIptablesEipLister v1.PodLister + podAnnotatedIptablesEipSynced cache.InformerSynced + addPodAnnotatedIptablesEipQueue workqueue.RateLimitingInterface + delPodAnnotatedIptablesEipQueue workqueue.RateLimitingInterface iptablesFipsLister kubeovnlister.IptablesFIPRuleLister iptablesFipSynced cache.InformerSynced @@ -119,11 +118,10 @@ type Controller struct { updateIptablesFipQueue workqueue.RateLimitingInterface delIptablesFipQueue workqueue.RateLimitingInterface - podAnnotatedIptablesFipLister v1.PodLister - podAnnotatedIptablesFipSynced cache.InformerSynced - addPodAnnotatedIptablesFipQueue workqueue.RateLimitingInterface - updatePodAnnotatedIptablesFipQueue workqueue.RateLimitingInterface - delPodAnnotatedIptablesFipQueue workqueue.RateLimitingInterface + podAnnotatedIptablesFipLister v1.PodLister + podAnnotatedIptablesFipSynced cache.InformerSynced + addPodAnnotatedIptablesFipQueue workqueue.RateLimitingInterface + delPodAnnotatedIptablesFipQueue workqueue.RateLimitingInterface iptablesDnatRulesLister kubeovnlister.IptablesDnatRuleLister iptablesDnatRuleSynced cache.InformerSynced @@ -306,11 +304,10 @@ func NewController(config *Configuration) *Controller { resetIptablesEipQueue: workqueue.NewNamedRateLimitingQueue(custCrdRateLimiter, "resetIptablesEip"), delIptablesEipQueue: workqueue.NewNamedRateLimitingQueue(custCrdRateLimiter, "delIptablesEip"), - podAnnotatedIptablesEipLister: podAnnotatedIptablesEipInformer.Lister(), - podAnnotatedIptablesEipSynced: podAnnotatedIptablesEipInformer.Informer().HasSynced, - addPodAnnotatedIptablesEipQueue: workqueue.NewNamedRateLimitingQueue(custCrdRateLimiter, "addPodAnnotatedIptablesEip"), - updatePodAnnotatedIptablesEipQueue: workqueue.NewNamedRateLimitingQueue(custCrdRateLimiter, "updatePodAnnotatedIptablesEip"), - delPodAnnotatedIptablesEipQueue: workqueue.NewNamedRateLimitingQueue(custCrdRateLimiter, "delPodAnnotatedIptablesEip"), + podAnnotatedIptablesEipLister: podAnnotatedIptablesEipInformer.Lister(), + podAnnotatedIptablesEipSynced: podAnnotatedIptablesEipInformer.Informer().HasSynced, + addPodAnnotatedIptablesEipQueue: workqueue.NewNamedRateLimitingQueue(custCrdRateLimiter, "AddPodAnnotatedIptablesEip"), + delPodAnnotatedIptablesEipQueue: workqueue.NewNamedRateLimitingQueue(custCrdRateLimiter, "DeletePodAnnotatedIptablesEip"), iptablesFipsLister: iptablesFipInformer.Lister(), iptablesFipSynced: iptablesFipInformer.Informer().HasSynced, @@ -318,11 +315,10 @@ func NewController(config *Configuration) *Controller { updateIptablesFipQueue: workqueue.NewNamedRateLimitingQueue(custCrdRateLimiter, "updateIptablesFip"), delIptablesFipQueue: workqueue.NewNamedRateLimitingQueue(custCrdRateLimiter, "delIptablesFip"), - podAnnotatedIptablesFipLister: podAnnotatedIptablesFipInformer.Lister(), - podAnnotatedIptablesFipSynced: podAnnotatedIptablesFipInformer.Informer().HasSynced, - addPodAnnotatedIptablesFipQueue: workqueue.NewNamedRateLimitingQueue(custCrdRateLimiter, "addPodAnnotatedIptablesFip"), - updatePodAnnotatedIptablesFipQueue: workqueue.NewNamedRateLimitingQueue(custCrdRateLimiter, "updatePodAnnotatedIptablesFip"), - delPodAnnotatedIptablesFipQueue: workqueue.NewNamedRateLimitingQueue(custCrdRateLimiter, "delPodAnnotatedIptablesFip"), + podAnnotatedIptablesFipLister: podAnnotatedIptablesFipInformer.Lister(), + podAnnotatedIptablesFipSynced: podAnnotatedIptablesFipInformer.Informer().HasSynced, + addPodAnnotatedIptablesFipQueue: workqueue.NewNamedRateLimitingQueue(custCrdRateLimiter, "AddPodAnnotatedIptablesFip"), + delPodAnnotatedIptablesFipQueue: workqueue.NewNamedRateLimitingQueue(custCrdRateLimiter, "DeletePodAnnotatedIptablesFip"), iptablesDnatRulesLister: iptablesDnatRuleInformer.Lister(), iptablesDnatRuleSynced: iptablesDnatRuleInformer.Informer().HasSynced, @@ -803,15 +799,12 @@ func (c *Controller) shutdown() { c.delIptablesSnatRuleQueue.ShutDown() } - if c.config.PodDefaultFipType == util.IptablesFip { - c.addPodAnnotatedIptablesEipQueue.ShutDown() - c.updatePodAnnotatedIptablesEipQueue.ShutDown() - c.delPodAnnotatedIptablesEipQueue.ShutDown() + c.addPodAnnotatedIptablesEipQueue.ShutDown() + c.delPodAnnotatedIptablesEipQueue.ShutDown() + + c.addPodAnnotatedIptablesFipQueue.ShutDown() + c.delPodAnnotatedIptablesFipQueue.ShutDown() - c.addPodAnnotatedIptablesFipQueue.ShutDown() - c.updatePodAnnotatedIptablesFipQueue.ShutDown() - c.delPodAnnotatedIptablesFipQueue.ShutDown() - } if c.config.EnableNP { c.updateNpQueue.ShutDown() c.deleteNpQueue.ShutDown() @@ -1005,13 +998,11 @@ func (c *Controller) startWorkers(ctx context.Context) { go wait.Until(c.runUpdateIptablesSnatRuleWorker, time.Second, ctx.Done()) go wait.Until(c.runDelIptablesSnatRuleWorker, time.Second, ctx.Done()) - if c.config.PodDefaultFipType == util.IptablesFip { - go wait.Until(c.runAddPodAnnotatedIptablesEipWorker, time.Second, ctx.Done()) - go wait.Until(c.runDelPodAnnotatedIptablesEipWorker, time.Second, ctx.Done()) + go wait.Until(c.runAddPodAnnotatedIptablesEipWorker, time.Second, ctx.Done()) + go wait.Until(c.runDelPodAnnotatedIptablesEipWorker, time.Second, ctx.Done()) - go wait.Until(c.runAddPodAnnotatedIptablesFipWorker, time.Second, ctx.Done()) - go wait.Until(c.runDelPodAnnotatedIptablesFipWorker, time.Second, ctx.Done()) - } + go wait.Until(c.runAddPodAnnotatedIptablesFipWorker, time.Second, ctx.Done()) + go wait.Until(c.runDelPodAnnotatedIptablesFipWorker, time.Second, ctx.Done()) } func (c *Controller) initResourceOnce() { diff --git a/pkg/controller/pod_iptables_eip.go b/pkg/controller/pod_iptables_eip.go index 59143ba675d..54242860d42 100644 --- a/pkg/controller/pod_iptables_eip.go +++ b/pkg/controller/pod_iptables_eip.go @@ -166,6 +166,13 @@ func (c *Controller) processNextAddPodAnnotatedIptablesEipWorkItem() bool { if shutdown { return false } + + if c.config.PodDefaultFipType != util.IptablesFip { + c.addPodAnnotatedIptablesEipQueue.Forget(obj) + c.addPodAnnotatedIptablesEipQueue.Done(obj) + return true + } + err := func(obj interface{}) error { defer c.addPodAnnotatedIptablesEipQueue.Done(obj) var key string @@ -195,6 +202,13 @@ func (c *Controller) processNextDeletePodAnnotatedIptablesEipWorkItem() bool { if shutdown { return false } + + if c.config.PodDefaultFipType != util.IptablesFip { + c.delPodAnnotatedIptablesEipQueue.Forget(obj) + c.delPodAnnotatedIptablesEipQueue.Done(obj) + return true + } + err := func(obj interface{}) error { defer c.delPodAnnotatedIptablesEipQueue.Done(obj) var pod *v1.Pod diff --git a/pkg/controller/pod_iptables_fip.go b/pkg/controller/pod_iptables_fip.go index dc7b210ea19..ac98ed45bf2 100644 --- a/pkg/controller/pod_iptables_fip.go +++ b/pkg/controller/pod_iptables_fip.go @@ -154,6 +154,13 @@ func (c *Controller) processNextAddPodAnnotatedIptablesFipWorkItem() bool { if shutdown { return false } + + if c.config.PodDefaultFipType != util.IptablesFip { + c.addPodAnnotatedIptablesFipQueue.Forget(obj) + c.addPodAnnotatedIptablesFipQueue.Done(obj) + return true + } + err := func(obj interface{}) error { defer c.addPodAnnotatedIptablesFipQueue.Done(obj) var key string @@ -182,6 +189,13 @@ func (c *Controller) processNextDeletePodAnnotatedIptablesFipWorkItem() bool { if shutdown { return false } + + if c.config.PodDefaultFipType != util.IptablesFip { + c.delPodAnnotatedIptablesFipQueue.Forget(obj) + c.delPodAnnotatedIptablesFipQueue.Done(obj) + return true + } + err := func(obj interface{}) error { defer c.delPodAnnotatedIptablesFipQueue.Done(obj) var pod *v1.Pod