diff --git a/cmd/kube-proxy/app/server.go b/cmd/kube-proxy/app/server.go index 02234ae5916..cd900f3580d 100644 --- a/cmd/kube-proxy/app/server.go +++ b/cmd/kube-proxy/app/server.go @@ -168,7 +168,7 @@ type ProxyServer struct { Recorder events.EventRecorder NodeRef *v1.ObjectReference HealthzServer *healthcheck.ProxyHealthServer - Hostname string + NodeName string PrimaryIPFamily v1.IPFamily NodeIPs map[v1.IPFamily]net.IP flagz flagz.Reader @@ -197,7 +197,7 @@ func newProxyServer(ctx context.Context, config *kubeproxyconfig.KubeProxyConfig metrics.SetShowHidden() } - s.Hostname, err = nodeutil.GetHostname(config.HostnameOverride) + s.NodeName, err = nodeutil.GetHostname(config.HostnameOverride) if err != nil { return nil, err } @@ -207,7 +207,7 @@ func newProxyServer(ctx context.Context, config *kubeproxyconfig.KubeProxyConfig return nil, err } - rawNodeIPs := getNodeIPs(ctx, s.Client, s.Hostname) + rawNodeIPs := getNodeIPs(ctx, s.Client, s.NodeName) s.PrimaryIPFamily, s.NodeIPs = detectNodeIPs(ctx, rawNodeIPs, config.BindAddress) if len(config.NodePortAddresses) == 1 && config.NodePortAddresses[0] == kubeproxyconfig.NodePortAddressesPrimary { @@ -226,8 +226,8 @@ func newProxyServer(ctx context.Context, config *kubeproxyconfig.KubeProxyConfig s.NodeRef = &v1.ObjectReference{ Kind: "Node", - Name: s.Hostname, - UID: types.UID(s.Hostname), + Name: s.NodeName, + UID: types.UID(s.NodeName), Namespace: "", } diff --git a/cmd/kube-proxy/app/server_linux.go b/cmd/kube-proxy/app/server_linux.go index a4769d3817b..9f95f8e28dd 100644 --- a/cmd/kube-proxy/app/server_linux.go +++ b/cmd/kube-proxy/app/server_linux.go @@ -81,8 +81,8 @@ func (o *Options) platformApplyDefaults(config *proxyconfigapi.KubeProxyConfigur func (s *ProxyServer) platformSetup(ctx context.Context) error { logger := klog.FromContext(ctx) if s.Config.DetectLocalMode == proxyconfigapi.LocalModeNodeCIDR { - logger.Info("Watching for node, awaiting podCIDR allocation", "hostname", s.Hostname) - node, err := waitForPodCIDR(ctx, s.Client, s.Hostname) + logger.Info("Watching for node, awaiting podCIDR allocation", "node", s.NodeName) + node, err := waitForPodCIDR(ctx, s.Client, s.NodeName) if err != nil { return err } @@ -157,7 +157,7 @@ func (s *ProxyServer) createProxier(ctx context.Context, config *proxyconfigapi. *config.IPTables.LocalhostNodePorts, int(*config.IPTables.MasqueradeBit), localDetectors, - s.Hostname, + s.NodeName, s.NodeIPs, s.Recorder, s.HealthzServer, @@ -179,7 +179,7 @@ func (s *ProxyServer) createProxier(ctx context.Context, config *proxyconfigapi. *config.IPTables.LocalhostNodePorts, int(*config.IPTables.MasqueradeBit), localDetectors[s.PrimaryIPFamily], - s.Hostname, + s.NodeName, s.NodeIPs[s.PrimaryIPFamily], s.Recorder, s.HealthzServer, @@ -217,7 +217,7 @@ func (s *ProxyServer) createProxier(ctx context.Context, config *proxyconfigapi. config.Linux.MasqueradeAll, int(*config.IPTables.MasqueradeBit), localDetectors, - s.Hostname, + s.NodeName, s.NodeIPs, s.Recorder, s.HealthzServer, @@ -243,7 +243,7 @@ func (s *ProxyServer) createProxier(ctx context.Context, config *proxyconfigapi. config.Linux.MasqueradeAll, int(*config.IPTables.MasqueradeBit), localDetectors[s.PrimaryIPFamily], - s.Hostname, + s.NodeName, s.NodeIPs[s.PrimaryIPFamily], s.Recorder, s.HealthzServer, @@ -267,7 +267,7 @@ func (s *ProxyServer) createProxier(ctx context.Context, config *proxyconfigapi. config.Linux.MasqueradeAll, int(*config.NFTables.MasqueradeBit), localDetectors, - s.Hostname, + s.NodeName, s.NodeIPs, s.Recorder, s.HealthzServer, @@ -285,7 +285,7 @@ func (s *ProxyServer) createProxier(ctx context.Context, config *proxyconfigapi. config.Linux.MasqueradeAll, int(*config.NFTables.MasqueradeBit), localDetectors[s.PrimaryIPFamily], - s.Hostname, + s.NodeName, s.NodeIPs[s.PrimaryIPFamily], s.Recorder, s.HealthzServer, diff --git a/cmd/kube-proxy/app/server_linux_test.go b/cmd/kube-proxy/app/server_linux_test.go index b224daf057e..3918a152793 100644 --- a/cmd/kube-proxy/app/server_linux_test.go +++ b/cmd/kube-proxy/app/server_linux_test.go @@ -703,7 +703,7 @@ func TestProxyServer_platformSetup(t *testing.T) { s := &ProxyServer{ Config: tt.config, Client: client, - Hostname: "nodename", + NodeName: "nodename", NodeIPs: map[v1.IPFamily]net.IP{ v1.IPv4Protocol: netutils.ParseIPSloppy("127.0.0.1"), v1.IPv6Protocol: net.IPv6zero, diff --git a/cmd/kube-proxy/app/server_windows.go b/cmd/kube-proxy/app/server_windows.go index 1d7f5d451ff..05d1ddafd3d 100644 --- a/cmd/kube-proxy/app/server_windows.go +++ b/cmd/kube-proxy/app/server_windows.go @@ -93,7 +93,7 @@ func (s *ProxyServer) createProxier(ctx context.Context, config *proxyconfigapi. proxier, err = winkernel.NewDualStackProxier( config.SyncPeriod.Duration, config.MinSyncPeriod.Duration, - s.Hostname, + s.NodeName, s.NodeIPs, s.Recorder, s.HealthzServer, @@ -105,7 +105,7 @@ func (s *ProxyServer) createProxier(ctx context.Context, config *proxyconfigapi. s.PrimaryIPFamily, config.SyncPeriod.Duration, config.MinSyncPeriod.Duration, - s.Hostname, + s.NodeName, s.NodeIPs[s.PrimaryIPFamily], s.Recorder, s.HealthzServer, diff --git a/pkg/proxy/endpointschangetracker.go b/pkg/proxy/endpointschangetracker.go index 3bb113c5b16..a152100c74b 100644 --- a/pkg/proxy/endpointschangetracker.go +++ b/pkg/proxy/endpointschangetracker.go @@ -59,7 +59,7 @@ type makeEndpointFunc func(info *BaseEndpointInfo, svcPortName *ServicePortName) type processEndpointsMapChangeFunc func(oldEndpointsMap, newEndpointsMap EndpointsMap) // NewEndpointsChangeTracker initializes an EndpointsChangeTracker -func NewEndpointsChangeTracker(ipFamily v1.IPFamily, hostname string, makeEndpointInfo makeEndpointFunc, processEndpointsMapChange processEndpointsMapChangeFunc) *EndpointsChangeTracker { +func NewEndpointsChangeTracker(ipFamily v1.IPFamily, nodeName string, makeEndpointInfo makeEndpointFunc, processEndpointsMapChange processEndpointsMapChangeFunc) *EndpointsChangeTracker { addressType := discovery.AddressTypeIPv4 if ipFamily == v1.IPv6Protocol { addressType = discovery.AddressTypeIPv6 @@ -70,7 +70,7 @@ func NewEndpointsChangeTracker(ipFamily v1.IPFamily, hostname string, makeEndpoi lastChangeTriggerTimes: make(map[types.NamespacedName][]time.Time), trackerStartTime: time.Now(), processEndpointsMapChange: processEndpointsMapChange, - endpointSliceCache: NewEndpointSliceCache(hostname, makeEndpointInfo), + endpointSliceCache: NewEndpointSliceCache(nodeName, makeEndpointInfo), } } diff --git a/pkg/proxy/endpointslicecache.go b/pkg/proxy/endpointslicecache.go index f17cc5ed8a9..c194afd52f5 100644 --- a/pkg/proxy/endpointslicecache.go +++ b/pkg/proxy/endpointslicecache.go @@ -43,7 +43,7 @@ type EndpointSliceCache struct { trackerByServiceMap map[types.NamespacedName]*endpointSliceTracker makeEndpointInfo makeEndpointFunc - hostname string + nodeName string } // endpointSliceTracker keeps track of EndpointSlices as they have been applied @@ -65,13 +65,13 @@ type endpointSliceData struct { } // NewEndpointSliceCache initializes an EndpointSliceCache. -func NewEndpointSliceCache(hostname string, makeEndpointInfo makeEndpointFunc) *EndpointSliceCache { +func NewEndpointSliceCache(nodeName string, makeEndpointInfo makeEndpointFunc) *EndpointSliceCache { if makeEndpointInfo == nil { makeEndpointInfo = standardEndpointInfo } return &EndpointSliceCache{ trackerByServiceMap: map[types.NamespacedName]*endpointSliceTracker{}, - hostname: hostname, + nodeName: nodeName, makeEndpointInfo: makeEndpointInfo, } } @@ -233,8 +233,8 @@ func (cache *EndpointSliceCache) addEndpoints(svcPortName *ServicePortName, port return endpointSet } -func (cache *EndpointSliceCache) isLocal(hostname string) bool { - return len(cache.hostname) > 0 && hostname == cache.hostname +func (cache *EndpointSliceCache) isLocal(nodeName string) bool { + return len(cache.nodeName) > 0 && nodeName == cache.nodeName } // esDataChanged returns true if the esData parameter should be set as a new diff --git a/pkg/proxy/healthcheck/service_health.go b/pkg/proxy/healthcheck/service_health.go index 37a4ed7b6fa..0d4f066dd0b 100644 --- a/pkg/proxy/healthcheck/service_health.go +++ b/pkg/proxy/healthcheck/service_health.go @@ -57,7 +57,7 @@ type proxyHealthChecker interface { Health() ProxyHealth } -func newServiceHealthServer(hostname string, recorder events.EventRecorder, listener listener, factory httpServerFactory, nodePortAddresses *proxyutil.NodePortAddresses, healthzServer proxyHealthChecker) ServiceHealthServer { +func newServiceHealthServer(nodeName string, recorder events.EventRecorder, listener listener, factory httpServerFactory, nodePortAddresses *proxyutil.NodePortAddresses, healthzServer proxyHealthChecker) ServiceHealthServer { // It doesn't matter whether we listen on "0.0.0.0", "::", or ""; go // treats them all the same. nodeIPs := []net.IP{net.IPv4zero} @@ -72,7 +72,7 @@ func newServiceHealthServer(hostname string, recorder events.EventRecorder, list } return &server{ - hostname: hostname, + nodeName: nodeName, recorder: recorder, listener: listener, httpFactory: factory, @@ -83,12 +83,12 @@ func newServiceHealthServer(hostname string, recorder events.EventRecorder, list } // NewServiceHealthServer allocates a new service healthcheck server manager -func NewServiceHealthServer(hostname string, recorder events.EventRecorder, nodePortAddresses *proxyutil.NodePortAddresses, healthzServer proxyHealthChecker) ServiceHealthServer { - return newServiceHealthServer(hostname, recorder, stdNetListener{}, stdHTTPServerFactory{}, nodePortAddresses, healthzServer) +func NewServiceHealthServer(nodeName string, recorder events.EventRecorder, nodePortAddresses *proxyutil.NodePortAddresses, healthzServer proxyHealthChecker) ServiceHealthServer { + return newServiceHealthServer(nodeName, recorder, stdNetListener{}, stdHTTPServerFactory{}, nodePortAddresses, healthzServer) } type server struct { - hostname string + nodeName string // node addresses where health check port will listen on nodeIPs []net.IP recorder events.EventRecorder // can be nil @@ -131,7 +131,7 @@ func (hcs *server) SyncServices(newServices map[types.NamespacedName]uint16) err err := svc.listenAndServeAll(hcs) if err != nil { - msg := fmt.Sprintf("node %s failed to start healthcheck %q on port %d: %v", hcs.hostname, nsn.String(), port, err) + msg := fmt.Sprintf("node %s failed to start healthcheck %q on port %d: %v", hcs.nodeName, nsn.String(), port, err) if hcs.recorder != nil { hcs.recorder.Eventf( @@ -142,7 +142,7 @@ func (hcs *server) SyncServices(newServices map[types.NamespacedName]uint16) err UID: types.UID(nsn.String()), }, nil, api.EventTypeWarning, "FailedToStartServiceHealthcheck", "Listen", msg) } - klog.ErrorS(err, "Failed to start healthcheck", "node", hcs.hostname, "service", nsn, "port", port) + klog.ErrorS(err, "Failed to start healthcheck", "node", hcs.nodeName, "service", nsn, "port", port) continue } hcs.services[nsn] = svc diff --git a/pkg/proxy/iptables/proxier.go b/pkg/proxy/iptables/proxier.go index 85a6adb2e5a..cc1394baef8 100644 --- a/pkg/proxy/iptables/proxier.go +++ b/pkg/proxy/iptables/proxier.go @@ -102,7 +102,7 @@ func NewDualStackProxier( localhostNodePorts bool, masqueradeBit int, localDetectors map[v1.IPFamily]proxyutil.LocalTrafficDetector, - hostname string, + nodeName string, nodeIPs map[v1.IPFamily]net.IP, recorder events.EventRecorder, healthzServer *healthcheck.ProxyHealthServer, @@ -112,7 +112,7 @@ func NewDualStackProxier( // Create an ipv4 instance of the single-stack proxier ipv4Proxier, err := NewProxier(ctx, v1.IPv4Protocol, ipts[v1.IPv4Protocol], sysctl, syncPeriod, minSyncPeriod, masqueradeAll, localhostNodePorts, masqueradeBit, - localDetectors[v1.IPv4Protocol], hostname, nodeIPs[v1.IPv4Protocol], + localDetectors[v1.IPv4Protocol], nodeName, nodeIPs[v1.IPv4Protocol], recorder, healthzServer, nodePortAddresses, initOnly) if err != nil { return nil, fmt.Errorf("unable to create ipv4 proxier: %v", err) @@ -120,7 +120,7 @@ func NewDualStackProxier( ipv6Proxier, err := NewProxier(ctx, v1.IPv6Protocol, ipts[v1.IPv6Protocol], sysctl, syncPeriod, minSyncPeriod, masqueradeAll, false, masqueradeBit, - localDetectors[v1.IPv6Protocol], hostname, nodeIPs[v1.IPv6Protocol], + localDetectors[v1.IPv6Protocol], nodeName, nodeIPs[v1.IPv6Protocol], recorder, healthzServer, nodePortAddresses, initOnly) if err != nil { return nil, fmt.Errorf("unable to create ipv6 proxier: %v", err) @@ -166,7 +166,7 @@ type Proxier struct { conntrack conntrack.Interface nfacct nfacct.Interface localDetector proxyutil.LocalTrafficDetector - hostname string + nodeName string nodeIP net.IP serviceHealthServer healthcheck.ServiceHealthServer @@ -224,7 +224,7 @@ func NewProxier(ctx context.Context, localhostNodePorts bool, masqueradeBit int, localDetector proxyutil.LocalTrafficDetector, - hostname string, + nodeName string, nodeIP net.IP, recorder events.EventRecorder, healthzServer *healthcheck.ProxyHealthServer, @@ -265,7 +265,7 @@ func NewProxier(ctx context.Context, masqueradeMark := fmt.Sprintf("%#08x", masqueradeValue) logger.V(2).Info("Using iptables mark for masquerade", "mark", masqueradeMark) - serviceHealthServer := healthcheck.NewServiceHealthServer(hostname, recorder, nodePortAddresses, healthzServer) + serviceHealthServer := healthcheck.NewServiceHealthServer(nodeName, recorder, nodePortAddresses, healthzServer) nfacctRunner, err := nfacct.New() if err != nil { logger.Error(err, "Failed to create nfacct runner, nfacct based metrics won't be available") @@ -276,7 +276,7 @@ func NewProxier(ctx context.Context, svcPortMap: make(proxy.ServicePortMap), serviceChanges: proxy.NewServiceChangeTracker(ipFamily, newServiceInfo, nil), endpointsMap: make(proxy.EndpointsMap), - endpointsChanges: proxy.NewEndpointsChangeTracker(ipFamily, hostname, newEndpointInfo, nil), + endpointsChanges: proxy.NewEndpointsChangeTracker(ipFamily, nodeName, newEndpointInfo, nil), needFullSync: true, syncPeriod: syncPeriod, iptables: ipt, @@ -285,7 +285,7 @@ func NewProxier(ctx context.Context, conntrack: conntrack.New(), nfacct: nfacctRunner, localDetector: localDetector, - hostname: hostname, + nodeName: nodeName, nodeIP: nodeIP, serviceHealthServer: serviceHealthServer, healthzServer: healthzServer, @@ -615,9 +615,9 @@ func (proxier *Proxier) OnEndpointSlicesSynced() { // OnNodeAdd is called whenever creation of new node object // is observed. func (proxier *Proxier) OnNodeAdd(node *v1.Node) { - if node.Name != proxier.hostname { + if node.Name != proxier.nodeName { proxier.logger.Error(nil, "Received a watch event for a node that doesn't match the current node", - "eventNode", node.Name, "currentNode", proxier.hostname) + "eventNode", node.Name, "currentNode", proxier.nodeName) return } @@ -640,9 +640,9 @@ func (proxier *Proxier) OnNodeAdd(node *v1.Node) { // OnNodeUpdate is called whenever modification of an existing // node object is observed. func (proxier *Proxier) OnNodeUpdate(oldNode, node *v1.Node) { - if node.Name != proxier.hostname { + if node.Name != proxier.nodeName { proxier.logger.Error(nil, "Received a watch event for a node that doesn't match the current node", - "eventNode", node.Name, "currentNode", proxier.hostname) + "eventNode", node.Name, "currentNode", proxier.nodeName) return } @@ -665,9 +665,9 @@ func (proxier *Proxier) OnNodeUpdate(oldNode, node *v1.Node) { // OnNodeDelete is called whenever deletion of an existing node // object is observed. func (proxier *Proxier) OnNodeDelete(node *v1.Node) { - if node.Name != proxier.hostname { + if node.Name != proxier.nodeName { proxier.logger.Error(nil, "Received a watch event for a node that doesn't match the current node", - "eventNode", node.Name, "currentNode", proxier.hostname) + "eventNode", node.Name, "currentNode", proxier.nodeName) return } diff --git a/pkg/proxy/iptables/proxier_test.go b/pkg/proxy/iptables/proxier_test.go index 29e4456457a..ef1747396fc 100644 --- a/pkg/proxy/iptables/proxier_test.go +++ b/pkg/proxy/iptables/proxier_test.go @@ -75,7 +75,7 @@ import ( // Non-cluster IPs: 203.0.113.0/24 // LB Source Range: 203.0.113.0/25 -const testHostname = "test-hostname" +const testNodeName = "test-node" const testNodeIP = "192.168.0.2" const testNodeIPAlt = "192.168.1.2" const testExternalIP = "192.168.99.11" @@ -119,13 +119,13 @@ func NewFakeProxier(ipt utiliptables.Interface) *Proxier { svcPortMap: make(proxy.ServicePortMap), serviceChanges: proxy.NewServiceChangeTracker(ipfamily, newServiceInfo, nil), endpointsMap: make(proxy.EndpointsMap), - endpointsChanges: proxy.NewEndpointsChangeTracker(ipfamily, testHostname, newEndpointInfo, nil), + endpointsChanges: proxy.NewEndpointsChangeTracker(ipfamily, testNodeName, newEndpointInfo, nil), needFullSync: true, iptables: ipt, masqueradeMark: "0x4000", conntrack: conntrack.NewFake(), localDetector: detectLocal, - hostname: testHostname, + nodeName: testNodeName, serviceHealthServer: healthcheck.NewFakeServiceHealthServer(), precomputedProbabilities: make([]string, 0, 1001), iptablesData: bytes.NewBuffer(nil), @@ -1686,7 +1686,7 @@ func TestOverallIPTablesRules(t *testing.T) { Addresses: []string{"10.180.0.4"}, }, { Addresses: []string{"10.180.0.5"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p80"), @@ -1952,7 +1952,7 @@ func TestClusterIPGeneral(t *testing.T) { eps.AddressType = discovery.AddressTypeIPv4 eps.Endpoints = []discovery.Endpoint{{ Addresses: []string{"10.180.0.1"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("http"), @@ -1965,11 +1965,11 @@ func TestClusterIPGeneral(t *testing.T) { eps.Endpoints = []discovery.Endpoint{ { Addresses: []string{"10.180.0.1"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.180.2.1"}, - NodeName: ptr.To("host2"), + NodeName: ptr.To("node2"), }, } eps.Ports = []discovery.EndpointPort{ @@ -2381,7 +2381,7 @@ func TestNodePorts(t *testing.T) { NodeName: nil, }, { Addresses: []string{epIP2}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p80"), @@ -2671,7 +2671,7 @@ func TestExternalTrafficPolicyLocal(t *testing.T) { Addresses: []string{epIP1}, }, { Addresses: []string{epIP2}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To(svcPortName.Port), @@ -2788,7 +2788,7 @@ func TestExternalTrafficPolicyCluster(t *testing.T) { NodeName: nil, }, { Addresses: []string{epIP2}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To(svcPortName.Port), @@ -3227,7 +3227,7 @@ func TestUpdateEndpointsMap(t *testing.T) { eps.AddressType = discovery.AddressTypeIPv4 eps.Endpoints = []discovery.Endpoint{{ Addresses: []string{"10.1.1.1"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p11"), @@ -3275,7 +3275,7 @@ func TestUpdateEndpointsMap(t *testing.T) { Addresses: []string{"10.1.1.1"}, }, { Addresses: []string{"10.1.1.2"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p11"), @@ -3296,7 +3296,7 @@ func TestUpdateEndpointsMap(t *testing.T) { eps.AddressType = discovery.AddressTypeIPv4 eps.Endpoints = []discovery.Endpoint{{ Addresses: []string{"10.1.1.2"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p12"), @@ -3312,7 +3312,7 @@ func TestUpdateEndpointsMap(t *testing.T) { eps.AddressType = discovery.AddressTypeIPv4 eps.Endpoints = []discovery.Endpoint{{ Addresses: []string{"10.1.1.1"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p11"), @@ -3345,7 +3345,7 @@ func TestUpdateEndpointsMap(t *testing.T) { Addresses: []string{"10.1.1.1"}, }, { Addresses: []string{"10.1.1.2"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p11"), @@ -3363,7 +3363,7 @@ func TestUpdateEndpointsMap(t *testing.T) { Addresses: []string{"10.1.1.3"}, }, { Addresses: []string{"10.1.1.4"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p13"), @@ -3381,7 +3381,7 @@ func TestUpdateEndpointsMap(t *testing.T) { Addresses: []string{"10.2.2.1"}, }, { Addresses: []string{"10.2.2.2"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p21"), @@ -3402,10 +3402,10 @@ func TestUpdateEndpointsMap(t *testing.T) { eps.AddressType = discovery.AddressTypeIPv4 eps.Endpoints = []discovery.Endpoint{{ Addresses: []string{"10.2.2.2"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.2.2.22"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p22"), @@ -3417,7 +3417,7 @@ func TestUpdateEndpointsMap(t *testing.T) { eps.AddressType = discovery.AddressTypeIPv4 eps.Endpoints = []discovery.Endpoint{{ Addresses: []string{"10.2.2.3"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p23"), @@ -3429,10 +3429,10 @@ func TestUpdateEndpointsMap(t *testing.T) { eps.AddressType = discovery.AddressTypeIPv4 eps.Endpoints = []discovery.Endpoint{{ Addresses: []string{"10.4.4.4"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.4.4.5"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p44"), @@ -3444,7 +3444,7 @@ func TestUpdateEndpointsMap(t *testing.T) { eps.AddressType = discovery.AddressTypeIPv4 eps.Endpoints = []discovery.Endpoint{{ Addresses: []string{"10.4.4.6"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p45"), @@ -3495,7 +3495,7 @@ func TestUpdateEndpointsMap(t *testing.T) { eps.AddressType = discovery.AddressTypeIPv4 eps.Endpoints = []discovery.Endpoint{{ Addresses: []string{"10.4.4.4"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p44"), @@ -3891,7 +3891,6 @@ func TestUpdateEndpointsMap(t *testing.T) { t.Run(tc.name, func(t *testing.T) { ipt := iptablestest.NewFake() fp := NewFakeProxier(ipt) - fp.hostname = testHostname // First check that after adding all previous versions of endpoints, // the fp.oldEndpoints is as we expect. @@ -3967,19 +3966,19 @@ func TestHealthCheckNodePortWhenTerminating(t *testing.T) { Endpoints: []discovery.Endpoint{{ Addresses: []string{"10.0.1.1"}, Conditions: discovery.EndpointConditions{Ready: ptr.To(true)}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.0.1.2"}, Conditions: discovery.EndpointConditions{Ready: ptr.To(true)}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.0.1.3"}, Conditions: discovery.EndpointConditions{Ready: ptr.To(true)}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { // not ready endpoints should be ignored Addresses: []string{"10.0.1.4"}, Conditions: discovery.EndpointConditions{Ready: ptr.To(false)}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }}, } @@ -4010,7 +4009,7 @@ func TestHealthCheckNodePortWhenTerminating(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(false), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.0.1.2"}, Conditions: discovery.EndpointConditions{ @@ -4018,7 +4017,7 @@ func TestHealthCheckNodePortWhenTerminating(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.0.1.3"}, Conditions: discovery.EndpointConditions{ @@ -4026,7 +4025,7 @@ func TestHealthCheckNodePortWhenTerminating(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { // not ready endpoints should be ignored Addresses: []string{"10.0.1.4"}, Conditions: discovery.EndpointConditions{ @@ -4034,7 +4033,7 @@ func TestHealthCheckNodePortWhenTerminating(t *testing.T) { Serving: ptr.To(false), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }}, } @@ -4131,7 +4130,7 @@ func TestProxierMetricsIPTablesTotalRules(t *testing.T) { func TestInternalTrafficPolicy(t *testing.T) { type endpoint struct { ip string - hostname string + nodeName string } testCases := []struct { @@ -4146,9 +4145,9 @@ func TestInternalTrafficPolicy(t *testing.T) { line: getLine(), internalTrafficPolicy: ptr.To(v1.ServiceInternalTrafficPolicyCluster), endpoints: []endpoint{ - {"10.0.1.1", testHostname}, - {"10.0.1.2", "host1"}, - {"10.0.1.3", "host2"}, + {"10.0.1.1", testNodeName}, + {"10.0.1.2", "node1"}, + {"10.0.1.3", "node2"}, }, flowTests: []packetFlowTest{ { @@ -4166,9 +4165,9 @@ func TestInternalTrafficPolicy(t *testing.T) { line: getLine(), internalTrafficPolicy: ptr.To(v1.ServiceInternalTrafficPolicyLocal), endpoints: []endpoint{ - {"10.0.1.1", testHostname}, - {"10.0.1.2", "host1"}, - {"10.0.1.3", "host2"}, + {"10.0.1.1", testNodeName}, + {"10.0.1.2", "node1"}, + {"10.0.1.3", "node2"}, }, flowTests: []packetFlowTest{ { @@ -4186,9 +4185,9 @@ func TestInternalTrafficPolicy(t *testing.T) { line: getLine(), internalTrafficPolicy: ptr.To(v1.ServiceInternalTrafficPolicyLocal), endpoints: []endpoint{ - {"10.0.1.1", testHostname}, - {"10.0.1.2", testHostname}, - {"10.0.1.3", "host2"}, + {"10.0.1.1", testNodeName}, + {"10.0.1.2", testNodeName}, + {"10.0.1.3", "node2"}, }, flowTests: []packetFlowTest{ { @@ -4206,9 +4205,9 @@ func TestInternalTrafficPolicy(t *testing.T) { line: getLine(), internalTrafficPolicy: ptr.To(v1.ServiceInternalTrafficPolicyLocal), endpoints: []endpoint{ - {"10.0.1.1", "host0"}, - {"10.0.1.2", "host1"}, - {"10.0.1.3", "host2"}, + {"10.0.1.1", "node0"}, + {"10.0.1.2", "node1"}, + {"10.0.1.3", "node2"}, }, flowTests: []packetFlowTest{ { @@ -4263,7 +4262,7 @@ func TestInternalTrafficPolicy(t *testing.T) { endpointSlice.Endpoints = append(endpointSlice.Endpoints, discovery.Endpoint{ Addresses: []string{ep.ip}, Conditions: discovery.EndpointConditions{Ready: ptr.To(true)}, - NodeName: ptr.To(ep.hostname), + NodeName: ptr.To(ep.nodeName), }) } @@ -4343,7 +4342,7 @@ func TestTerminatingEndpointsTrafficPolicyLocal(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(false), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.0.1.2"}, @@ -4352,7 +4351,7 @@ func TestTerminatingEndpointsTrafficPolicyLocal(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(false), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { // this endpoint should be ignored for external since there are ready non-terminating endpoints @@ -4362,7 +4361,7 @@ func TestTerminatingEndpointsTrafficPolicyLocal(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { // this endpoint should be ignored for external since there are ready non-terminating endpoints @@ -4372,7 +4371,7 @@ func TestTerminatingEndpointsTrafficPolicyLocal(t *testing.T) { Serving: ptr.To(false), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { // this endpoint should be ignored for external since it's not local @@ -4382,7 +4381,7 @@ func TestTerminatingEndpointsTrafficPolicyLocal(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(false), }, - NodeName: ptr.To("host-1"), + NodeName: ptr.To("node-1"), }, }, }, @@ -4429,7 +4428,7 @@ func TestTerminatingEndpointsTrafficPolicyLocal(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { // this endpoint should be used since there are only ready terminating endpoints @@ -4439,7 +4438,7 @@ func TestTerminatingEndpointsTrafficPolicyLocal(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { // this endpoint should not be used since it is both terminating and not ready. @@ -4449,7 +4448,7 @@ func TestTerminatingEndpointsTrafficPolicyLocal(t *testing.T) { Serving: ptr.To(false), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { // this endpoint should be ignored for external since it's not local @@ -4459,7 +4458,7 @@ func TestTerminatingEndpointsTrafficPolicyLocal(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(false), }, - NodeName: ptr.To("host-1"), + NodeName: ptr.To("node-1"), }, }, }, @@ -4507,7 +4506,7 @@ func TestTerminatingEndpointsTrafficPolicyLocal(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(true), }, - NodeName: ptr.To("host-1"), + NodeName: ptr.To("node-1"), }, }, }, @@ -4552,7 +4551,7 @@ func TestTerminatingEndpointsTrafficPolicyLocal(t *testing.T) { Serving: ptr.To(false), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { // Remote and not ready or serving @@ -4562,7 +4561,7 @@ func TestTerminatingEndpointsTrafficPolicyLocal(t *testing.T) { Serving: ptr.To(false), Terminating: ptr.To(true), }, - NodeName: ptr.To("host-1"), + NodeName: ptr.To("node-1"), }, }, }, @@ -4677,7 +4676,7 @@ func TestTerminatingEndpointsTrafficPolicyCluster(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(false), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.0.1.2"}, @@ -4686,7 +4685,7 @@ func TestTerminatingEndpointsTrafficPolicyCluster(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(false), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { // this endpoint should be ignored since there are ready non-terminating endpoints @@ -4696,7 +4695,7 @@ func TestTerminatingEndpointsTrafficPolicyCluster(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(true), }, - NodeName: ptr.To("another-host"), + NodeName: ptr.To("another-node"), }, { // this endpoint should be ignored since it is not "serving" @@ -4706,7 +4705,7 @@ func TestTerminatingEndpointsTrafficPolicyCluster(t *testing.T) { Serving: ptr.To(false), Terminating: ptr.To(true), }, - NodeName: ptr.To("another-host"), + NodeName: ptr.To("another-node"), }, { Addresses: []string{"10.0.1.5"}, @@ -4715,7 +4714,7 @@ func TestTerminatingEndpointsTrafficPolicyCluster(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(false), }, - NodeName: ptr.To("another-host"), + NodeName: ptr.To("another-node"), }, }, }, @@ -4762,7 +4761,7 @@ func TestTerminatingEndpointsTrafficPolicyCluster(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { // this endpoint should be used since there are only ready terminating endpoints @@ -4772,7 +4771,7 @@ func TestTerminatingEndpointsTrafficPolicyCluster(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { // this endpoint should not be used since it is both terminating and not ready. @@ -4782,7 +4781,7 @@ func TestTerminatingEndpointsTrafficPolicyCluster(t *testing.T) { Serving: ptr.To(false), Terminating: ptr.To(true), }, - NodeName: ptr.To("another-host"), + NodeName: ptr.To("another-node"), }, { // this endpoint should be used since there are only ready terminating endpoints @@ -4792,7 +4791,7 @@ func TestTerminatingEndpointsTrafficPolicyCluster(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(true), }, - NodeName: ptr.To("another-host"), + NodeName: ptr.To("another-node"), }, }, }, @@ -4838,7 +4837,7 @@ func TestTerminatingEndpointsTrafficPolicyCluster(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(true), }, - NodeName: ptr.To("host-1"), + NodeName: ptr.To("node-1"), }, }, }, @@ -4885,7 +4884,7 @@ func TestTerminatingEndpointsTrafficPolicyCluster(t *testing.T) { Serving: ptr.To(false), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { // Remote, not ready or serving @@ -4895,7 +4894,7 @@ func TestTerminatingEndpointsTrafficPolicyCluster(t *testing.T) { Serving: ptr.To(false), Terminating: ptr.To(true), }, - NodeName: ptr.To("host-1"), + NodeName: ptr.To("node-1"), }, }, }, @@ -5011,7 +5010,7 @@ func TestInternalExternalMasquerade(t *testing.T) { eps.Endpoints = []discovery.Endpoint{ { Addresses: []string{"10.180.0.1"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.180.1.1"}, @@ -5029,7 +5028,7 @@ func TestInternalExternalMasquerade(t *testing.T) { eps.Endpoints = []discovery.Endpoint{ { Addresses: []string{"10.180.0.2"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.180.1.2"}, @@ -5047,7 +5046,7 @@ func TestInternalExternalMasquerade(t *testing.T) { eps.Endpoints = []discovery.Endpoint{ { Addresses: []string{"10.180.0.3"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.180.1.3"}, @@ -6372,7 +6371,7 @@ func TestSyncProxyRulesRepeated(t *testing.T) { func TestNoEndpointsMetric(t *testing.T) { type endpoint struct { ip string - hostname string + nodeName string } metrics.RegisterMetrics(kubeproxyconfig.ProxyModeIPTables) @@ -6388,18 +6387,18 @@ func TestNoEndpointsMetric(t *testing.T) { name: "internalTrafficPolicy is set and there are local endpoints", internalTrafficPolicy: ptr.To(v1.ServiceInternalTrafficPolicyLocal), endpoints: []endpoint{ - {"10.0.1.1", testHostname}, - {"10.0.1.2", "host1"}, - {"10.0.1.3", "host2"}, + {"10.0.1.1", testNodeName}, + {"10.0.1.2", "node1"}, + {"10.0.1.3", "node2"}, }, }, { name: "externalTrafficPolicy is set and there are local endpoints", externalTrafficPolicy: v1.ServiceExternalTrafficPolicyLocal, endpoints: []endpoint{ - {"10.0.1.1", testHostname}, - {"10.0.1.2", "host1"}, - {"10.0.1.3", "host2"}, + {"10.0.1.1", testNodeName}, + {"10.0.1.2", "node1"}, + {"10.0.1.3", "node2"}, }, }, { @@ -6407,18 +6406,18 @@ func TestNoEndpointsMetric(t *testing.T) { internalTrafficPolicy: ptr.To(v1.ServiceInternalTrafficPolicyLocal), externalTrafficPolicy: v1.ServiceExternalTrafficPolicyLocal, endpoints: []endpoint{ - {"10.0.1.1", testHostname}, - {"10.0.1.2", "host1"}, - {"10.0.1.3", "host2"}, + {"10.0.1.1", testNodeName}, + {"10.0.1.2", "node1"}, + {"10.0.1.3", "node2"}, }, }, { name: "internalTrafficPolicy is set and there are no local endpoints", internalTrafficPolicy: ptr.To(v1.ServiceInternalTrafficPolicyLocal), endpoints: []endpoint{ - {"10.0.1.1", "host0"}, - {"10.0.1.2", "host1"}, - {"10.0.1.3", "host2"}, + {"10.0.1.1", "node0"}, + {"10.0.1.2", "node1"}, + {"10.0.1.3", "node2"}, }, expectedSyncProxyRulesNoLocalEndpointsTotalInternal: 1, }, @@ -6426,9 +6425,9 @@ func TestNoEndpointsMetric(t *testing.T) { name: "externalTrafficPolicy is set and there are no local endpoints", externalTrafficPolicy: v1.ServiceExternalTrafficPolicyLocal, endpoints: []endpoint{ - {"10.0.1.1", "host0"}, - {"10.0.1.2", "host1"}, - {"10.0.1.3", "host2"}, + {"10.0.1.1", "node0"}, + {"10.0.1.2", "node1"}, + {"10.0.1.3", "node2"}, }, expectedSyncProxyRulesNoLocalEndpointsTotalExternal: 1, }, @@ -6437,9 +6436,9 @@ func TestNoEndpointsMetric(t *testing.T) { internalTrafficPolicy: ptr.To(v1.ServiceInternalTrafficPolicyLocal), externalTrafficPolicy: v1.ServiceExternalTrafficPolicyLocal, endpoints: []endpoint{ - {"10.0.1.1", "host0"}, - {"10.0.1.2", "host1"}, - {"10.0.1.3", "host2"}, + {"10.0.1.1", "node0"}, + {"10.0.1.2", "node1"}, + {"10.0.1.3", "node2"}, }, expectedSyncProxyRulesNoLocalEndpointsTotalInternal: 1, expectedSyncProxyRulesNoLocalEndpointsTotalExternal: 1, @@ -6499,7 +6498,7 @@ func TestNoEndpointsMetric(t *testing.T) { endpointSlice.Endpoints = append(endpointSlice.Endpoints, discovery.Endpoint{ Addresses: []string{ep.ip}, Conditions: discovery.EndpointConditions{Ready: ptr.To(true)}, - NodeName: ptr.To(ep.hostname), + NodeName: ptr.To(ep.nodeName), }) } diff --git a/pkg/proxy/ipvs/proxier.go b/pkg/proxy/ipvs/proxier.go index 9d70be2ee7e..85bd8950eaf 100644 --- a/pkg/proxy/ipvs/proxier.go +++ b/pkg/proxy/ipvs/proxier.go @@ -124,7 +124,7 @@ func NewDualStackProxier( masqueradeAll bool, masqueradeBit int, localDetectors map[v1.IPFamily]proxyutil.LocalTrafficDetector, - hostname string, + nodeName string, nodeIPs map[v1.IPFamily]net.IP, recorder events.EventRecorder, healthzServer *healthcheck.ProxyHealthServer, @@ -136,7 +136,7 @@ func NewDualStackProxier( ipv4Proxier, err := NewProxier(ctx, v1.IPv4Protocol, ipts[v1.IPv4Protocol], ipvs, ipset, sysctl, syncPeriod, minSyncPeriod, filterCIDRs(false, excludeCIDRs), strictARP, tcpTimeout, tcpFinTimeout, udpTimeout, masqueradeAll, masqueradeBit, - localDetectors[v1.IPv4Protocol], hostname, nodeIPs[v1.IPv4Protocol], recorder, + localDetectors[v1.IPv4Protocol], nodeName, nodeIPs[v1.IPv4Protocol], recorder, healthzServer, scheduler, nodePortAddresses, initOnly) if err != nil { return nil, fmt.Errorf("unable to create ipv4 proxier: %v", err) @@ -145,7 +145,7 @@ func NewDualStackProxier( ipv6Proxier, err := NewProxier(ctx, v1.IPv6Protocol, ipts[v1.IPv6Protocol], ipvs, ipset, sysctl, syncPeriod, minSyncPeriod, filterCIDRs(true, excludeCIDRs), strictARP, tcpTimeout, tcpFinTimeout, udpTimeout, masqueradeAll, masqueradeBit, - localDetectors[v1.IPv6Protocol], hostname, nodeIPs[v1.IPv6Protocol], recorder, + localDetectors[v1.IPv6Protocol], nodeName, nodeIPs[v1.IPv6Protocol], recorder, healthzServer, scheduler, nodePortAddresses, initOnly) if err != nil { return nil, fmt.Errorf("unable to create ipv6 proxier: %v", err) @@ -202,7 +202,7 @@ type Proxier struct { masqueradeAll bool masqueradeMark string localDetector proxyutil.LocalTrafficDetector - hostname string + nodeName string nodeIP net.IP serviceHealthServer healthcheck.ServiceHealthServer @@ -271,7 +271,7 @@ func NewProxier( masqueradeAll bool, masqueradeBit int, localDetector proxyutil.LocalTrafficDetector, - hostname string, + nodeName string, nodeIP net.IP, recorder events.EventRecorder, healthzServer *healthcheck.ProxyHealthServer, @@ -356,7 +356,7 @@ func NewProxier( nodePortAddresses := proxyutil.NewNodePortAddresses(ipFamily, nodePortAddressStrings) - serviceHealthServer := healthcheck.NewServiceHealthServer(hostname, recorder, nodePortAddresses, healthzServer) + serviceHealthServer := healthcheck.NewServiceHealthServer(nodeName, recorder, nodePortAddresses, healthzServer) // excludeCIDRs has been validated before, here we just parse it to IPNet list parsedExcludeCIDRs, _ := netutils.ParseCIDRs(excludeCIDRs) @@ -366,7 +366,7 @@ func NewProxier( svcPortMap: make(proxy.ServicePortMap), serviceChanges: proxy.NewServiceChangeTracker(ipFamily, newServiceInfo, nil), endpointsMap: make(proxy.EndpointsMap), - endpointsChanges: proxy.NewEndpointsChangeTracker(ipFamily, hostname, nil, nil), + endpointsChanges: proxy.NewEndpointsChangeTracker(ipFamily, nodeName, nil, nil), initialSync: true, syncPeriod: syncPeriod, minSyncPeriod: minSyncPeriod, @@ -376,7 +376,7 @@ func NewProxier( masqueradeMark: masqueradeMark, conntrack: conntrack.New(), localDetector: localDetector, - hostname: hostname, + nodeName: nodeName, nodeIP: nodeIP, serviceHealthServer: serviceHealthServer, healthzServer: healthzServer, @@ -826,8 +826,8 @@ func (proxier *Proxier) OnEndpointSlicesSynced() { // OnNodeAdd is called whenever creation of new node object // is observed. func (proxier *Proxier) OnNodeAdd(node *v1.Node) { - if node.Name != proxier.hostname { - proxier.logger.Error(nil, "Received a watch event for a node that doesn't match the current node", "eventNode", node.Name, "currentNode", proxier.hostname) + if node.Name != proxier.nodeName { + proxier.logger.Error(nil, "Received a watch event for a node that doesn't match the current node", "eventNode", node.Name, "currentNode", proxier.nodeName) return } @@ -849,8 +849,8 @@ func (proxier *Proxier) OnNodeAdd(node *v1.Node) { // OnNodeUpdate is called whenever modification of an existing // node object is observed. func (proxier *Proxier) OnNodeUpdate(oldNode, node *v1.Node) { - if node.Name != proxier.hostname { - proxier.logger.Error(nil, "Received a watch event for a node that doesn't match the current node", "eventNode", node.Name, "currentNode", proxier.hostname) + if node.Name != proxier.nodeName { + proxier.logger.Error(nil, "Received a watch event for a node that doesn't match the current node", "eventNode", node.Name, "currentNode", proxier.nodeName) return } @@ -872,8 +872,8 @@ func (proxier *Proxier) OnNodeUpdate(oldNode, node *v1.Node) { // OnNodeDelete is called whenever deletion of an existing node // object is observed. func (proxier *Proxier) OnNodeDelete(node *v1.Node) { - if node.Name != proxier.hostname { - proxier.logger.Error(nil, "Received a watch event for a node that doesn't match the current node", "eventNode", node.Name, "currentNode", proxier.hostname) + if node.Name != proxier.nodeName { + proxier.logger.Error(nil, "Received a watch event for a node that doesn't match the current node", "eventNode", node.Name, "currentNode", proxier.nodeName) return } diff --git a/pkg/proxy/ipvs/proxier_test.go b/pkg/proxy/ipvs/proxier_test.go index c835ade5c46..09e95316d9b 100644 --- a/pkg/proxy/ipvs/proxier_test.go +++ b/pkg/proxy/ipvs/proxier_test.go @@ -63,7 +63,7 @@ import ( "k8s.io/utils/ptr" ) -const testHostname = "test-hostname" +const testNodeName = "test-node" // fakeIpvs implements utilipvs.Interface type fakeIpvs struct { @@ -143,14 +143,14 @@ func NewFakeProxier(ctx context.Context, ipt utiliptables.Interface, ipvs utilip svcPortMap: make(proxy.ServicePortMap), serviceChanges: proxy.NewServiceChangeTracker(ipFamily, newServiceInfo, nil), endpointsMap: make(proxy.EndpointsMap), - endpointsChanges: proxy.NewEndpointsChangeTracker(ipFamily, testHostname, nil, nil), + endpointsChanges: proxy.NewEndpointsChangeTracker(ipFamily, testNodeName, nil, nil), excludeCIDRs: excludeCIDRs, iptables: ipt, ipvs: ipvs, ipset: ipset, conntrack: conntrack.NewFake(), localDetector: proxyutil.NewNoOpLocalDetector(), - hostname: testHostname, + nodeName: testNodeName, serviceHealthServer: healthcheck.NewFakeServiceHealthServer(), ipvsScheduler: defaultScheduler, iptablesData: bytes.NewBuffer(nil), @@ -847,10 +847,10 @@ func TestNodePortIPv4(t *testing.T) { eps.AddressType = discovery.AddressTypeIPv4 eps.Endpoints = []discovery.Endpoint{{ Addresses: []string{"10.180.0.1"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.180.1.1"}, - NodeName: ptr.To("otherHost"), + NodeName: ptr.To("other-node"), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p80"), @@ -1864,18 +1864,18 @@ func TestOnlyLocalExternalIPs(t *testing.T) { ) epIP := "10.180.0.1" epIP1 := "10.180.1.1" - thisHostname := testHostname - otherHostname := "other-hostname" + thisNodeName := testNodeName + otherNodeName := "other-node" populateEndpointSlices(fp, makeTestEndpointSlice(svcPortName.Namespace, svcPortName.Name, 1, func(eps *discovery.EndpointSlice) { eps.AddressType = discovery.AddressTypeIPv4 eps.Endpoints = []discovery.Endpoint{{ Addresses: []string{epIP}, - NodeName: ptr.To(thisHostname), + NodeName: ptr.To(thisNodeName), }, { Addresses: []string{epIP1}, - NodeName: ptr.To(otherHostname), + NodeName: ptr.To(otherNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To(svcPortName.Port), @@ -2035,10 +2035,10 @@ func TestOnlyLocalNodePorts(t *testing.T) { eps.AddressType = discovery.AddressTypeIPv4 eps.Endpoints = []discovery.Endpoint{{ Addresses: []string{epIP}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{epIP1}, - NodeName: ptr.To("other-hostname"), + NodeName: ptr.To("other-node"), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To(svcPortName.Port), @@ -2386,11 +2386,11 @@ func TestOnlyLocalLoadBalancing(t *testing.T) { eps.Endpoints = []discovery.Endpoint{ { // **local** endpoint address, should be added as RS Addresses: []string{epIP}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { // **remote** endpoint address, should not be added as RS Addresses: []string{epIP1}, - NodeName: ptr.To("other-hostname"), + NodeName: ptr.To("other-node"), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To(svcPortName.Port), @@ -2787,7 +2787,7 @@ func Test_updateEndpointsMap(t *testing.T) { eps.AddressType = discovery.AddressTypeIPv4 eps.Endpoints = []discovery.Endpoint{{ Addresses: []string{"1.1.1.1"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p11"), @@ -2835,7 +2835,7 @@ func Test_updateEndpointsMap(t *testing.T) { Addresses: []string{"1.1.1.1"}, }, { Addresses: []string{"1.1.1.2"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p11"), @@ -2856,7 +2856,7 @@ func Test_updateEndpointsMap(t *testing.T) { eps.AddressType = discovery.AddressTypeIPv4 eps.Endpoints = []discovery.Endpoint{{ Addresses: []string{"1.1.1.2"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p12"), @@ -2872,7 +2872,7 @@ func Test_updateEndpointsMap(t *testing.T) { eps.AddressType = discovery.AddressTypeIPv4 eps.Endpoints = []discovery.Endpoint{{ Addresses: []string{"1.1.1.1"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p11"), @@ -2905,7 +2905,7 @@ func Test_updateEndpointsMap(t *testing.T) { Addresses: []string{"1.1.1.1"}, }, { Addresses: []string{"1.1.1.2"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p11"), @@ -2923,7 +2923,7 @@ func Test_updateEndpointsMap(t *testing.T) { Addresses: []string{"1.1.1.3"}, }, { Addresses: []string{"1.1.1.4"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p13"), @@ -2941,7 +2941,7 @@ func Test_updateEndpointsMap(t *testing.T) { Addresses: []string{"2.2.2.1"}, }, { Addresses: []string{"2.2.2.2"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p21"), @@ -2962,10 +2962,10 @@ func Test_updateEndpointsMap(t *testing.T) { eps.AddressType = discovery.AddressTypeIPv4 eps.Endpoints = []discovery.Endpoint{{ Addresses: []string{"2.2.2.2"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"2.2.2.22"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p22"), @@ -2977,7 +2977,7 @@ func Test_updateEndpointsMap(t *testing.T) { eps.AddressType = discovery.AddressTypeIPv4 eps.Endpoints = []discovery.Endpoint{{ Addresses: []string{"2.2.2.3"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p23"), @@ -2989,10 +2989,10 @@ func Test_updateEndpointsMap(t *testing.T) { eps.AddressType = discovery.AddressTypeIPv4 eps.Endpoints = []discovery.Endpoint{{ Addresses: []string{"4.4.4.4"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"4.4.4.5"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p44"), @@ -3004,7 +3004,7 @@ func Test_updateEndpointsMap(t *testing.T) { eps.AddressType = discovery.AddressTypeIPv4 eps.Endpoints = []discovery.Endpoint{{ Addresses: []string{"4.4.4.6"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p45"), @@ -3055,7 +3055,7 @@ func Test_updateEndpointsMap(t *testing.T) { eps.AddressType = discovery.AddressTypeIPv4 eps.Endpoints = []discovery.Endpoint{{ Addresses: []string{"4.4.4.4"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p44"), @@ -3454,7 +3454,6 @@ func Test_updateEndpointsMap(t *testing.T) { ipvs := ipvstest.NewFake() ipset := ipsettest.NewFake(testIPSetVersion) fp := NewFakeProxier(ctx, ipt, ipvs, ipset, nil, nil, v1.IPv4Protocol) - fp.hostname = testHostname // First check that after adding all previous versions of endpoints, // the fp.oldEndpoints is as we expect. @@ -4252,7 +4251,7 @@ func TestEndpointSliceE2E(t *testing.T) { Endpoints: []discovery.Endpoint{{ Addresses: []string{"10.0.1.1"}, Conditions: discovery.EndpointConditions{Ready: ptr.To(true)}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.0.1.2"}, Conditions: discovery.EndpointConditions{Ready: ptr.To(true)}, @@ -4393,18 +4392,18 @@ func Test_HealthCheckNodePortWhenTerminating(t *testing.T) { Endpoints: []discovery.Endpoint{{ Addresses: []string{"10.0.1.1"}, Conditions: discovery.EndpointConditions{Ready: ptr.To(true)}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.0.1.2"}, Conditions: discovery.EndpointConditions{Ready: ptr.To(true)}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.0.1.3"}, Conditions: discovery.EndpointConditions{Ready: ptr.To(true)}, }, { // not ready endpoints should be ignored Addresses: []string{"10.0.1.4"}, Conditions: discovery.EndpointConditions{Ready: ptr.To(false)}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }}, } @@ -4435,7 +4434,7 @@ func Test_HealthCheckNodePortWhenTerminating(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(false), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.0.1.2"}, Conditions: discovery.EndpointConditions{ @@ -4443,7 +4442,7 @@ func Test_HealthCheckNodePortWhenTerminating(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.0.1.3"}, Conditions: discovery.EndpointConditions{ @@ -4451,7 +4450,7 @@ func Test_HealthCheckNodePortWhenTerminating(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { // not ready endpoints should be ignored Addresses: []string{"10.0.1.4"}, Conditions: discovery.EndpointConditions{ @@ -4459,7 +4458,7 @@ func Test_HealthCheckNodePortWhenTerminating(t *testing.T) { Serving: ptr.To(false), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }}, } @@ -4530,7 +4529,7 @@ func TestCreateAndLinkKubeChain(t *testing.T) { func TestTestInternalTrafficPolicyE2E(t *testing.T) { type endpoint struct { ip string - hostname string + nodeName string } testCases := []struct { @@ -4546,9 +4545,9 @@ func TestTestInternalTrafficPolicyE2E(t *testing.T) { name: "internalTrafficPolicy is cluster with non-zero local endpoints", internalTrafficPolicy: ptr.To(v1.ServiceInternalTrafficPolicyCluster), endpoints: []endpoint{ - {"10.0.1.1", testHostname}, - {"10.0.1.2", "host1"}, - {"10.0.1.3", "host2"}, + {"10.0.1.1", testNodeName}, + {"10.0.1.2", "node1"}, + {"10.0.1.3", "node2"}, }, expectVirtualServer: true, expectLocalEntries: true, @@ -4563,9 +4562,9 @@ func TestTestInternalTrafficPolicyE2E(t *testing.T) { name: "internalTrafficPolicy is cluster with zero local endpoints", internalTrafficPolicy: ptr.To(v1.ServiceInternalTrafficPolicyCluster), endpoints: []endpoint{ - {"10.0.1.1", "host0"}, - {"10.0.1.2", "host1"}, - {"10.0.1.3", "host2"}, + {"10.0.1.1", "node0"}, + {"10.0.1.2", "node1"}, + {"10.0.1.3", "node2"}, }, expectVirtualServer: false, expectLocalEntries: false, @@ -4580,9 +4579,9 @@ func TestTestInternalTrafficPolicyE2E(t *testing.T) { name: "internalTrafficPolicy is local with non-zero local endpoints", internalTrafficPolicy: ptr.To(v1.ServiceInternalTrafficPolicyLocal), endpoints: []endpoint{ - {"10.0.1.1", testHostname}, - {"10.0.1.2", "host1"}, - {"10.0.1.3", "host2"}, + {"10.0.1.1", testNodeName}, + {"10.0.1.2", "node1"}, + {"10.0.1.3", "node2"}, }, expectVirtualServer: true, expectLocalEntries: true, @@ -4595,9 +4594,9 @@ func TestTestInternalTrafficPolicyE2E(t *testing.T) { name: "internalTrafficPolicy is local with zero local endpoints", internalTrafficPolicy: ptr.To(v1.ServiceInternalTrafficPolicyLocal), endpoints: []endpoint{ - {"10.0.1.1", "host0"}, - {"10.0.1.2", "host1"}, - {"10.0.1.3", "host2"}, + {"10.0.1.1", "node0"}, + {"10.0.1.2", "node1"}, + {"10.0.1.3", "node2"}, }, expectVirtualServer: false, expectLocalEntries: false, @@ -4652,7 +4651,7 @@ func TestTestInternalTrafficPolicyE2E(t *testing.T) { endpointSlice.Endpoints = append(endpointSlice.Endpoints, discovery.Endpoint{ Addresses: []string{ep.ip}, Conditions: discovery.EndpointConditions{Ready: ptr.To(true)}, - NodeName: ptr.To(ep.hostname), + NodeName: ptr.To(ep.nodeName), }) } @@ -4758,7 +4757,7 @@ func Test_EndpointSliceReadyAndTerminatingCluster(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(false), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.0.1.2"}, @@ -4767,7 +4766,7 @@ func Test_EndpointSliceReadyAndTerminatingCluster(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(false), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.0.1.3"}, @@ -4776,7 +4775,7 @@ func Test_EndpointSliceReadyAndTerminatingCluster(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.0.1.4"}, @@ -4785,7 +4784,7 @@ func Test_EndpointSliceReadyAndTerminatingCluster(t *testing.T) { Serving: ptr.To(false), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.0.1.5"}, @@ -4794,7 +4793,7 @@ func Test_EndpointSliceReadyAndTerminatingCluster(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(false), }, - NodeName: ptr.To("another-host"), + NodeName: ptr.To("another-node"), }, }, } @@ -4931,7 +4930,7 @@ func Test_EndpointSliceReadyAndTerminatingLocal(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(false), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.0.1.2"}, @@ -4940,7 +4939,7 @@ func Test_EndpointSliceReadyAndTerminatingLocal(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(false), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.0.1.3"}, @@ -4949,7 +4948,7 @@ func Test_EndpointSliceReadyAndTerminatingLocal(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.0.1.4"}, @@ -4958,7 +4957,7 @@ func Test_EndpointSliceReadyAndTerminatingLocal(t *testing.T) { Serving: ptr.To(false), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.0.1.5"}, @@ -4967,7 +4966,7 @@ func Test_EndpointSliceReadyAndTerminatingLocal(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(false), }, - NodeName: ptr.To("another-host"), + NodeName: ptr.To("another-node"), }, }, } @@ -5103,7 +5102,7 @@ func Test_EndpointSliceOnlyReadyAndTerminatingCluster(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.0.1.2"}, @@ -5112,7 +5111,7 @@ func Test_EndpointSliceOnlyReadyAndTerminatingCluster(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.0.1.3"}, @@ -5121,7 +5120,7 @@ func Test_EndpointSliceOnlyReadyAndTerminatingCluster(t *testing.T) { Serving: ptr.To(false), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.0.1.4"}, @@ -5130,7 +5129,7 @@ func Test_EndpointSliceOnlyReadyAndTerminatingCluster(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(true), }, - NodeName: ptr.To("another-host"), + NodeName: ptr.To("another-node"), }, { Addresses: []string{"10.0.1.5"}, @@ -5139,7 +5138,7 @@ func Test_EndpointSliceOnlyReadyAndTerminatingCluster(t *testing.T) { Serving: ptr.To(false), Terminating: ptr.To(false), }, - NodeName: ptr.To("another-host"), + NodeName: ptr.To("another-node"), }, }, } @@ -5275,7 +5274,7 @@ func Test_EndpointSliceOnlyReadyAndTerminatingLocal(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.0.1.2"}, @@ -5284,7 +5283,7 @@ func Test_EndpointSliceOnlyReadyAndTerminatingLocal(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.0.1.3"}, @@ -5293,7 +5292,7 @@ func Test_EndpointSliceOnlyReadyAndTerminatingLocal(t *testing.T) { Serving: ptr.To(false), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.0.1.4"}, @@ -5302,7 +5301,7 @@ func Test_EndpointSliceOnlyReadyAndTerminatingLocal(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(true), }, - NodeName: ptr.To("another-host"), + NodeName: ptr.To("another-node"), }, { Addresses: []string{"10.0.1.5"}, @@ -5311,7 +5310,7 @@ func Test_EndpointSliceOnlyReadyAndTerminatingLocal(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(false), }, - NodeName: ptr.To("another-host"), + NodeName: ptr.To("another-node"), }, }, } @@ -5480,7 +5479,7 @@ func TestIpIsValidForSet(t *testing.T) { func TestNoEndpointsMetric(t *testing.T) { type endpoint struct { ip string - hostname string + nodeName string } metrics.RegisterMetrics(kubeproxyconfig.ProxyModeIPVS) @@ -5497,18 +5496,18 @@ func TestNoEndpointsMetric(t *testing.T) { name: "internalTrafficPolicy is set and there are local endpoints", internalTrafficPolicy: ptr.To(v1.ServiceInternalTrafficPolicyLocal), endpoints: []endpoint{ - {"10.0.1.1", testHostname}, - {"10.0.1.2", "host1"}, - {"10.0.1.3", "host2"}, + {"10.0.1.1", testNodeName}, + {"10.0.1.2", "node1"}, + {"10.0.1.3", "node2"}, }, }, { name: "externalTrafficPolicy is set and there are local endpoints", externalTrafficPolicy: v1.ServiceExternalTrafficPolicyLocal, endpoints: []endpoint{ - {"10.0.1.1", testHostname}, - {"10.0.1.2", "host1"}, - {"10.0.1.3", "host2"}, + {"10.0.1.1", testNodeName}, + {"10.0.1.2", "node1"}, + {"10.0.1.3", "node2"}, }, }, { @@ -5516,18 +5515,18 @@ func TestNoEndpointsMetric(t *testing.T) { internalTrafficPolicy: ptr.To(v1.ServiceInternalTrafficPolicyLocal), externalTrafficPolicy: v1.ServiceExternalTrafficPolicyLocal, endpoints: []endpoint{ - {"10.0.1.1", testHostname}, - {"10.0.1.2", "host1"}, - {"10.0.1.3", "host2"}, + {"10.0.1.1", testNodeName}, + {"10.0.1.2", "node1"}, + {"10.0.1.3", "node2"}, }, }, { name: "internalTrafficPolicy is set and there are no local endpoints", internalTrafficPolicy: ptr.To(v1.ServiceInternalTrafficPolicyLocal), endpoints: []endpoint{ - {"10.0.1.1", "host0"}, - {"10.0.1.2", "host1"}, - {"10.0.1.3", "host2"}, + {"10.0.1.1", "node0"}, + {"10.0.1.2", "node1"}, + {"10.0.1.3", "node2"}, }, expectedSyncProxyRulesNoLocalEndpointsTotalInternal: 1, }, @@ -5535,9 +5534,9 @@ func TestNoEndpointsMetric(t *testing.T) { name: "externalTrafficPolicy is set and there are no local endpoints", externalTrafficPolicy: v1.ServiceExternalTrafficPolicyLocal, endpoints: []endpoint{ - {"10.0.1.1", "host0"}, - {"10.0.1.2", "host1"}, - {"10.0.1.3", "host2"}, + {"10.0.1.1", "node0"}, + {"10.0.1.2", "node1"}, + {"10.0.1.3", "node2"}, }, expectedSyncProxyRulesNoLocalEndpointsTotalExternal: 1, }, @@ -5546,9 +5545,9 @@ func TestNoEndpointsMetric(t *testing.T) { internalTrafficPolicy: ptr.To(v1.ServiceInternalTrafficPolicyLocal), externalTrafficPolicy: v1.ServiceExternalTrafficPolicyLocal, endpoints: []endpoint{ - {"10.0.1.1", "host0"}, - {"10.0.1.2", "host1"}, - {"10.0.1.3", "host2"}, + {"10.0.1.1", "node0"}, + {"10.0.1.2", "node1"}, + {"10.0.1.3", "node2"}, }, expectedSyncProxyRulesNoLocalEndpointsTotalInternal: 1, expectedSyncProxyRulesNoLocalEndpointsTotalExternal: 1, @@ -5613,7 +5612,7 @@ func TestNoEndpointsMetric(t *testing.T) { endpointSlice.Endpoints = append(endpointSlice.Endpoints, discovery.Endpoint{ Addresses: []string{ep.ip}, Conditions: discovery.EndpointConditions{Ready: ptr.To(true)}, - NodeName: ptr.To(ep.hostname), + NodeName: ptr.To(ep.nodeName), }) } diff --git a/pkg/proxy/nftables/proxier.go b/pkg/proxy/nftables/proxier.go index a5f2ce96334..b1bba524119 100644 --- a/pkg/proxy/nftables/proxier.go +++ b/pkg/proxy/nftables/proxier.go @@ -110,7 +110,7 @@ func NewDualStackProxier( masqueradeAll bool, masqueradeBit int, localDetectors map[v1.IPFamily]proxyutil.LocalTrafficDetector, - hostname string, + nodeName string, nodeIPs map[v1.IPFamily]net.IP, recorder events.EventRecorder, healthzServer *healthcheck.ProxyHealthServer, @@ -120,7 +120,7 @@ func NewDualStackProxier( // Create an ipv4 instance of the single-stack proxier ipv4Proxier, err := NewProxier(ctx, v1.IPv4Protocol, syncPeriod, minSyncPeriod, masqueradeAll, masqueradeBit, - localDetectors[v1.IPv4Protocol], hostname, nodeIPs[v1.IPv4Protocol], + localDetectors[v1.IPv4Protocol], nodeName, nodeIPs[v1.IPv4Protocol], recorder, healthzServer, nodePortAddresses, initOnly) if err != nil { return nil, fmt.Errorf("unable to create ipv4 proxier: %v", err) @@ -128,7 +128,7 @@ func NewDualStackProxier( ipv6Proxier, err := NewProxier(ctx, v1.IPv6Protocol, syncPeriod, minSyncPeriod, masqueradeAll, masqueradeBit, - localDetectors[v1.IPv6Protocol], hostname, nodeIPs[v1.IPv6Protocol], + localDetectors[v1.IPv6Protocol], nodeName, nodeIPs[v1.IPv6Protocol], recorder, healthzServer, nodePortAddresses, initOnly) if err != nil { return nil, fmt.Errorf("unable to create ipv6 proxier: %v", err) @@ -174,7 +174,7 @@ type Proxier struct { masqueradeMark string conntrack conntrack.Interface localDetector proxyutil.LocalTrafficDetector - hostname string + nodeName string nodeIP net.IP serviceHealthServer healthcheck.ServiceHealthServer @@ -215,7 +215,7 @@ func NewProxier(ctx context.Context, masqueradeAll bool, masqueradeBit int, localDetector proxyutil.LocalTrafficDetector, - hostname string, + nodeName string, nodeIP net.IP, recorder events.EventRecorder, healthzServer *healthcheck.ProxyHealthServer, @@ -241,14 +241,14 @@ func NewProxier(ctx context.Context, nodePortAddresses := proxyutil.NewNodePortAddresses(ipFamily, nodePortAddressStrings) - serviceHealthServer := healthcheck.NewServiceHealthServer(hostname, recorder, nodePortAddresses, healthzServer) + serviceHealthServer := healthcheck.NewServiceHealthServer(nodeName, recorder, nodePortAddresses, healthzServer) proxier := &Proxier{ ipFamily: ipFamily, svcPortMap: make(proxy.ServicePortMap), serviceChanges: proxy.NewServiceChangeTracker(ipFamily, newServiceInfo, nil), endpointsMap: make(proxy.EndpointsMap), - endpointsChanges: proxy.NewEndpointsChangeTracker(ipFamily, hostname, newEndpointInfo, nil), + endpointsChanges: proxy.NewEndpointsChangeTracker(ipFamily, nodeName, newEndpointInfo, nil), needFullSync: true, syncPeriod: syncPeriod, nftables: nft, @@ -256,7 +256,7 @@ func NewProxier(ctx context.Context, masqueradeMark: masqueradeMark, conntrack: conntrack.New(), localDetector: localDetector, - hostname: hostname, + nodeName: nodeName, nodeIP: nodeIP, serviceHealthServer: serviceHealthServer, healthzServer: healthzServer, @@ -842,9 +842,9 @@ func (proxier *Proxier) OnEndpointSlicesSynced() { // OnNodeAdd is called whenever creation of new node object // is observed. func (proxier *Proxier) OnNodeAdd(node *v1.Node) { - if node.Name != proxier.hostname { + if node.Name != proxier.nodeName { proxier.logger.Error(nil, "Received a watch event for a node that doesn't match the current node", - "eventNode", node.Name, "currentNode", proxier.hostname) + "eventNode", node.Name, "currentNode", proxier.nodeName) return } @@ -867,9 +867,9 @@ func (proxier *Proxier) OnNodeAdd(node *v1.Node) { // OnNodeUpdate is called whenever modification of an existing // node object is observed. func (proxier *Proxier) OnNodeUpdate(oldNode, node *v1.Node) { - if node.Name != proxier.hostname { + if node.Name != proxier.nodeName { proxier.logger.Error(nil, "Received a watch event for a node that doesn't match the current node", - "eventNode", node.Name, "currentNode", proxier.hostname) + "eventNode", node.Name, "currentNode", proxier.nodeName) return } @@ -892,9 +892,9 @@ func (proxier *Proxier) OnNodeUpdate(oldNode, node *v1.Node) { // OnNodeDelete is called whenever deletion of an existing node // object is observed. func (proxier *Proxier) OnNodeDelete(node *v1.Node) { - if node.Name != proxier.hostname { + if node.Name != proxier.nodeName { proxier.logger.Error(nil, "Received a watch event for a node that doesn't match the current node", - "eventNode", node.Name, "currentNode", proxier.hostname) + "eventNode", node.Name, "currentNode", proxier.nodeName) return } diff --git a/pkg/proxy/nftables/proxier_test.go b/pkg/proxy/nftables/proxier_test.go index 112d67997ba..2bc57b18bf7 100644 --- a/pkg/proxy/nftables/proxier_test.go +++ b/pkg/proxy/nftables/proxier_test.go @@ -65,7 +65,7 @@ import ( // Non-cluster IPs: 203.0.113.0/24 // LB Source Range: 203.0.113.0/25 -const testHostname = "test-hostname" +const testNodeName = "test-node" const testNodeIP = "192.168.0.2" const testNodeIPAlt = "192.168.1.2" const testExternalIP = "192.168.99.11" @@ -120,13 +120,13 @@ func NewFakeProxier(ipFamily v1.IPFamily) (*knftables.Fake, *Proxier) { svcPortMap: make(proxy.ServicePortMap), serviceChanges: proxy.NewServiceChangeTracker(ipFamily, newServiceInfo, nil), endpointsMap: make(proxy.EndpointsMap), - endpointsChanges: proxy.NewEndpointsChangeTracker(ipFamily, testHostname, newEndpointInfo, nil), + endpointsChanges: proxy.NewEndpointsChangeTracker(ipFamily, testNodeName, newEndpointInfo, nil), needFullSync: true, nftables: nft, masqueradeMark: "0x4000", conntrack: conntrack.NewFake(), localDetector: detectLocal, - hostname: testHostname, + nodeName: testNodeName, serviceHealthServer: healthcheck.NewFakeServiceHealthServer(), nodeIP: nodeIP, nodePortAddresses: proxyutil.NewNodePortAddresses(ipFamily, nodePortAddresses), @@ -343,7 +343,7 @@ func TestOverallNFTablesRules(t *testing.T) { Addresses: []string{"10.180.0.4"}, }, { Addresses: []string{"10.180.0.5"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p80"), @@ -599,7 +599,7 @@ func TestClusterIPGeneral(t *testing.T) { eps.AddressType = discovery.AddressTypeIPv4 eps.Endpoints = []discovery.Endpoint{{ Addresses: []string{"10.180.0.1"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("http"), @@ -612,11 +612,11 @@ func TestClusterIPGeneral(t *testing.T) { eps.Endpoints = []discovery.Endpoint{ { Addresses: []string{"10.180.0.1"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.180.2.1"}, - NodeName: ptr.To("host2"), + NodeName: ptr.To("node2"), }, } eps.Ports = []discovery.EndpointPort{ @@ -991,7 +991,7 @@ func TestNodePorts(t *testing.T) { NodeName: nil, }, { Addresses: []string{epIP2}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p80"), @@ -1116,7 +1116,7 @@ func TestExternalTrafficPolicyLocal(t *testing.T) { Addresses: []string{epIP1}, }, { Addresses: []string{epIP2}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To(svcPortName.Port), @@ -1232,7 +1232,7 @@ func TestExternalTrafficPolicyCluster(t *testing.T) { NodeName: nil, }, { Addresses: []string{epIP2}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To(svcPortName.Port), @@ -1635,7 +1635,7 @@ func TestUpdateEndpointsMap(t *testing.T) { eps.AddressType = discovery.AddressTypeIPv4 eps.Endpoints = []discovery.Endpoint{{ Addresses: []string{"10.1.1.1"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p11"), @@ -1683,7 +1683,7 @@ func TestUpdateEndpointsMap(t *testing.T) { Addresses: []string{"10.1.1.1"}, }, { Addresses: []string{"10.1.1.2"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p11"), @@ -1704,7 +1704,7 @@ func TestUpdateEndpointsMap(t *testing.T) { eps.AddressType = discovery.AddressTypeIPv4 eps.Endpoints = []discovery.Endpoint{{ Addresses: []string{"10.1.1.2"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p12"), @@ -1720,7 +1720,7 @@ func TestUpdateEndpointsMap(t *testing.T) { eps.AddressType = discovery.AddressTypeIPv4 eps.Endpoints = []discovery.Endpoint{{ Addresses: []string{"10.1.1.1"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p11"), @@ -1753,7 +1753,7 @@ func TestUpdateEndpointsMap(t *testing.T) { Addresses: []string{"10.1.1.1"}, }, { Addresses: []string{"10.1.1.2"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p11"), @@ -1771,7 +1771,7 @@ func TestUpdateEndpointsMap(t *testing.T) { Addresses: []string{"10.1.1.3"}, }, { Addresses: []string{"10.1.1.4"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p13"), @@ -1789,7 +1789,7 @@ func TestUpdateEndpointsMap(t *testing.T) { Addresses: []string{"10.2.2.1"}, }, { Addresses: []string{"10.2.2.2"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p21"), @@ -1810,10 +1810,10 @@ func TestUpdateEndpointsMap(t *testing.T) { eps.AddressType = discovery.AddressTypeIPv4 eps.Endpoints = []discovery.Endpoint{{ Addresses: []string{"10.2.2.2"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.2.2.22"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p22"), @@ -1825,7 +1825,7 @@ func TestUpdateEndpointsMap(t *testing.T) { eps.AddressType = discovery.AddressTypeIPv4 eps.Endpoints = []discovery.Endpoint{{ Addresses: []string{"10.2.2.3"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p23"), @@ -1837,10 +1837,10 @@ func TestUpdateEndpointsMap(t *testing.T) { eps.AddressType = discovery.AddressTypeIPv4 eps.Endpoints = []discovery.Endpoint{{ Addresses: []string{"10.4.4.4"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.4.4.5"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p44"), @@ -1852,7 +1852,7 @@ func TestUpdateEndpointsMap(t *testing.T) { eps.AddressType = discovery.AddressTypeIPv4 eps.Endpoints = []discovery.Endpoint{{ Addresses: []string{"10.4.4.6"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p45"), @@ -1903,7 +1903,7 @@ func TestUpdateEndpointsMap(t *testing.T) { eps.AddressType = discovery.AddressTypeIPv4 eps.Endpoints = []discovery.Endpoint{{ Addresses: []string{"10.4.4.4"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To("p44"), @@ -2297,7 +2297,6 @@ func TestUpdateEndpointsMap(t *testing.T) { for tci, tc := range testCases { t.Run(tc.name, func(t *testing.T) { _, fp := NewFakeProxier(v1.IPv4Protocol) - fp.hostname = testHostname // First check that after adding all previous versions of endpoints, // the fp.oldEndpoints is as we expect. @@ -2372,19 +2371,19 @@ func TestHealthCheckNodePortWhenTerminating(t *testing.T) { Endpoints: []discovery.Endpoint{{ Addresses: []string{"10.0.1.1"}, Conditions: discovery.EndpointConditions{Ready: ptr.To(true)}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.0.1.2"}, Conditions: discovery.EndpointConditions{Ready: ptr.To(true)}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.0.1.3"}, Conditions: discovery.EndpointConditions{Ready: ptr.To(true)}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { // not ready endpoints should be ignored Addresses: []string{"10.0.1.4"}, Conditions: discovery.EndpointConditions{Ready: ptr.To(false)}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }}, } @@ -2415,7 +2414,7 @@ func TestHealthCheckNodePortWhenTerminating(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(false), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.0.1.2"}, Conditions: discovery.EndpointConditions{ @@ -2423,7 +2422,7 @@ func TestHealthCheckNodePortWhenTerminating(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.0.1.3"}, Conditions: discovery.EndpointConditions{ @@ -2431,7 +2430,7 @@ func TestHealthCheckNodePortWhenTerminating(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { // not ready endpoints should be ignored Addresses: []string{"10.0.1.4"}, Conditions: discovery.EndpointConditions{ @@ -2439,7 +2438,7 @@ func TestHealthCheckNodePortWhenTerminating(t *testing.T) { Serving: ptr.To(false), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }}, } @@ -2458,7 +2457,7 @@ func TestHealthCheckNodePortWhenTerminating(t *testing.T) { func TestInternalTrafficPolicy(t *testing.T) { type endpoint struct { ip string - hostname string + nodeName string } testCases := []struct { @@ -2473,9 +2472,9 @@ func TestInternalTrafficPolicy(t *testing.T) { line: getLine(), internalTrafficPolicy: ptr.To(v1.ServiceInternalTrafficPolicyCluster), endpoints: []endpoint{ - {"10.0.1.1", testHostname}, - {"10.0.1.2", "host1"}, - {"10.0.1.3", "host2"}, + {"10.0.1.1", testNodeName}, + {"10.0.1.2", "node1"}, + {"10.0.1.3", "node2"}, }, flowTests: []packetFlowTest{ { @@ -2493,9 +2492,9 @@ func TestInternalTrafficPolicy(t *testing.T) { line: getLine(), internalTrafficPolicy: ptr.To(v1.ServiceInternalTrafficPolicyLocal), endpoints: []endpoint{ - {"10.0.1.1", testHostname}, - {"10.0.1.2", "host1"}, - {"10.0.1.3", "host2"}, + {"10.0.1.1", testNodeName}, + {"10.0.1.2", "node1"}, + {"10.0.1.3", "node2"}, }, flowTests: []packetFlowTest{ { @@ -2513,9 +2512,9 @@ func TestInternalTrafficPolicy(t *testing.T) { line: getLine(), internalTrafficPolicy: ptr.To(v1.ServiceInternalTrafficPolicyLocal), endpoints: []endpoint{ - {"10.0.1.1", testHostname}, - {"10.0.1.2", testHostname}, - {"10.0.1.3", "host2"}, + {"10.0.1.1", testNodeName}, + {"10.0.1.2", testNodeName}, + {"10.0.1.3", "node2"}, }, flowTests: []packetFlowTest{ { @@ -2533,9 +2532,9 @@ func TestInternalTrafficPolicy(t *testing.T) { line: getLine(), internalTrafficPolicy: ptr.To(v1.ServiceInternalTrafficPolicyLocal), endpoints: []endpoint{ - {"10.0.1.1", "host0"}, - {"10.0.1.2", "host1"}, - {"10.0.1.3", "host2"}, + {"10.0.1.1", "node0"}, + {"10.0.1.2", "node1"}, + {"10.0.1.3", "node2"}, }, flowTests: []packetFlowTest{ { @@ -2589,7 +2588,7 @@ func TestInternalTrafficPolicy(t *testing.T) { endpointSlice.Endpoints = append(endpointSlice.Endpoints, discovery.Endpoint{ Addresses: []string{ep.ip}, Conditions: discovery.EndpointConditions{Ready: ptr.To(true)}, - NodeName: ptr.To(ep.hostname), + NodeName: ptr.To(ep.nodeName), }) } @@ -2669,7 +2668,7 @@ func TestTerminatingEndpointsTrafficPolicyLocal(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(false), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.0.1.2"}, @@ -2678,7 +2677,7 @@ func TestTerminatingEndpointsTrafficPolicyLocal(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(false), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { // this endpoint should be ignored for external since there are ready non-terminating endpoints @@ -2688,7 +2687,7 @@ func TestTerminatingEndpointsTrafficPolicyLocal(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { // this endpoint should be ignored for external since there are ready non-terminating endpoints @@ -2698,7 +2697,7 @@ func TestTerminatingEndpointsTrafficPolicyLocal(t *testing.T) { Serving: ptr.To(false), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { // this endpoint should be ignored for external since it's not local @@ -2708,7 +2707,7 @@ func TestTerminatingEndpointsTrafficPolicyLocal(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(false), }, - NodeName: ptr.To("host-1"), + NodeName: ptr.To("node-1"), }, }, }, @@ -2755,7 +2754,7 @@ func TestTerminatingEndpointsTrafficPolicyLocal(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { // this endpoint should be used since there are only ready terminating endpoints @@ -2765,7 +2764,7 @@ func TestTerminatingEndpointsTrafficPolicyLocal(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { // this endpoint should not be used since it is both terminating and not ready. @@ -2775,7 +2774,7 @@ func TestTerminatingEndpointsTrafficPolicyLocal(t *testing.T) { Serving: ptr.To(false), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { // this endpoint should be ignored for external since it's not local @@ -2785,7 +2784,7 @@ func TestTerminatingEndpointsTrafficPolicyLocal(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(false), }, - NodeName: ptr.To("host-1"), + NodeName: ptr.To("node-1"), }, }, }, @@ -2833,7 +2832,7 @@ func TestTerminatingEndpointsTrafficPolicyLocal(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(true), }, - NodeName: ptr.To("host-1"), + NodeName: ptr.To("node-1"), }, }, }, @@ -2878,7 +2877,7 @@ func TestTerminatingEndpointsTrafficPolicyLocal(t *testing.T) { Serving: ptr.To(false), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { // Remote and not ready or serving @@ -2888,7 +2887,7 @@ func TestTerminatingEndpointsTrafficPolicyLocal(t *testing.T) { Serving: ptr.To(false), Terminating: ptr.To(true), }, - NodeName: ptr.To("host-1"), + NodeName: ptr.To("node-1"), }, }, }, @@ -3002,7 +3001,7 @@ func TestTerminatingEndpointsTrafficPolicyCluster(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(false), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.0.1.2"}, @@ -3011,7 +3010,7 @@ func TestTerminatingEndpointsTrafficPolicyCluster(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(false), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { // this endpoint should be ignored since there are ready non-terminating endpoints @@ -3021,7 +3020,7 @@ func TestTerminatingEndpointsTrafficPolicyCluster(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(true), }, - NodeName: ptr.To("another-host"), + NodeName: ptr.To("another-node"), }, { // this endpoint should be ignored since it is not "serving" @@ -3031,7 +3030,7 @@ func TestTerminatingEndpointsTrafficPolicyCluster(t *testing.T) { Serving: ptr.To(false), Terminating: ptr.To(true), }, - NodeName: ptr.To("another-host"), + NodeName: ptr.To("another-node"), }, { Addresses: []string{"10.0.1.5"}, @@ -3040,7 +3039,7 @@ func TestTerminatingEndpointsTrafficPolicyCluster(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(false), }, - NodeName: ptr.To("another-host"), + NodeName: ptr.To("another-node"), }, }, }, @@ -3087,7 +3086,7 @@ func TestTerminatingEndpointsTrafficPolicyCluster(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { // this endpoint should be used since there are only ready terminating endpoints @@ -3097,7 +3096,7 @@ func TestTerminatingEndpointsTrafficPolicyCluster(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { // this endpoint should not be used since it is both terminating and not ready. @@ -3107,7 +3106,7 @@ func TestTerminatingEndpointsTrafficPolicyCluster(t *testing.T) { Serving: ptr.To(false), Terminating: ptr.To(true), }, - NodeName: ptr.To("another-host"), + NodeName: ptr.To("another-node"), }, { // this endpoint should be used since there are only ready terminating endpoints @@ -3117,7 +3116,7 @@ func TestTerminatingEndpointsTrafficPolicyCluster(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(true), }, - NodeName: ptr.To("another-host"), + NodeName: ptr.To("another-node"), }, }, }, @@ -3163,7 +3162,7 @@ func TestTerminatingEndpointsTrafficPolicyCluster(t *testing.T) { Serving: ptr.To(true), Terminating: ptr.To(true), }, - NodeName: ptr.To("host-1"), + NodeName: ptr.To("node-1"), }, }, }, @@ -3210,7 +3209,7 @@ func TestTerminatingEndpointsTrafficPolicyCluster(t *testing.T) { Serving: ptr.To(false), Terminating: ptr.To(true), }, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { // Remote, not ready or serving @@ -3220,7 +3219,7 @@ func TestTerminatingEndpointsTrafficPolicyCluster(t *testing.T) { Serving: ptr.To(false), Terminating: ptr.To(true), }, - NodeName: ptr.To("host-1"), + NodeName: ptr.To("node-1"), }, }, }, @@ -3335,7 +3334,7 @@ func TestInternalExternalMasquerade(t *testing.T) { eps.Endpoints = []discovery.Endpoint{ { Addresses: []string{"10.180.0.1"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.180.1.1"}, @@ -3353,7 +3352,7 @@ func TestInternalExternalMasquerade(t *testing.T) { eps.Endpoints = []discovery.Endpoint{ { Addresses: []string{"10.180.0.2"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.180.1.2"}, @@ -3371,7 +3370,7 @@ func TestInternalExternalMasquerade(t *testing.T) { eps.Endpoints = []discovery.Endpoint{ { Addresses: []string{"10.180.0.3"}, - NodeName: ptr.To(testHostname), + NodeName: ptr.To(testNodeName), }, { Addresses: []string{"10.180.1.3"}, @@ -4462,7 +4461,7 @@ func TestSyncProxyRulesStartup(t *testing.T) { func TestNoEndpointsMetric(t *testing.T) { type endpoint struct { ip string - hostname string + nodeName string } metrics.RegisterMetrics(kubeproxyconfig.ProxyModeNFTables) @@ -4478,18 +4477,18 @@ func TestNoEndpointsMetric(t *testing.T) { name: "internalTrafficPolicy is set and there are local endpoints", internalTrafficPolicy: ptr.To(v1.ServiceInternalTrafficPolicyLocal), endpoints: []endpoint{ - {"10.0.1.1", testHostname}, - {"10.0.1.2", "host1"}, - {"10.0.1.3", "host2"}, + {"10.0.1.1", testNodeName}, + {"10.0.1.2", "node1"}, + {"10.0.1.3", "node2"}, }, }, { name: "externalTrafficPolicy is set and there are local endpoints", externalTrafficPolicy: v1.ServiceExternalTrafficPolicyLocal, endpoints: []endpoint{ - {"10.0.1.1", testHostname}, - {"10.0.1.2", "host1"}, - {"10.0.1.3", "host2"}, + {"10.0.1.1", testNodeName}, + {"10.0.1.2", "node1"}, + {"10.0.1.3", "node2"}, }, }, { @@ -4497,18 +4496,18 @@ func TestNoEndpointsMetric(t *testing.T) { internalTrafficPolicy: ptr.To(v1.ServiceInternalTrafficPolicyLocal), externalTrafficPolicy: v1.ServiceExternalTrafficPolicyLocal, endpoints: []endpoint{ - {"10.0.1.1", testHostname}, - {"10.0.1.2", "host1"}, - {"10.0.1.3", "host2"}, + {"10.0.1.1", testNodeName}, + {"10.0.1.2", "node1"}, + {"10.0.1.3", "node2"}, }, }, { name: "internalTrafficPolicy is set and there are no local endpoints", internalTrafficPolicy: ptr.To(v1.ServiceInternalTrafficPolicyLocal), endpoints: []endpoint{ - {"10.0.1.1", "host0"}, - {"10.0.1.2", "host1"}, - {"10.0.1.3", "host2"}, + {"10.0.1.1", "node0"}, + {"10.0.1.2", "node1"}, + {"10.0.1.3", "node2"}, }, expectedSyncProxyRulesNoLocalEndpointsTotalInternal: 1, }, @@ -4516,9 +4515,9 @@ func TestNoEndpointsMetric(t *testing.T) { name: "externalTrafficPolicy is set and there are no local endpoints", externalTrafficPolicy: v1.ServiceExternalTrafficPolicyLocal, endpoints: []endpoint{ - {"10.0.1.1", "host0"}, - {"10.0.1.2", "host1"}, - {"10.0.1.3", "host2"}, + {"10.0.1.1", "node0"}, + {"10.0.1.2", "node1"}, + {"10.0.1.3", "node2"}, }, expectedSyncProxyRulesNoLocalEndpointsTotalExternal: 1, }, @@ -4527,9 +4526,9 @@ func TestNoEndpointsMetric(t *testing.T) { internalTrafficPolicy: ptr.To(v1.ServiceInternalTrafficPolicyLocal), externalTrafficPolicy: v1.ServiceExternalTrafficPolicyLocal, endpoints: []endpoint{ - {"10.0.1.1", "host0"}, - {"10.0.1.2", "host1"}, - {"10.0.1.3", "host2"}, + {"10.0.1.1", "node0"}, + {"10.0.1.2", "node1"}, + {"10.0.1.3", "node2"}, }, expectedSyncProxyRulesNoLocalEndpointsTotalInternal: 1, expectedSyncProxyRulesNoLocalEndpointsTotalExternal: 1, @@ -4588,7 +4587,7 @@ func TestNoEndpointsMetric(t *testing.T) { endpointSlice.Endpoints = append(endpointSlice.Endpoints, discovery.Endpoint{ Addresses: []string{ep.ip}, Conditions: discovery.EndpointConditions{Ready: ptr.To(true)}, - NodeName: ptr.To(ep.hostname), + NodeName: ptr.To(ep.nodeName), }) } diff --git a/pkg/proxy/winkernel/proxier.go b/pkg/proxy/winkernel/proxier.go index 6279a92c0cb..70bb3303cb6 100644 --- a/pkg/proxy/winkernel/proxier.go +++ b/pkg/proxy/winkernel/proxier.go @@ -652,7 +652,7 @@ type Proxier struct { initialized int32 syncRunner *async.BoundedFrequencyRunner // governs calls to syncProxyRules // These are effectively const and do not need the mutex to be held. - hostname string + nodeName string nodeIP net.IP serviceHealthServer healthcheck.ServiceHealthServer @@ -709,7 +709,7 @@ func NewProxier( ipFamily v1.IPFamily, syncPeriod time.Duration, minSyncPeriod time.Duration, - hostname string, + nodeName string, nodeIP net.IP, recorder events.EventRecorder, healthzServer *healthcheck.ProxyHealthServer, @@ -718,7 +718,7 @@ func NewProxier( ) (*Proxier, error) { // windows listens to all node addresses nodePortAddresses := proxyutil.NewNodePortAddresses(ipFamily, nil) - serviceHealthServer := healthcheck.NewServiceHealthServer(hostname, recorder, nodePortAddresses, healthzServer) + serviceHealthServer := healthcheck.NewServiceHealthServer(nodeName, recorder, nodePortAddresses, healthzServer) var healthzPort int if len(healthzBindAddress) > 0 { @@ -729,7 +729,7 @@ func NewProxier( hcnImpl := newHcnImpl() proxier, err := newProxierInternal( ipFamily, - hostname, + nodeName, nodeIP, serviceHealthServer, healthzServer, @@ -752,7 +752,7 @@ func NewProxier( // allow internal testing of proxier func newProxierInternal( ipFamily v1.IPFamily, - hostname string, + nodeName string, nodeIP net.IP, serviceHealthServer healthcheck.ServiceHealthServer, healthzServer *healthcheck.ProxyHealthServer, @@ -837,7 +837,7 @@ func newProxierInternal( endPointsRefCount: make(endPointsReferenceCountMap), svcPortMap: make(proxy.ServicePortMap), endpointsMap: make(proxy.EndpointsMap), - hostname: hostname, + nodeName: nodeName, nodeIP: nodeIP, serviceHealthServer: serviceHealthServer, healthzServer: healthzServer, @@ -856,7 +856,7 @@ func newProxierInternal( } serviceChanges := proxy.NewServiceChangeTracker(ipFamily, proxier.newServiceInfo, proxier.serviceMapChange) - endPointChangeTracker := proxy.NewEndpointsChangeTracker(ipFamily, hostname, proxier.newEndpointInfo, proxier.endpointsMapChange) + endPointChangeTracker := proxy.NewEndpointsChangeTracker(ipFamily, nodeName, proxier.newEndpointInfo, proxier.endpointsMapChange) proxier.endpointsChanges = endPointChangeTracker proxier.serviceChanges = serviceChanges @@ -866,7 +866,7 @@ func newProxierInternal( func NewDualStackProxier( syncPeriod time.Duration, minSyncPeriod time.Duration, - hostname string, + nodeName string, nodeIPs map[v1.IPFamily]net.IP, recorder events.EventRecorder, healthzServer *healthcheck.ProxyHealthServer, @@ -876,18 +876,18 @@ func NewDualStackProxier( // Create an ipv4 instance of the single-stack proxier ipv4Proxier, err := NewProxier(v1.IPv4Protocol, syncPeriod, minSyncPeriod, - hostname, nodeIPs[v1.IPv4Protocol], recorder, healthzServer, + nodeName, nodeIPs[v1.IPv4Protocol], recorder, healthzServer, healthzBindAddress, config) if err != nil { - return nil, fmt.Errorf("unable to create ipv4 proxier: %v, hostname: %s, nodeIP:%v", err, hostname, nodeIPs[v1.IPv4Protocol]) + return nil, fmt.Errorf("unable to create ipv4 proxier: %v, nodeName: %s, nodeIP:%v", err, nodeName, nodeIPs[v1.IPv4Protocol]) } ipv6Proxier, err := NewProxier(v1.IPv6Protocol, syncPeriod, minSyncPeriod, - hostname, nodeIPs[v1.IPv6Protocol], recorder, healthzServer, + nodeName, nodeIPs[v1.IPv6Protocol], recorder, healthzServer, healthzBindAddress, config) if err != nil { - return nil, fmt.Errorf("unable to create ipv6 proxier: %v, hostname: %s, nodeIP:%v", err, hostname, nodeIPs[v1.IPv6Protocol]) + return nil, fmt.Errorf("unable to create ipv6 proxier: %v, nodeName: %s, nodeIP:%v", err, nodeName, nodeIPs[v1.IPv6Protocol]) } // Return a meta-proxier that dispatch calls between the two diff --git a/pkg/proxy/winkernel/proxier_test.go b/pkg/proxy/winkernel/proxier_test.go index dcfcc0cd49d..f84526a412a 100644 --- a/pkg/proxy/winkernel/proxier_test.go +++ b/pkg/proxy/winkernel/proxier_test.go @@ -45,7 +45,7 @@ import ( ) const ( - testHostName = "test-hostname" + testNodeName = "test-node" testNetwork = "TestNetwork" ipAddress = "10.0.0.1" prefixLen = 24 @@ -87,7 +87,7 @@ func newHnsNetwork(networkInfo *hnsNetworkInfo) *hcn.HostComputeNetwork { return network } -func NewFakeProxier(t *testing.T, hostname string, nodeIP net.IP, networkType string, enableDSR bool) *Proxier { +func NewFakeProxier(t *testing.T, nodeName string, nodeIP net.IP, networkType string, enableDSR bool) *Proxier { sourceVip := "192.168.1.2" // enable `WinDSR` feature gate @@ -104,7 +104,7 @@ func NewFakeProxier(t *testing.T, hostname string, nodeIP net.IP, networkType st proxier, _ := newProxierInternal( v1.IPv4Protocol, - hostname, + nodeName, nodeIP, healthcheck.NewFakeServiceHealthServer(), nil, @@ -139,7 +139,7 @@ func getHcnMock(networkType string) *fakehcn.HcnMock { } func TestCreateServiceVip(t *testing.T) { - proxier := NewFakeProxier(t, "testhost", netutils.ParseIPSloppy("10.0.0.1"), NETWORK_TYPE_OVERLAY, true) + proxier := NewFakeProxier(t, testNodeName, netutils.ParseIPSloppy("10.0.0.1"), NETWORK_TYPE_OVERLAY, true) if proxier == nil { t.Error() } @@ -192,7 +192,7 @@ func TestCreateServiceVip(t *testing.T) { } func TestCreateRemoteEndpointOverlay(t *testing.T) { - proxier := NewFakeProxier(t, "testhost", netutils.ParseIPSloppy("10.0.0.1"), NETWORK_TYPE_OVERLAY, false) + proxier := NewFakeProxier(t, testNodeName, netutils.ParseIPSloppy("10.0.0.1"), NETWORK_TYPE_OVERLAY, false) if proxier == nil { t.Error() } @@ -256,7 +256,7 @@ func TestCreateRemoteEndpointOverlay(t *testing.T) { } func TestCreateRemoteEndpointL2Bridge(t *testing.T) { - proxier := NewFakeProxier(t, "testhost", netutils.ParseIPSloppy("10.0.0.1"), "L2Bridge", false) + proxier := NewFakeProxier(t, testNodeName, netutils.ParseIPSloppy("10.0.0.1"), "L2Bridge", false) if proxier == nil { t.Error() } @@ -413,7 +413,7 @@ func TestDsrNotAppliedToClusterTrafficPolicy(t *testing.T) { } func TestSharedRemoteEndpointDelete(t *testing.T) { - proxier := NewFakeProxier(t, "testhost", netutils.ParseIPSloppy("10.0.0.1"), "L2Bridge", true) + proxier := NewFakeProxier(t, testNodeName, netutils.ParseIPSloppy("10.0.0.1"), "L2Bridge", true) if proxier == nil { t.Error() } @@ -554,7 +554,7 @@ func TestSharedRemoteEndpointDelete(t *testing.T) { } } func TestSharedRemoteEndpointUpdate(t *testing.T) { - proxier := NewFakeProxier(t, "testhost", netutils.ParseIPSloppy("10.0.0.1"), "L2Bridge", true) + proxier := NewFakeProxier(t, testNodeName, netutils.ParseIPSloppy("10.0.0.1"), "L2Bridge", true) if proxier == nil { t.Error() } @@ -728,7 +728,7 @@ func TestSharedRemoteEndpointUpdate(t *testing.T) { } func TestCreateLoadBalancerWithoutDSR(t *testing.T) { - proxier := NewFakeProxier(t, "testhost", netutils.ParseIPSloppy("10.0.0.1"), NETWORK_TYPE_OVERLAY, false) + proxier := NewFakeProxier(t, testNodeName, netutils.ParseIPSloppy("10.0.0.1"), NETWORK_TYPE_OVERLAY, false) if proxier == nil { t.Error() } @@ -797,7 +797,7 @@ func TestCreateLoadBalancerWithoutDSR(t *testing.T) { } func TestCreateLoadBalancerWithDSR(t *testing.T) { - proxier := NewFakeProxier(t, "testhost", netutils.ParseIPSloppy("10.0.0.1"), NETWORK_TYPE_OVERLAY, true) + proxier := NewFakeProxier(t, testNodeName, netutils.ParseIPSloppy("10.0.0.1"), NETWORK_TYPE_OVERLAY, true) if proxier == nil { t.Error() } @@ -866,7 +866,7 @@ func TestCreateLoadBalancerWithDSR(t *testing.T) { } func TestUpdateLoadBalancerWhenSupported(t *testing.T) { - proxier := NewFakeProxier(t, "testhost", netutils.ParseIPSloppy("10.0.0.1"), NETWORK_TYPE_OVERLAY, true) + proxier := NewFakeProxier(t, testNodeName, netutils.ParseIPSloppy("10.0.0.1"), NETWORK_TYPE_OVERLAY, true) if proxier == nil { t.Error() } @@ -1007,7 +1007,7 @@ func TestUpdateLoadBalancerWhenSupported(t *testing.T) { } func TestUpdateLoadBalancerWhenUnsupported(t *testing.T) { - proxier := NewFakeProxier(t, "testhost", netutils.ParseIPSloppy("10.0.0.1"), NETWORK_TYPE_OVERLAY, true) + proxier := NewFakeProxier(t, testNodeName, netutils.ParseIPSloppy("10.0.0.1"), NETWORK_TYPE_OVERLAY, true) if proxier == nil { t.Error() } @@ -1149,7 +1149,7 @@ func TestUpdateLoadBalancerWhenUnsupported(t *testing.T) { } func TestCreateDsrLoadBalancer(t *testing.T) { - proxier := NewFakeProxier(t, "testhost", netutils.ParseIPSloppy("10.0.0.1"), NETWORK_TYPE_OVERLAY, true) + proxier := NewFakeProxier(t, testNodeName, netutils.ParseIPSloppy("10.0.0.1"), NETWORK_TYPE_OVERLAY, true) if proxier == nil { t.Error() } @@ -1185,7 +1185,7 @@ func TestCreateDsrLoadBalancer(t *testing.T) { eps.AddressType = discovery.AddressTypeIPv4 eps.Endpoints = []discovery.Endpoint{{ Addresses: []string{epIpAddressRemote}, - NodeName: ptr.To("testhost"), + NodeName: ptr.To(testNodeName), }} eps.Ports = []discovery.EndpointPort{{ Name: ptr.To(svcPortName.Port), @@ -1227,7 +1227,7 @@ func TestCreateDsrLoadBalancer(t *testing.T) { // syncproxyrules only creates ClusterIP Loadbalancer and no NodePort, External IP or IngressIP // loadbalancers will be created. func TestClusterIPLBInCreateDsrLoadBalancer(t *testing.T) { - proxier := NewFakeProxier(t, "testhost", netutils.ParseIPSloppy("10.0.0.1"), NETWORK_TYPE_OVERLAY, false) + proxier := NewFakeProxier(t, testNodeName, netutils.ParseIPSloppy("10.0.0.1"), NETWORK_TYPE_OVERLAY, false) if proxier == nil { t.Error() @@ -1307,7 +1307,7 @@ func TestClusterIPLBInCreateDsrLoadBalancer(t *testing.T) { } func TestEndpointSlice(t *testing.T) { - proxier := NewFakeProxier(t, "testhost", netutils.ParseIPSloppy("10.0.0.1"), NETWORK_TYPE_OVERLAY, true) + proxier := NewFakeProxier(t, testNodeName, netutils.ParseIPSloppy("10.0.0.1"), NETWORK_TYPE_OVERLAY, true) if proxier == nil { t.Error() } @@ -1387,7 +1387,7 @@ func TestNoopEndpointSlice(t *testing.T) { } func TestFindRemoteSubnetProviderAddress(t *testing.T) { - proxier := NewFakeProxier(t, "testhost", netutils.ParseIPSloppy("10.0.0.1"), NETWORK_TYPE_OVERLAY, true) + proxier := NewFakeProxier(t, testNodeName, netutils.ParseIPSloppy("10.0.0.1"), NETWORK_TYPE_OVERLAY, true) if proxier == nil { t.Error() } @@ -1413,7 +1413,7 @@ func TestFindRemoteSubnetProviderAddress(t *testing.T) { } func TestWinDSRWithOverlayEnabled(t *testing.T) { - proxier := NewFakeProxier(t, "testhost", netutils.ParseIPSloppy("10.0.0.1"), NETWORK_TYPE_OVERLAY, true) + proxier := NewFakeProxier(t, testNodeName, netutils.ParseIPSloppy("10.0.0.1"), NETWORK_TYPE_OVERLAY, true) if proxier == nil { t.Error("Failed to create proxier") } @@ -1499,7 +1499,7 @@ func TestDSRFeatureGateValidation(t *testing.T) { _, err := newProxierInternal( v1.IPv4Protocol, // ipFamily - testHostName, // hostname + testNodeName, // nodeName netutils.ParseIPSloppy("192.168.1.1"), // nodeIP nil, // serviceHealthServer (not needed in this unit test) nil, // healthzServer (not needed in this unit test)