From dbe89a568301884bc6502bc5e0b20d9ff44037f4 Mon Sep 17 00:00:00 2001 From: jornshen Date: Sun, 17 Jan 2021 12:08:17 +0800 Subject: [PATCH] migrate kube canary chain as const --- pkg/proxy/iptables/proxier.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/proxy/iptables/proxier.go b/pkg/proxy/iptables/proxier.go index be9804148e6..c5a912bef52 100644 --- a/pkg/proxy/iptables/proxier.go +++ b/pkg/proxy/iptables/proxier.go @@ -77,6 +77,9 @@ const ( // the kubernetes forward chain kubeForwardChain utiliptables.Chain = "KUBE-FORWARD" + + // kube proxy canary chain is used for monitoring rule reload + kubeProxyCanaryChain utiliptables.Chain = "KUBE-PROXY-CANARY" ) // KernelCompatTester tests whether the required kernel capabilities are @@ -338,8 +341,7 @@ func NewProxier(ipt utiliptables.Interface, // time.Hour is arbitrary. proxier.syncRunner = async.NewBoundedFrequencyRunner("sync-runner", proxier.syncProxyRules, minSyncPeriod, time.Hour, burstSyncs) - go ipt.Monitor(utiliptables.Chain("KUBE-PROXY-CANARY"), - []utiliptables.Table{utiliptables.TableMangle, utiliptables.TableNAT, utiliptables.TableFilter}, + go ipt.Monitor(kubeProxyCanaryChain, []utiliptables.Table{utiliptables.TableMangle, utiliptables.TableNAT, utiliptables.TableFilter}, proxier.syncProxyRules, syncPeriod, wait.NeverStop) if ipt.HasRandomFully() { @@ -1364,7 +1366,7 @@ func (proxier *Proxier) syncProxyRules() { endpointChains = append(endpointChains, endpointChain) // Create the endpoint chain, retaining counters if possible. - if chain, ok := existingNATChains[utiliptables.Chain(endpointChain)]; ok { + if chain, ok := existingNATChains[endpointChain]; ok { utilproxy.WriteBytesLine(proxier.natChains, chain) } else { utilproxy.WriteLine(proxier.natChains, utiliptables.MakeChainLine(endpointChain))