From 1c180e0865a63bec5848075bdd59c04fa7387258 Mon Sep 17 00:00:00 2001 From: Tim Hockin Date: Wed, 1 Feb 2017 11:36:24 -0800 Subject: [PATCH] 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. --- pkg/proxy/iptables/proxier.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pkg/proxy/iptables/proxier.go b/pkg/proxy/iptables/proxier.go index 311ef58d04b..612f8cfb638 100644 --- a/pkg/proxy/iptables/proxier.go +++ b/pkg/proxy/iptables/proxier.go @@ -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 {