diff --git a/cmd/kube-proxy/app/server.go b/cmd/kube-proxy/app/server.go index 1c6492633f4..4f8ff6cda1c 100644 --- a/cmd/kube-proxy/app/server.go +++ b/cmd/kube-proxy/app/server.go @@ -159,7 +159,7 @@ type ProxyServer struct { Broadcaster events.EventBroadcaster Recorder events.EventRecorder NodeRef *v1.ObjectReference - HealthzServer *healthcheck.ProxierHealthServer + HealthzServer *healthcheck.ProxyHealthServer Hostname string PrimaryIPFamily v1.IPFamily NodeIPs map[v1.IPFamily]net.IP @@ -224,7 +224,7 @@ func newProxyServer(ctx context.Context, config *kubeproxyconfig.KubeProxyConfig } if len(config.HealthzBindAddress) > 0 { - s.HealthzServer = healthcheck.NewProxierHealthServer(config.HealthzBindAddress, 2*config.SyncPeriod.Duration) + s.HealthzServer = healthcheck.NewProxyHealthServer(config.HealthzBindAddress, 2*config.SyncPeriod.Duration) } err = s.platformSetup(ctx) @@ -415,7 +415,7 @@ func createClient(ctx context.Context, config componentbaseconfig.ClientConnecti return client, nil } -func serveHealthz(ctx context.Context, hz *healthcheck.ProxierHealthServer, errCh chan error) { +func serveHealthz(ctx context.Context, hz *healthcheck.ProxyHealthServer, errCh chan error) { logger := klog.FromContext(ctx) if hz == nil { return diff --git a/pkg/proxy/healthcheck/common.go b/pkg/proxy/healthcheck/common.go index c7a9f8bfbe0..5e026484665 100644 --- a/pkg/proxy/healthcheck/common.go +++ b/pkg/proxy/healthcheck/common.go @@ -24,21 +24,21 @@ import ( netutils "k8s.io/utils/net" ) -// listener allows for testing of ServiceHealthServer and ProxierHealthServer. +// listener allows for testing of ServiceHealthServer and ProxyHealthServer. type listener interface { // Listen is very much like netutils.MultiListen, except the second arg (network) is // fixed to be "tcp". Listen(ctx context.Context, addrs ...string) (net.Listener, error) } -// httpServerFactory allows for testing of ServiceHealthServer and ProxierHealthServer. +// httpServerFactory allows for testing of ServiceHealthServer and ProxyHealthServer. type httpServerFactory interface { // New creates an instance of a type satisfying HTTPServer. This is // designed to include http.Server. New(handler http.Handler) httpServer } -// httpServer allows for testing of ServiceHealthServer and ProxierHealthServer. +// httpServer allows for testing of ServiceHealthServer and ProxyHealthServer. // It is designed so that http.Server satisfies this interface, type httpServer interface { Serve(listener net.Listener) error diff --git a/pkg/proxy/healthcheck/healthcheck_test.go b/pkg/proxy/healthcheck/healthcheck_test.go index 777f529897e..d1ff3e78cef 100644 --- a/pkg/proxy/healthcheck/healthcheck_test.go +++ b/pkg/proxy/healthcheck/healthcheck_test.go @@ -138,11 +138,11 @@ type healthzPayload struct { NodeHealthy bool } -type fakeProxierHealthChecker struct { +type fakeProxyHealthChecker struct { healthy bool } -func (fake fakeProxierHealthChecker) IsHealthy() bool { +func (fake fakeProxyHealthChecker) IsHealthy() bool { return fake.healthy } @@ -150,7 +150,7 @@ func TestServer(t *testing.T) { listener := newFakeListener() httpFactory := newFakeHTTPServerFactory() nodePortAddresses := proxyutil.NewNodePortAddresses(v1.IPv4Protocol, []string{}) - proxyChecker := &fakeProxierHealthChecker{true} + proxyChecker := &fakeProxyHealthChecker{true} hcsi := newServiceHealthServer("hostname", nil, listener, httpFactory, nodePortAddresses, proxyChecker) hcs := hcsi.(*server) @@ -469,7 +469,7 @@ func TestHealthzServer(t *testing.T) { httpFactory := newFakeHTTPServerFactory() fakeClock := testingclock.NewFakeClock(time.Now()) - hs := newProxierHealthServer(listener, httpFactory, fakeClock, "127.0.0.1:10256", 10*time.Second) + hs := newProxyHealthServer(listener, httpFactory, fakeClock, "127.0.0.1:10256", 10*time.Second) server := hs.httpFactory.New(healthzHandler{hs: hs}) hsTest := &serverTest{ @@ -479,7 +479,7 @@ func TestHealthzServer(t *testing.T) { tracking503: 0, } - testProxierHealthUpdater(hs, hsTest, fakeClock, t) + testProxyHealthUpdater(hs, hsTest, fakeClock, t) // Should return 200 "OK" if we've synced a node, tainted in any other way hs.SyncNode(makeNode(tweakTainted("other"))) @@ -504,7 +504,7 @@ func TestLivezServer(t *testing.T) { httpFactory := newFakeHTTPServerFactory() fakeClock := testingclock.NewFakeClock(time.Now()) - hs := newProxierHealthServer(listener, httpFactory, fakeClock, "127.0.0.1:10256", 10*time.Second) + hs := newProxyHealthServer(listener, httpFactory, fakeClock, "127.0.0.1:10256", 10*time.Second) server := hs.httpFactory.New(livezHandler{hs: hs}) hsTest := &serverTest{ @@ -514,7 +514,7 @@ func TestLivezServer(t *testing.T) { tracking503: 0, } - testProxierHealthUpdater(hs, hsTest, fakeClock, t) + testProxyHealthUpdater(hs, hsTest, fakeClock, t) // Should return 200 "OK" irrespective of node syncs hs.SyncNode(makeNode(tweakTainted("other"))) @@ -540,7 +540,7 @@ var ( livezURL url = "/livez" ) -func testProxierHealthUpdater(hs *ProxierHealthServer, hsTest *serverTest, fakeClock *testingclock.FakeClock, t *testing.T) { +func testProxyHealthUpdater(hs *ProxyHealthServer, hsTest *serverTest, fakeClock *testingclock.FakeClock, t *testing.T) { // Should return 200 "OK" by default. testHTTPHandler(hsTest, http.StatusOK, t) @@ -659,7 +659,7 @@ func testMetricEquals(metric basemetrics.CounterMetric, expected float64, t *tes func TestServerWithSelectiveListeningAddress(t *testing.T) { listener := newFakeListener() httpFactory := newFakeHTTPServerFactory() - proxyChecker := &fakeProxierHealthChecker{true} + proxyChecker := &fakeProxyHealthChecker{true} // limiting addresses to loop back. We don't want any cleverness here around getting IP for // machine nor testing ipv6 || ipv4. using loop back guarantees the test will work on any machine diff --git a/pkg/proxy/healthcheck/proxier_health.go b/pkg/proxy/healthcheck/proxier_health.go index a76437189bd..9fbe4fc0331 100644 --- a/pkg/proxy/healthcheck/proxier_health.go +++ b/pkg/proxy/healthcheck/proxier_health.go @@ -35,14 +35,14 @@ const ( ToBeDeletedTaint = "ToBeDeletedByClusterAutoscaler" ) -// ProxierHealthServer allows callers to: +// ProxyHealthServer allows callers to: // 1. run a http server with /healthz and /livez endpoint handlers. // 2. update healthz timestamps before and after synchronizing dataplane. // 3. sync node status, for reporting unhealthy /healthz response // if the node is marked for deletion by autoscaler. // 4. get proxy health by verifying that the delay between QueuedUpdate() // calls and Updated() calls exceeded healthTimeout or not. -type ProxierHealthServer struct { +type ProxyHealthServer struct { listener listener httpFactory httpServerFactory clock clock.Clock @@ -56,13 +56,13 @@ type ProxierHealthServer struct { nodeEligible bool } -// NewProxierHealthServer returns a proxier health http server. -func NewProxierHealthServer(addr string, healthTimeout time.Duration) *ProxierHealthServer { - return newProxierHealthServer(stdNetListener{}, stdHTTPServerFactory{}, clock.RealClock{}, addr, healthTimeout) +// NewProxyHealthServer returns a proxy health http server. +func NewProxyHealthServer(addr string, healthTimeout time.Duration) *ProxyHealthServer { + return newProxyHealthServer(stdNetListener{}, stdHTTPServerFactory{}, clock.RealClock{}, addr, healthTimeout) } -func newProxierHealthServer(listener listener, httpServerFactory httpServerFactory, c clock.Clock, addr string, healthTimeout time.Duration) *ProxierHealthServer { - return &ProxierHealthServer{ +func newProxyHealthServer(listener listener, httpServerFactory httpServerFactory, c clock.Clock, addr string, healthTimeout time.Duration) *ProxyHealthServer { + return &ProxyHealthServer{ listener: listener, httpFactory: httpServerFactory, clock: c, @@ -80,7 +80,7 @@ func newProxierHealthServer(listener listener, httpServerFactory httpServerFacto // Updated should be called when the proxier of the given IP family has successfully updated // the service rules to reflect the current state and should be considered healthy now. -func (hs *ProxierHealthServer) Updated(ipFamily v1.IPFamily) { +func (hs *ProxyHealthServer) Updated(ipFamily v1.IPFamily) { hs.lock.Lock() defer hs.lock.Unlock() delete(hs.oldestPendingQueuedMap, ipFamily) @@ -92,7 +92,7 @@ func (hs *ProxierHealthServer) Updated(ipFamily v1.IPFamily) { // indicates that the proxier for the given IP family has received changes but has not // yet pushed them to its backend. If the proxier does not call Updated within the // healthTimeout time then it will be considered unhealthy. -func (hs *ProxierHealthServer) QueuedUpdate(ipFamily v1.IPFamily) { +func (hs *ProxyHealthServer) QueuedUpdate(ipFamily v1.IPFamily) { hs.lock.Lock() defer hs.lock.Unlock() // Set oldestPendingQueuedMap[ipFamily] only if it's currently unset @@ -103,12 +103,12 @@ func (hs *ProxierHealthServer) QueuedUpdate(ipFamily v1.IPFamily) { // IsHealthy returns only the proxier's health state, following the same // definition the HTTP server defines, but ignoring the state of the Node. -func (hs *ProxierHealthServer) IsHealthy() bool { +func (hs *ProxyHealthServer) IsHealthy() bool { isHealthy, _ := hs.isHealthy() return isHealthy } -func (hs *ProxierHealthServer) isHealthy() (bool, time.Time) { +func (hs *ProxyHealthServer) isHealthy() (bool, time.Time) { hs.lock.RLock() defer hs.lock.RUnlock() @@ -138,7 +138,7 @@ func (hs *ProxierHealthServer) isHealthy() (bool, time.Time) { // SyncNode syncs the node and determines if it is eligible or not. Eligible is // defined as being: not tainted by ToBeDeletedTaint and not deleted. -func (hs *ProxierHealthServer) SyncNode(node *v1.Node) { +func (hs *ProxyHealthServer) SyncNode(node *v1.Node) { hs.lock.Lock() defer hs.lock.Unlock() @@ -155,15 +155,15 @@ func (hs *ProxierHealthServer) SyncNode(node *v1.Node) { hs.nodeEligible = true } -// NodeEligible returns nodeEligible field of ProxierHealthServer. -func (hs *ProxierHealthServer) NodeEligible() bool { +// NodeEligible returns nodeEligible field of ProxyHealthServer. +func (hs *ProxyHealthServer) NodeEligible() bool { hs.lock.RLock() defer hs.lock.RUnlock() return hs.nodeEligible } // Run starts the healthz HTTP server and blocks until it exits. -func (hs *ProxierHealthServer) Run(ctx context.Context) error { +func (hs *ProxyHealthServer) Run(ctx context.Context) error { serveMux := http.NewServeMux() serveMux.Handle("/healthz", healthzHandler{hs: hs}) serveMux.Handle("/livez", livezHandler{hs: hs}) @@ -171,19 +171,19 @@ func (hs *ProxierHealthServer) Run(ctx context.Context) error { listener, err := hs.listener.Listen(ctx, hs.addr) if err != nil { - return fmt.Errorf("failed to start proxier healthz on %s: %v", hs.addr, err) + return fmt.Errorf("failed to start proxy healthz on %s: %v", hs.addr, err) } klog.V(3).InfoS("Starting healthz HTTP server", "address", hs.addr) if err := server.Serve(listener); err != nil { - return fmt.Errorf("proxier healthz closed with error: %v", err) + return fmt.Errorf("proxy healthz closed with error: %v", err) } return nil } type healthzHandler struct { - hs *ProxierHealthServer + hs *ProxyHealthServer } func (h healthzHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request) { @@ -211,7 +211,7 @@ func (h healthzHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request) { } type livezHandler struct { - hs *ProxierHealthServer + hs *ProxyHealthServer } func (h livezHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request) { diff --git a/pkg/proxy/healthcheck/service_health.go b/pkg/proxy/healthcheck/service_health.go index 44eb8b687cf..e0894aae98a 100644 --- a/pkg/proxy/healthcheck/service_health.go +++ b/pkg/proxy/healthcheck/service_health.go @@ -52,13 +52,13 @@ type ServiceHealthServer interface { SyncEndpoints(newEndpoints map[types.NamespacedName]int) error } -type proxierHealthChecker interface { - // IsHealthy returns the proxier's health state, following the same +type proxyHealthChecker interface { + // IsHealthy returns the proxy's health state, following the same // definition the HTTP server defines. IsHealthy() bool } -func newServiceHealthServer(hostname string, recorder events.EventRecorder, listener listener, factory httpServerFactory, nodePortAddresses *proxyutil.NodePortAddresses, healthzServer proxierHealthChecker) ServiceHealthServer { +func newServiceHealthServer(hostname 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} @@ -84,7 +84,7 @@ 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 proxierHealthChecker) ServiceHealthServer { +func NewServiceHealthServer(hostname string, recorder events.EventRecorder, nodePortAddresses *proxyutil.NodePortAddresses, healthzServer proxyHealthChecker) ServiceHealthServer { return newServiceHealthServer(hostname, recorder, stdNetListener{}, stdHTTPServerFactory{}, nodePortAddresses, healthzServer) } @@ -96,7 +96,7 @@ type server struct { listener listener httpFactory httpServerFactory - healthzServer proxierHealthChecker + healthzServer proxyHealthChecker lock sync.RWMutex services map[types.NamespacedName]*hcInstance diff --git a/pkg/proxy/iptables/proxier.go b/pkg/proxy/iptables/proxier.go index da61d131248..5ce65a618de 100644 --- a/pkg/proxy/iptables/proxier.go +++ b/pkg/proxy/iptables/proxier.go @@ -111,7 +111,7 @@ func NewDualStackProxier( hostname string, nodeIPs map[v1.IPFamily]net.IP, recorder events.EventRecorder, - healthzServer *healthcheck.ProxierHealthServer, + healthzServer *healthcheck.ProxyHealthServer, nodePortAddresses []string, initOnly bool, ) (proxy.Provider, error) { @@ -177,7 +177,7 @@ type Proxier struct { recorder events.EventRecorder serviceHealthServer healthcheck.ServiceHealthServer - healthzServer *healthcheck.ProxierHealthServer + healthzServer *healthcheck.ProxyHealthServer // Since converting probabilities (floats) to strings is expensive // and we are using only probabilities in the format of 1/n, we are @@ -239,7 +239,7 @@ func NewProxier(ctx context.Context, hostname string, nodeIP net.IP, recorder events.EventRecorder, - healthzServer *healthcheck.ProxierHealthServer, + healthzServer *healthcheck.ProxyHealthServer, nodePortAddressStrings []string, initOnly bool, ) (*Proxier, error) { diff --git a/pkg/proxy/ipvs/proxier.go b/pkg/proxy/ipvs/proxier.go index b3d0dd4f81b..11ec8c8d0d5 100644 --- a/pkg/proxy/ipvs/proxier.go +++ b/pkg/proxy/ipvs/proxier.go @@ -130,7 +130,7 @@ func NewDualStackProxier( hostname string, nodeIPs map[v1.IPFamily]net.IP, recorder events.EventRecorder, - healthzServer *healthcheck.ProxierHealthServer, + healthzServer *healthcheck.ProxyHealthServer, scheduler string, nodePortAddresses []string, initOnly bool, @@ -212,7 +212,7 @@ type Proxier struct { recorder events.EventRecorder serviceHealthServer healthcheck.ServiceHealthServer - healthzServer *healthcheck.ProxierHealthServer + healthzServer *healthcheck.ProxyHealthServer ipvsScheduler string // The following buffers are used to reuse memory and avoid allocations @@ -285,7 +285,7 @@ func NewProxier( hostname string, nodeIP net.IP, recorder events.EventRecorder, - healthzServer *healthcheck.ProxierHealthServer, + healthzServer *healthcheck.ProxyHealthServer, scheduler string, nodePortAddressStrings []string, initOnly bool, diff --git a/pkg/proxy/nftables/proxier.go b/pkg/proxy/nftables/proxier.go index db993dab5ad..2076bd8f7e3 100644 --- a/pkg/proxy/nftables/proxier.go +++ b/pkg/proxy/nftables/proxier.go @@ -116,7 +116,7 @@ func NewDualStackProxier( hostname string, nodeIPs map[v1.IPFamily]net.IP, recorder events.EventRecorder, - healthzServer *healthcheck.ProxierHealthServer, + healthzServer *healthcheck.ProxyHealthServer, nodePortAddresses []string, initOnly bool, ) (proxy.Provider, error) { @@ -180,7 +180,7 @@ type Proxier struct { recorder events.EventRecorder serviceHealthServer healthcheck.ServiceHealthServer - healthzServer *healthcheck.ProxierHealthServer + healthzServer *healthcheck.ProxyHealthServer // nodePortAddresses selects the interfaces where nodePort works. nodePortAddresses *proxyutil.NodePortAddresses @@ -222,7 +222,7 @@ func NewProxier(ctx context.Context, hostname string, nodeIP net.IP, recorder events.EventRecorder, - healthzServer *healthcheck.ProxierHealthServer, + healthzServer *healthcheck.ProxyHealthServer, nodePortAddressStrings []string, initOnly bool, ) (*Proxier, error) { diff --git a/pkg/proxy/node.go b/pkg/proxy/node.go index 0de896710c4..db92508fb4b 100644 --- a/pkg/proxy/node.go +++ b/pkg/proxy/node.go @@ -93,7 +93,7 @@ func (n *NodePodCIDRHandler) OnNodeSynced() {} // NodeEligibleHandler handles the life cycle of the Node's eligibility, as // determined by the health server for directing load balancer traffic. type NodeEligibleHandler struct { - HealthServer *healthcheck.ProxierHealthServer + HealthServer *healthcheck.ProxyHealthServer } var _ config.NodeHandler = &NodeEligibleHandler{} diff --git a/pkg/proxy/winkernel/proxier.go b/pkg/proxy/winkernel/proxier.go index fbd3562e6fa..6b0c9de13f7 100644 --- a/pkg/proxy/winkernel/proxier.go +++ b/pkg/proxy/winkernel/proxier.go @@ -620,7 +620,7 @@ type Proxier struct { recorder events.EventRecorder serviceHealthServer healthcheck.ServiceHealthServer - healthzServer *healthcheck.ProxierHealthServer + healthzServer *healthcheck.ProxyHealthServer hns HostNetworkService hcn HcnService @@ -676,7 +676,7 @@ func NewProxier( hostname string, nodeIP net.IP, recorder events.EventRecorder, - healthzServer *healthcheck.ProxierHealthServer, + healthzServer *healthcheck.ProxyHealthServer, healthzBindAddress string, config config.KubeProxyWinkernelConfiguration, ) (*Proxier, error) { @@ -813,7 +813,7 @@ func NewDualStackProxier( hostname string, nodeIPs map[v1.IPFamily]net.IP, recorder events.EventRecorder, - healthzServer *healthcheck.ProxierHealthServer, + healthzServer *healthcheck.ProxyHealthServer, healthzBindAddress string, config config.KubeProxyWinkernelConfiguration, ) (proxy.Provider, error) {