Skip to content

Commit

Permalink
Fix NodePort/LoadBalancer issue when proxyAll is enabled
Browse files Browse the repository at this point in the history
When proxyAll is enabled, create a NodePort/LoadBalancer Service whose
externalTrafficPolicy is Cluster, then only an OVS group with all
Endpoints will be installed. If change externalTrafficPolicy of the
Service from Cluster to Local, an OVS group with only local Endpoints
should be also installed since externalTrafficPolicy is Local, but it
is not. This patch fixes the issue that OVS group with only local
Endpoints is not installed when externalTrafficPolicy of Service is
changed from Cluster to Local.

Signed-off-by: Hongliang Liu <[email protected]>
  • Loading branch information
hongliangl committed Feb 9, 2022
1 parent 70fac83 commit aa411cd
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pkg/agent/proxy/proxier.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,21 @@ func (p *proxier) installServices() {
nGroupID := groupID
if svcInfo.NodeLocalExternal() {
nGroupID, _ = p.groupCounter.Get(svcPortName, true)
var localEndpointUpdateList []k8sproxy.Endpoint
// If externalTrafficPolicy of the previous Service is Cluster, a group which only has local Endpoints
// should be installed.
if pSvcInfo != nil && !pSvcInfo.NodeLocalExternal() {
for _, ed := range endpointUpdateList {
if ed.GetIsLocal() {
localEndpointUpdateList = append(localEndpointUpdateList, ed)
}
}
err := p.ofClient.InstallServiceGroup(nGroupID, svcInfo.StickyMaxAgeSeconds() != 0, localEndpointUpdateList)
if err != nil {
klog.ErrorS(err, "Error when installing Endpoints groups")
continue
}
}
}

if p.proxyAll {
Expand Down

0 comments on commit aa411cd

Please sign in to comment.