Skip to content

Commit d6c5755

Browse files
committed
pkg/proxy/healthcheck: rename 'proxier' to 'proxy'
KubeProxy operates with a single health server and two proxies, one for each IP family. The use of the term 'proxier' in the types and functions within pkg/proxy/healthcheck can be misleading, as it may suggest the existence of two health servers, one for each IP family. Signed-off-by: Daman Arora <[email protected]>
1 parent 9709d36 commit d6c5755

File tree

10 files changed

+52
-52
lines changed

10 files changed

+52
-52
lines changed

cmd/kube-proxy/app/server.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ type ProxyServer struct {
159159
Broadcaster events.EventBroadcaster
160160
Recorder events.EventRecorder
161161
NodeRef *v1.ObjectReference
162-
HealthzServer *healthcheck.ProxierHealthServer
162+
HealthzServer *healthcheck.ProxyHealthServer
163163
Hostname string
164164
PrimaryIPFamily v1.IPFamily
165165
NodeIPs map[v1.IPFamily]net.IP
@@ -224,7 +224,7 @@ func newProxyServer(ctx context.Context, config *kubeproxyconfig.KubeProxyConfig
224224
}
225225

226226
if len(config.HealthzBindAddress) > 0 {
227-
s.HealthzServer = healthcheck.NewProxierHealthServer(config.HealthzBindAddress, 2*config.SyncPeriod.Duration)
227+
s.HealthzServer = healthcheck.NewProxyHealthServer(config.HealthzBindAddress, 2*config.SyncPeriod.Duration)
228228
}
229229

230230
err = s.platformSetup(ctx)
@@ -415,7 +415,7 @@ func createClient(ctx context.Context, config componentbaseconfig.ClientConnecti
415415
return client, nil
416416
}
417417

418-
func serveHealthz(ctx context.Context, hz *healthcheck.ProxierHealthServer, errCh chan error) {
418+
func serveHealthz(ctx context.Context, hz *healthcheck.ProxyHealthServer, errCh chan error) {
419419
logger := klog.FromContext(ctx)
420420
if hz == nil {
421421
return

pkg/proxy/healthcheck/common.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,21 @@ import (
2424
netutils "k8s.io/utils/net"
2525
)
2626

27-
// listener allows for testing of ServiceHealthServer and ProxierHealthServer.
27+
// listener allows for testing of ServiceHealthServer and ProxyHealthServer.
2828
type listener interface {
2929
// Listen is very much like netutils.MultiListen, except the second arg (network) is
3030
// fixed to be "tcp".
3131
Listen(ctx context.Context, addrs ...string) (net.Listener, error)
3232
}
3333

34-
// httpServerFactory allows for testing of ServiceHealthServer and ProxierHealthServer.
34+
// httpServerFactory allows for testing of ServiceHealthServer and ProxyHealthServer.
3535
type httpServerFactory interface {
3636
// New creates an instance of a type satisfying HTTPServer. This is
3737
// designed to include http.Server.
3838
New(handler http.Handler) httpServer
3939
}
4040

41-
// httpServer allows for testing of ServiceHealthServer and ProxierHealthServer.
41+
// httpServer allows for testing of ServiceHealthServer and ProxyHealthServer.
4242
// It is designed so that http.Server satisfies this interface,
4343
type httpServer interface {
4444
Serve(listener net.Listener) error

pkg/proxy/healthcheck/healthcheck_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,19 +138,19 @@ type healthzPayload struct {
138138
NodeHealthy bool
139139
}
140140

141-
type fakeProxierHealthChecker struct {
141+
type fakeProxyHealthChecker struct {
142142
healthy bool
143143
}
144144

145-
func (fake fakeProxierHealthChecker) IsHealthy() bool {
145+
func (fake fakeProxyHealthChecker) IsHealthy() bool {
146146
return fake.healthy
147147
}
148148

149149
func TestServer(t *testing.T) {
150150
listener := newFakeListener()
151151
httpFactory := newFakeHTTPServerFactory()
152152
nodePortAddresses := proxyutil.NewNodePortAddresses(v1.IPv4Protocol, []string{})
153-
proxyChecker := &fakeProxierHealthChecker{true}
153+
proxyChecker := &fakeProxyHealthChecker{true}
154154

155155
hcsi := newServiceHealthServer("hostname", nil, listener, httpFactory, nodePortAddresses, proxyChecker)
156156
hcs := hcsi.(*server)
@@ -469,7 +469,7 @@ func TestHealthzServer(t *testing.T) {
469469
httpFactory := newFakeHTTPServerFactory()
470470
fakeClock := testingclock.NewFakeClock(time.Now())
471471

472-
hs := newProxierHealthServer(listener, httpFactory, fakeClock, "127.0.0.1:10256", 10*time.Second)
472+
hs := newProxyHealthServer(listener, httpFactory, fakeClock, "127.0.0.1:10256", 10*time.Second)
473473
server := hs.httpFactory.New(healthzHandler{hs: hs})
474474

475475
hsTest := &serverTest{
@@ -479,7 +479,7 @@ func TestHealthzServer(t *testing.T) {
479479
tracking503: 0,
480480
}
481481

482-
testProxierHealthUpdater(hs, hsTest, fakeClock, t)
482+
testProxyHealthUpdater(hs, hsTest, fakeClock, t)
483483

484484
// Should return 200 "OK" if we've synced a node, tainted in any other way
485485
hs.SyncNode(makeNode(tweakTainted("other")))
@@ -504,7 +504,7 @@ func TestLivezServer(t *testing.T) {
504504
httpFactory := newFakeHTTPServerFactory()
505505
fakeClock := testingclock.NewFakeClock(time.Now())
506506

507-
hs := newProxierHealthServer(listener, httpFactory, fakeClock, "127.0.0.1:10256", 10*time.Second)
507+
hs := newProxyHealthServer(listener, httpFactory, fakeClock, "127.0.0.1:10256", 10*time.Second)
508508
server := hs.httpFactory.New(livezHandler{hs: hs})
509509

510510
hsTest := &serverTest{
@@ -514,7 +514,7 @@ func TestLivezServer(t *testing.T) {
514514
tracking503: 0,
515515
}
516516

517-
testProxierHealthUpdater(hs, hsTest, fakeClock, t)
517+
testProxyHealthUpdater(hs, hsTest, fakeClock, t)
518518

519519
// Should return 200 "OK" irrespective of node syncs
520520
hs.SyncNode(makeNode(tweakTainted("other")))
@@ -540,7 +540,7 @@ var (
540540
livezURL url = "/livez"
541541
)
542542

543-
func testProxierHealthUpdater(hs *ProxierHealthServer, hsTest *serverTest, fakeClock *testingclock.FakeClock, t *testing.T) {
543+
func testProxyHealthUpdater(hs *ProxyHealthServer, hsTest *serverTest, fakeClock *testingclock.FakeClock, t *testing.T) {
544544
// Should return 200 "OK" by default.
545545
testHTTPHandler(hsTest, http.StatusOK, t)
546546

@@ -659,7 +659,7 @@ func testMetricEquals(metric basemetrics.CounterMetric, expected float64, t *tes
659659
func TestServerWithSelectiveListeningAddress(t *testing.T) {
660660
listener := newFakeListener()
661661
httpFactory := newFakeHTTPServerFactory()
662-
proxyChecker := &fakeProxierHealthChecker{true}
662+
proxyChecker := &fakeProxyHealthChecker{true}
663663

664664
// limiting addresses to loop back. We don't want any cleverness here around getting IP for
665665
// machine nor testing ipv6 || ipv4. using loop back guarantees the test will work on any machine

pkg/proxy/healthcheck/proxier_health.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ const (
3535
ToBeDeletedTaint = "ToBeDeletedByClusterAutoscaler"
3636
)
3737

38-
// ProxierHealthServer allows callers to:
38+
// ProxyHealthServer allows callers to:
3939
// 1. run a http server with /healthz and /livez endpoint handlers.
4040
// 2. update healthz timestamps before and after synchronizing dataplane.
4141
// 3. sync node status, for reporting unhealthy /healthz response
4242
// if the node is marked for deletion by autoscaler.
4343
// 4. get proxy health by verifying that the delay between QueuedUpdate()
4444
// calls and Updated() calls exceeded healthTimeout or not.
45-
type ProxierHealthServer struct {
45+
type ProxyHealthServer struct {
4646
listener listener
4747
httpFactory httpServerFactory
4848
clock clock.Clock
@@ -56,13 +56,13 @@ type ProxierHealthServer struct {
5656
nodeEligible bool
5757
}
5858

59-
// NewProxierHealthServer returns a proxier health http server.
60-
func NewProxierHealthServer(addr string, healthTimeout time.Duration) *ProxierHealthServer {
61-
return newProxierHealthServer(stdNetListener{}, stdHTTPServerFactory{}, clock.RealClock{}, addr, healthTimeout)
59+
// NewProxyHealthServer returns a proxy health http server.
60+
func NewProxyHealthServer(addr string, healthTimeout time.Duration) *ProxyHealthServer {
61+
return newProxyHealthServer(stdNetListener{}, stdHTTPServerFactory{}, clock.RealClock{}, addr, healthTimeout)
6262
}
6363

64-
func newProxierHealthServer(listener listener, httpServerFactory httpServerFactory, c clock.Clock, addr string, healthTimeout time.Duration) *ProxierHealthServer {
65-
return &ProxierHealthServer{
64+
func newProxyHealthServer(listener listener, httpServerFactory httpServerFactory, c clock.Clock, addr string, healthTimeout time.Duration) *ProxyHealthServer {
65+
return &ProxyHealthServer{
6666
listener: listener,
6767
httpFactory: httpServerFactory,
6868
clock: c,
@@ -80,7 +80,7 @@ func newProxierHealthServer(listener listener, httpServerFactory httpServerFacto
8080

8181
// Updated should be called when the proxier of the given IP family has successfully updated
8282
// the service rules to reflect the current state and should be considered healthy now.
83-
func (hs *ProxierHealthServer) Updated(ipFamily v1.IPFamily) {
83+
func (hs *ProxyHealthServer) Updated(ipFamily v1.IPFamily) {
8484
hs.lock.Lock()
8585
defer hs.lock.Unlock()
8686
delete(hs.oldestPendingQueuedMap, ipFamily)
@@ -92,7 +92,7 @@ func (hs *ProxierHealthServer) Updated(ipFamily v1.IPFamily) {
9292
// indicates that the proxier for the given IP family has received changes but has not
9393
// yet pushed them to its backend. If the proxier does not call Updated within the
9494
// healthTimeout time then it will be considered unhealthy.
95-
func (hs *ProxierHealthServer) QueuedUpdate(ipFamily v1.IPFamily) {
95+
func (hs *ProxyHealthServer) QueuedUpdate(ipFamily v1.IPFamily) {
9696
hs.lock.Lock()
9797
defer hs.lock.Unlock()
9898
// Set oldestPendingQueuedMap[ipFamily] only if it's currently unset
@@ -103,12 +103,12 @@ func (hs *ProxierHealthServer) QueuedUpdate(ipFamily v1.IPFamily) {
103103

104104
// IsHealthy returns only the proxier's health state, following the same
105105
// definition the HTTP server defines, but ignoring the state of the Node.
106-
func (hs *ProxierHealthServer) IsHealthy() bool {
106+
func (hs *ProxyHealthServer) IsHealthy() bool {
107107
isHealthy, _ := hs.isHealthy()
108108
return isHealthy
109109
}
110110

111-
func (hs *ProxierHealthServer) isHealthy() (bool, time.Time) {
111+
func (hs *ProxyHealthServer) isHealthy() (bool, time.Time) {
112112
hs.lock.RLock()
113113
defer hs.lock.RUnlock()
114114

@@ -138,7 +138,7 @@ func (hs *ProxierHealthServer) isHealthy() (bool, time.Time) {
138138

139139
// SyncNode syncs the node and determines if it is eligible or not. Eligible is
140140
// defined as being: not tainted by ToBeDeletedTaint and not deleted.
141-
func (hs *ProxierHealthServer) SyncNode(node *v1.Node) {
141+
func (hs *ProxyHealthServer) SyncNode(node *v1.Node) {
142142
hs.lock.Lock()
143143
defer hs.lock.Unlock()
144144

@@ -155,35 +155,35 @@ func (hs *ProxierHealthServer) SyncNode(node *v1.Node) {
155155
hs.nodeEligible = true
156156
}
157157

158-
// NodeEligible returns nodeEligible field of ProxierHealthServer.
159-
func (hs *ProxierHealthServer) NodeEligible() bool {
158+
// NodeEligible returns nodeEligible field of ProxyHealthServer.
159+
func (hs *ProxyHealthServer) NodeEligible() bool {
160160
hs.lock.RLock()
161161
defer hs.lock.RUnlock()
162162
return hs.nodeEligible
163163
}
164164

165165
// Run starts the healthz HTTP server and blocks until it exits.
166-
func (hs *ProxierHealthServer) Run(ctx context.Context) error {
166+
func (hs *ProxyHealthServer) Run(ctx context.Context) error {
167167
serveMux := http.NewServeMux()
168168
serveMux.Handle("/healthz", healthzHandler{hs: hs})
169169
serveMux.Handle("/livez", livezHandler{hs: hs})
170170
server := hs.httpFactory.New(serveMux)
171171

172172
listener, err := hs.listener.Listen(ctx, hs.addr)
173173
if err != nil {
174-
return fmt.Errorf("failed to start proxier healthz on %s: %v", hs.addr, err)
174+
return fmt.Errorf("failed to start proxy healthz on %s: %v", hs.addr, err)
175175
}
176176

177177
klog.V(3).InfoS("Starting healthz HTTP server", "address", hs.addr)
178178

179179
if err := server.Serve(listener); err != nil {
180-
return fmt.Errorf("proxier healthz closed with error: %v", err)
180+
return fmt.Errorf("proxy healthz closed with error: %v", err)
181181
}
182182
return nil
183183
}
184184

185185
type healthzHandler struct {
186-
hs *ProxierHealthServer
186+
hs *ProxyHealthServer
187187
}
188188

189189
func (h healthzHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
@@ -211,7 +211,7 @@ func (h healthzHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
211211
}
212212

213213
type livezHandler struct {
214-
hs *ProxierHealthServer
214+
hs *ProxyHealthServer
215215
}
216216

217217
func (h livezHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request) {

pkg/proxy/healthcheck/service_health.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ type ServiceHealthServer interface {
5252
SyncEndpoints(newEndpoints map[types.NamespacedName]int) error
5353
}
5454

55-
type proxierHealthChecker interface {
56-
// IsHealthy returns the proxier's health state, following the same
55+
type proxyHealthChecker interface {
56+
// IsHealthy returns the proxy's health state, following the same
5757
// definition the HTTP server defines.
5858
IsHealthy() bool
5959
}
6060

61-
func newServiceHealthServer(hostname string, recorder events.EventRecorder, listener listener, factory httpServerFactory, nodePortAddresses *proxyutil.NodePortAddresses, healthzServer proxierHealthChecker) ServiceHealthServer {
61+
func newServiceHealthServer(hostname string, recorder events.EventRecorder, listener listener, factory httpServerFactory, nodePortAddresses *proxyutil.NodePortAddresses, healthzServer proxyHealthChecker) ServiceHealthServer {
6262
// It doesn't matter whether we listen on "0.0.0.0", "::", or ""; go
6363
// treats them all the same.
6464
nodeIPs := []net.IP{net.IPv4zero}
@@ -84,7 +84,7 @@ func newServiceHealthServer(hostname string, recorder events.EventRecorder, list
8484
}
8585

8686
// NewServiceHealthServer allocates a new service healthcheck server manager
87-
func NewServiceHealthServer(hostname string, recorder events.EventRecorder, nodePortAddresses *proxyutil.NodePortAddresses, healthzServer proxierHealthChecker) ServiceHealthServer {
87+
func NewServiceHealthServer(hostname string, recorder events.EventRecorder, nodePortAddresses *proxyutil.NodePortAddresses, healthzServer proxyHealthChecker) ServiceHealthServer {
8888
return newServiceHealthServer(hostname, recorder, stdNetListener{}, stdHTTPServerFactory{}, nodePortAddresses, healthzServer)
8989
}
9090

@@ -96,7 +96,7 @@ type server struct {
9696
listener listener
9797
httpFactory httpServerFactory
9898

99-
healthzServer proxierHealthChecker
99+
healthzServer proxyHealthChecker
100100

101101
lock sync.RWMutex
102102
services map[types.NamespacedName]*hcInstance

pkg/proxy/iptables/proxier.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func NewDualStackProxier(
111111
hostname string,
112112
nodeIPs map[v1.IPFamily]net.IP,
113113
recorder events.EventRecorder,
114-
healthzServer *healthcheck.ProxierHealthServer,
114+
healthzServer *healthcheck.ProxyHealthServer,
115115
nodePortAddresses []string,
116116
initOnly bool,
117117
) (proxy.Provider, error) {
@@ -177,7 +177,7 @@ type Proxier struct {
177177
recorder events.EventRecorder
178178

179179
serviceHealthServer healthcheck.ServiceHealthServer
180-
healthzServer *healthcheck.ProxierHealthServer
180+
healthzServer *healthcheck.ProxyHealthServer
181181

182182
// Since converting probabilities (floats) to strings is expensive
183183
// and we are using only probabilities in the format of 1/n, we are
@@ -239,7 +239,7 @@ func NewProxier(ctx context.Context,
239239
hostname string,
240240
nodeIP net.IP,
241241
recorder events.EventRecorder,
242-
healthzServer *healthcheck.ProxierHealthServer,
242+
healthzServer *healthcheck.ProxyHealthServer,
243243
nodePortAddressStrings []string,
244244
initOnly bool,
245245
) (*Proxier, error) {

pkg/proxy/ipvs/proxier.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func NewDualStackProxier(
130130
hostname string,
131131
nodeIPs map[v1.IPFamily]net.IP,
132132
recorder events.EventRecorder,
133-
healthzServer *healthcheck.ProxierHealthServer,
133+
healthzServer *healthcheck.ProxyHealthServer,
134134
scheduler string,
135135
nodePortAddresses []string,
136136
initOnly bool,
@@ -212,7 +212,7 @@ type Proxier struct {
212212
recorder events.EventRecorder
213213

214214
serviceHealthServer healthcheck.ServiceHealthServer
215-
healthzServer *healthcheck.ProxierHealthServer
215+
healthzServer *healthcheck.ProxyHealthServer
216216

217217
ipvsScheduler string
218218
// The following buffers are used to reuse memory and avoid allocations
@@ -285,7 +285,7 @@ func NewProxier(
285285
hostname string,
286286
nodeIP net.IP,
287287
recorder events.EventRecorder,
288-
healthzServer *healthcheck.ProxierHealthServer,
288+
healthzServer *healthcheck.ProxyHealthServer,
289289
scheduler string,
290290
nodePortAddressStrings []string,
291291
initOnly bool,

pkg/proxy/nftables/proxier.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func NewDualStackProxier(
116116
hostname string,
117117
nodeIPs map[v1.IPFamily]net.IP,
118118
recorder events.EventRecorder,
119-
healthzServer *healthcheck.ProxierHealthServer,
119+
healthzServer *healthcheck.ProxyHealthServer,
120120
nodePortAddresses []string,
121121
initOnly bool,
122122
) (proxy.Provider, error) {
@@ -180,7 +180,7 @@ type Proxier struct {
180180
recorder events.EventRecorder
181181

182182
serviceHealthServer healthcheck.ServiceHealthServer
183-
healthzServer *healthcheck.ProxierHealthServer
183+
healthzServer *healthcheck.ProxyHealthServer
184184

185185
// nodePortAddresses selects the interfaces where nodePort works.
186186
nodePortAddresses *proxyutil.NodePortAddresses
@@ -222,7 +222,7 @@ func NewProxier(ctx context.Context,
222222
hostname string,
223223
nodeIP net.IP,
224224
recorder events.EventRecorder,
225-
healthzServer *healthcheck.ProxierHealthServer,
225+
healthzServer *healthcheck.ProxyHealthServer,
226226
nodePortAddressStrings []string,
227227
initOnly bool,
228228
) (*Proxier, error) {

pkg/proxy/node.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func (n *NodePodCIDRHandler) OnNodeSynced() {}
9393
// NodeEligibleHandler handles the life cycle of the Node's eligibility, as
9494
// determined by the health server for directing load balancer traffic.
9595
type NodeEligibleHandler struct {
96-
HealthServer *healthcheck.ProxierHealthServer
96+
HealthServer *healthcheck.ProxyHealthServer
9797
}
9898

9999
var _ config.NodeHandler = &NodeEligibleHandler{}

0 commit comments

Comments
 (0)