Merge pull request #72432 from DataDog/issue-71596

Fix for #71596
This commit is contained in:
Kubernetes Prow Robot 2019-01-03 20:22:15 -08:00 committed by GitHub
commit dfea6456f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 13 deletions

View File

@ -1028,11 +1028,9 @@ func (proxier *Proxier) syncProxyRules() {
serv.Timeout = uint32(svcInfo.StickyMaxAgeSeconds) serv.Timeout = uint32(svcInfo.StickyMaxAgeSeconds)
} }
if err := proxier.syncService(svcNameString, serv, true); err == nil { if err := proxier.syncService(svcNameString, serv, true); err == nil {
// check if service need skip endpoints that not in same host as kube-proxy
onlyLocal := svcInfo.SessionAffinityType == v1.ServiceAffinityClientIP && svcInfo.OnlyNodeLocalEndpoints
activeIPVSServices[serv.String()] = true activeIPVSServices[serv.String()] = true
activeBindAddrs[serv.Address.String()] = true activeBindAddrs[serv.Address.String()] = true
if err := proxier.syncEndpoint(svcName, onlyLocal, serv); err != nil { if err := proxier.syncEndpoint(svcName, svcInfo.OnlyNodeLocalEndpoints, serv); err != nil {
klog.Errorf("Failed to sync endpoint for service: %v, err: %v", serv, err) klog.Errorf("Failed to sync endpoint for service: %v, err: %v", serv, err)
} }
} else { } else {

View File

@ -1266,18 +1266,32 @@ func TestOnlyLocalLoadBalancing(t *testing.T) {
) )
epIP := "10.180.0.1" epIP := "10.180.0.1"
epIP1 := "10.180.1.1"
thisHostname := testHostname
otherHostname := "other-hostname"
makeEndpointsMap(fp, makeEndpointsMap(fp,
makeTestEndpoints(svcPortName.Namespace, svcPortName.Name, func(ept *v1.Endpoints) { makeTestEndpoints(svcPortName.Namespace, svcPortName.Name, func(ept *v1.Endpoints) {
ept.Subsets = []v1.EndpointSubset{{ ept.Subsets = []v1.EndpointSubset{
Addresses: []v1.EndpointAddress{{ { // **local** endpoint address, should be added as RS
IP: epIP, Addresses: []v1.EndpointAddress{{
NodeName: nil, IP: epIP,
}}, NodeName: &thisHostname,
Ports: []v1.EndpointPort{{ }},
Name: svcPortName.Port, Ports: []v1.EndpointPort{{
Port: int32(svcPort), Name: svcPortName.Port,
}}, Port: int32(svcPort),
}} }}},
{ // **remote** endpoint address, should not be added as RS
Addresses: []v1.EndpointAddress{{
IP: epIP1,
NodeName: &otherHostname,
}},
Ports: []v1.EndpointPort{{
Name: svcPortName.Port,
Port: int32(svcPort),
}},
}}
}), }),
) )