Simplify "is local" detection

Move the feature test to where we are activating the feature, rather
than where we detect locality.  This is in service of better tests,
which is in service of less-frequent resyncing, which is going to
require refactoring.
pull/6/head
Tim Hockin 2017-02-01 11:36:24 -08:00
parent 14bdeceeb4
commit 1c180e0865
1 changed files with 5 additions and 6 deletions

View File

@ -606,15 +606,10 @@ func (proxier *Proxier) OnEndpointsUpdate(allEndpoints []api.Endpoints) {
port := &ss.Ports[i]
for i := range ss.Addresses {
addr := &ss.Addresses[i]
var isLocalEndpoint bool
if addr.NodeName != nil {
isLocalEndpoint = *addr.NodeName == proxier.hostname
isLocalEndpoint = utilfeature.DefaultFeatureGate.Enabled(features.ExternalTrafficLocalOnly) && isLocalEndpoint
}
hostPortObject := hostPortInfo{
host: addr.IP,
port: int(port.Port),
localEndpoint: isLocalEndpoint,
localEndpoint: addr.NodeName != nil && *addr.NodeName == proxier.hostname,
}
portsToEndpoints[port.Name] = append(portsToEndpoints[port.Name], hostPortObject)
}
@ -675,6 +670,10 @@ func (proxier *Proxier) OnEndpointsUpdate(allEndpoints []api.Endpoints) {
// updateHealthCheckEntries - send the new set of local endpoints to the health checker
func (proxier *Proxier) updateHealthCheckEntries(name types.NamespacedName, hostPorts []hostPortInfo) {
if !utilfeature.DefaultFeatureGate.Enabled(features.ExternalTrafficLocalOnly) {
return
}
// Use a set instead of a slice to provide deduplication
endpoints := sets.NewString()
for _, portInfo := range hostPorts {