From ed802f1db7368b32438df7e55552ae4b0b8eb112 Mon Sep 17 00:00:00 2001 From: Lion-Wei Date: Wed, 13 Sep 2017 14:47:58 +0800 Subject: [PATCH] add FlagPersistent flag in nodePort and other situation --- pkg/proxy/ipvs/proxier.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pkg/proxy/ipvs/proxier.go b/pkg/proxy/ipvs/proxier.go index 6c4ad357240..5cba9aa24a2 100644 --- a/pkg/proxy/ipvs/proxier.go +++ b/pkg/proxy/ipvs/proxier.go @@ -952,7 +952,6 @@ func (proxier *Proxier) syncProxyRules(reason syncReason) { Scheduler: proxier.ipvsScheduler, } // Set session affinity flag and timeout for IPVS service - var flags utilipvs.ServiceFlags if svcInfo.sessionAffinityType == api.ServiceAffinityClientIP { serv.Flags |= utilipvs.FlagPersistent serv.Timeout = uint32(svcInfo.stickyMaxAgeSeconds) @@ -1030,10 +1029,10 @@ func (proxier *Proxier) syncProxyRules(reason syncReason) { Address: net.ParseIP(externalIP), Port: uint16(svcInfo.port), Protocol: string(svcInfo.protocol), - Flags: flags, Scheduler: proxier.ipvsScheduler, } if svcInfo.sessionAffinityType == api.ServiceAffinityClientIP { + serv.Flags |= utilipvs.FlagPersistent serv.Timeout = uint32(svcInfo.stickyMaxAgeSeconds) } // There is no need to bind externalIP to dummy interface, so set parameter `bindAddr` to `false`. @@ -1091,10 +1090,10 @@ func (proxier *Proxier) syncProxyRules(reason syncReason) { Address: net.ParseIP(ingress.IP), Port: uint16(svcInfo.port), Protocol: string(svcInfo.protocol), - Flags: flags, Scheduler: proxier.ipvsScheduler, } if svcInfo.sessionAffinityType == api.ServiceAffinityClientIP { + serv.Flags |= utilipvs.FlagPersistent serv.Timeout = uint32(svcInfo.stickyMaxAgeSeconds) } // There is no need to bind LB ingress.IP to dummy interface, so set parameter `bindAddr` to `false`. @@ -1141,10 +1140,10 @@ func (proxier *Proxier) syncProxyRules(reason syncReason) { Address: nodeIP, Port: uint16(svcInfo.nodePort), Protocol: string(svcInfo.protocol), - Flags: flags, Scheduler: proxier.ipvsScheduler, } if svcInfo.sessionAffinityType == api.ServiceAffinityClientIP { + serv.Flags |= utilipvs.FlagPersistent serv.Timeout = uint32(svcInfo.stickyMaxAgeSeconds) } // There is no need to bind Node IP to dummy interface, so set parameter `bindAddr` to `false`.