Skip to content

Commit 8dea331

Browse files
authored
Merge pull request kubernetes#81376 from logicalhan/health-checks
rename healthz methodNames to be more consistent w/ present day usages
2 parents c008cf9 + 2e23788 commit 8dea331

File tree

15 files changed

+60
-60
lines changed

15 files changed

+60
-60
lines changed

cmd/cloud-controller-manager/app/controllermanager.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ func Run(c *cloudcontrollerconfig.CompletedConfig, stopCh <-chan struct{}) error
139139
klog.Errorf("unable to register configz: %v", err)
140140
}
141141

142-
// Setup any healthz checks we will want to use.
143-
var checks []healthz.HealthzChecker
142+
// Setup any health checks we will want to use.
143+
var checks []healthz.HealthChecker
144144
var electionChecker *leaderelection.HealthzAdaptor
145145
if c.ComponentConfig.Generic.LeaderElection.LeaderElect {
146146
electionChecker = leaderelection.NewLeaderHealthzAdaptor(time.Second * 20)

cmd/controller-manager/app/serve.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func BuildHandlerChain(apiHandler http.Handler, authorizationInfo *apiserver.Aut
5252
}
5353

5454
// NewBaseHandler takes in CompletedConfig and returns a handler.
55-
func NewBaseHandler(c *componentbaseconfig.DebuggingConfiguration, checks ...healthz.HealthzChecker) *mux.PathRecorderMux {
55+
func NewBaseHandler(c *componentbaseconfig.DebuggingConfiguration, checks ...healthz.HealthChecker) *mux.PathRecorderMux {
5656
mux := mux.NewPathRecorderMux("controller-manager")
5757
healthz.InstallHandler(mux, checks...)
5858
if c.EnableProfiling {

cmd/kube-apiserver/app/aggregator.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ func createAggregatorServer(aggregatorConfig *aggregatorapiserver.Config, delega
153153
return nil, err
154154
}
155155

156-
err = aggregatorServer.GenericAPIServer.AddHealthzChecks(
157-
makeAPIServiceAvailableHealthzCheck(
156+
err = aggregatorServer.GenericAPIServer.AddHealthChecks(
157+
makeAPIServiceAvailableHealthCheck(
158158
"autoregister-completion",
159159
apiServices,
160160
aggregatorServer.APIRegistrationInformers.Apiregistration().V1().APIServices(),
@@ -186,9 +186,9 @@ func makeAPIService(gv schema.GroupVersion) *v1.APIService {
186186
}
187187
}
188188

189-
// makeAPIServiceAvailableHealthzCheck returns a healthz check that returns healthy
189+
// makeAPIServiceAvailableHealthCheck returns a healthz check that returns healthy
190190
// once all of the specified services have been observed to be available at least once.
191-
func makeAPIServiceAvailableHealthzCheck(name string, apiServices []*v1.APIService, apiServiceInformer informers.APIServiceInformer) healthz.HealthzChecker {
191+
func makeAPIServiceAvailableHealthCheck(name string, apiServices []*v1.APIService, apiServiceInformer informers.APIServiceInformer) healthz.HealthChecker {
192192
// Track the auto-registered API services that have not been observed to be available yet
193193
pendingServiceNamesLock := &sync.RWMutex{}
194194
pendingServiceNames := sets.NewString()

cmd/kube-apiserver/app/testing/testserver.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ type TestServerInstanceOptions struct {
4747
// DisableStorageCleanup Disable the automatic storage cleanup
4848
DisableStorageCleanup bool
4949
// Injected health
50-
InjectedHealthzChecker healthz.HealthzChecker
50+
InjectedHealthChecker healthz.HealthChecker
5151
}
5252

5353
// TestServer return values supplied by kube-test-ApiServer
@@ -151,9 +151,9 @@ func StartTestServer(t Logger, instanceOptions *TestServerInstanceOptions, custo
151151
return result, fmt.Errorf("failed to create server chain: %v", err)
152152
}
153153

154-
if instanceOptions.InjectedHealthzChecker != nil {
155-
t.Logf("Adding health check with delay %v %v", s.GenericServerRunOptions.MaxStartupSequenceDuration, instanceOptions.InjectedHealthzChecker.Name())
156-
if err := server.GenericAPIServer.AddDelayedHealthzChecks(s.GenericServerRunOptions.MaxStartupSequenceDuration, instanceOptions.InjectedHealthzChecker); err != nil {
154+
if instanceOptions.InjectedHealthChecker != nil {
155+
t.Logf("Adding health check with delay %v %v", s.GenericServerRunOptions.MaxStartupSequenceDuration, instanceOptions.InjectedHealthChecker.Name())
156+
if err := server.GenericAPIServer.AddDelayedHealthzChecks(s.GenericServerRunOptions.MaxStartupSequenceDuration, instanceOptions.InjectedHealthChecker); err != nil {
157157
return result, err
158158
}
159159
}

cmd/kube-controller-manager/app/controllermanager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func Run(c *config.CompletedConfig, stopCh <-chan struct{}) error {
170170
}
171171

172172
// Setup any healthz checks we will want to use.
173-
var checks []healthz.HealthzChecker
173+
var checks []healthz.HealthChecker
174174
var electionChecker *leaderelection.HealthzAdaptor
175175
if c.ComponentConfig.Generic.LeaderElection.LeaderElect {
176176
electionChecker = leaderelection.NewLeaderHealthzAdaptor(time.Second * 20)

cmd/kube-scheduler/app/server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ func Run(cc schedulerserverconfig.CompletedConfig, stopCh <-chan struct{}, regis
204204
cc.LeaderElectionBroadcaster.StartRecordingToSink(&corev1.EventSinkImpl{Interface: cc.CoreEventClient.Events("")})
205205
}
206206
// Setup healthz checks.
207-
var checks []healthz.HealthzChecker
207+
var checks []healthz.HealthChecker
208208
if cc.ComponentConfig.LeaderElection.LeaderElect {
209209
checks = append(checks, cc.LeaderElection.WatchDog)
210210
}
@@ -321,7 +321,7 @@ func newMetricsHandler(config *kubeschedulerconfig.KubeSchedulerConfiguration) h
321321
// newHealthzHandler creates a healthz server from the config, and will also
322322
// embed the metrics handler if the healthz and metrics address configurations
323323
// are the same.
324-
func newHealthzHandler(config *kubeschedulerconfig.KubeSchedulerConfiguration, separateMetrics bool, checks ...healthz.HealthzChecker) http.Handler {
324+
func newHealthzHandler(config *kubeschedulerconfig.KubeSchedulerConfiguration, separateMetrics bool, checks ...healthz.HealthChecker) http.Handler {
325325
pathRecorderMux := mux.NewPathRecorderMux("kube-scheduler")
326326
healthz.InstallHandler(pathRecorderMux, checks...)
327327
if !separateMetrics {

pkg/master/master.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ func (m *Master) InstallLegacyAPI(c *completedConfig, restOptionsGetter generic.
396396

397397
func (m *Master) installTunneler(nodeTunneler tunneler.Tunneler, nodeClient corev1client.NodeInterface) {
398398
nodeTunneler.Run(nodeAddressProvider{nodeClient}.externalAddresses)
399-
m.GenericAPIServer.AddHealthzChecks(healthz.NamedCheck("SSH Tunnel Check", tunneler.TunnelSyncHealthChecker(nodeTunneler)))
399+
m.GenericAPIServer.AddHealthChecks(healthz.NamedCheck("SSH Tunnel Check", tunneler.TunnelSyncHealthChecker(nodeTunneler)))
400400
prometheus.NewGaugeFunc(prometheus.GaugeOpts{
401401
Name: "apiserver_proxy_tunnel_sync_duration_seconds",
402402
Help: "The time since the last successful synchronization of the SSH tunnels for proxy requests.",

staging/src/k8s.io/apiserver/pkg/server/config.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,10 @@ type Config struct {
137137
// DiscoveryAddresses is used to build the IPs pass to discovery. If nil, the ExternalAddress is
138138
// always reported
139139
DiscoveryAddresses discovery.Addresses
140-
// The default set of healthz checks. There might be more added via AddHealthzChecks dynamically.
141-
HealthzChecks []healthz.HealthzChecker
140+
// The default set of healthz checks. There might be more added via AddHealthChecks dynamically.
141+
HealthzChecks []healthz.HealthChecker
142142
// The default set of readyz-only checks. There might be more added via AddReadyzChecks dynamically.
143-
ReadyzChecks []healthz.HealthzChecker
143+
ReadyzChecks []healthz.HealthChecker
144144
// LegacyAPIGroupPrefixes is used to set up URL parsing for authorization and for validating requests
145145
// to InstallLegacyAPIGroup. New API servers don't generally have legacy groups at all.
146146
LegacyAPIGroupPrefixes sets.String
@@ -269,15 +269,15 @@ type AuthorizationInfo struct {
269269

270270
// NewConfig returns a Config struct with the default values
271271
func NewConfig(codecs serializer.CodecFactory) *Config {
272-
defaultHealthChecks := []healthz.HealthzChecker{healthz.PingHealthz, healthz.LogHealthz}
272+
defaultHealthChecks := []healthz.HealthChecker{healthz.PingHealthz, healthz.LogHealthz}
273273
return &Config{
274274
Serializer: codecs,
275275
BuildHandlerChainFunc: DefaultBuildHandlerChain,
276276
HandlerChainWaitGroup: new(utilwaitgroup.SafeWaitGroup),
277277
LegacyAPIGroupPrefixes: sets.NewString(DefaultLegacyAPIPrefix),
278278
DisabledPostStartHooks: sets.NewString(),
279-
HealthzChecks: append([]healthz.HealthzChecker{}, defaultHealthChecks...),
280-
ReadyzChecks: append([]healthz.HealthzChecker{}, defaultHealthChecks...),
279+
HealthzChecks: append([]healthz.HealthChecker{}, defaultHealthChecks...),
280+
ReadyzChecks: append([]healthz.HealthChecker{}, defaultHealthChecks...),
281281
EnableIndex: true,
282282
EnableDiscovery: true,
283283
EnableProfiling: true,

staging/src/k8s.io/apiserver/pkg/server/genericapiserver.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ type GenericAPIServer struct {
147147

148148
// healthz checks
149149
healthzLock sync.Mutex
150-
healthzChecks []healthz.HealthzChecker
150+
healthzChecks []healthz.HealthChecker
151151
healthzChecksInstalled bool
152152
readyzLock sync.Mutex
153-
readyzChecks []healthz.HealthzChecker
153+
readyzChecks []healthz.HealthChecker
154154
readyzChecksInstalled bool
155155
maxStartupSequenceDuration time.Duration
156156
healthzClock clock.Clock
@@ -203,7 +203,7 @@ type DelegationTarget interface {
203203
PreShutdownHooks() map[string]preShutdownHookEntry
204204

205205
// HealthzChecks returns the healthz checks that need to be combined
206-
HealthzChecks() []healthz.HealthzChecker
206+
HealthzChecks() []healthz.HealthChecker
207207

208208
// ListedPaths returns the paths for supporting an index
209209
ListedPaths() []string
@@ -225,7 +225,7 @@ func (s *GenericAPIServer) PostStartHooks() map[string]postStartHookEntry {
225225
func (s *GenericAPIServer) PreShutdownHooks() map[string]preShutdownHookEntry {
226226
return s.preShutdownHooks
227227
}
228-
func (s *GenericAPIServer) HealthzChecks() []healthz.HealthzChecker {
228+
func (s *GenericAPIServer) HealthzChecks() []healthz.HealthChecker {
229229
return s.healthzChecks
230230
}
231231
func (s *GenericAPIServer) ListedPaths() []string {
@@ -252,8 +252,8 @@ func (s emptyDelegate) PostStartHooks() map[string]postStartHookEntry {
252252
func (s emptyDelegate) PreShutdownHooks() map[string]preShutdownHookEntry {
253253
return map[string]preShutdownHookEntry{}
254254
}
255-
func (s emptyDelegate) HealthzChecks() []healthz.HealthzChecker {
256-
return []healthz.HealthzChecker{}
255+
func (s emptyDelegate) HealthzChecks() []healthz.HealthChecker {
256+
return []healthz.HealthChecker{}
257257
}
258258
func (s emptyDelegate) ListedPaths() []string {
259259
return []string{}

staging/src/k8s.io/apiserver/pkg/server/healthz.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,23 @@ import (
2525
"k8s.io/apiserver/pkg/server/healthz"
2626
)
2727

28-
// AddHealthzCheck adds HealthzCheck(s) to both healthz and readyz. All healthz checks
28+
// AddHealthChecks adds HealthzCheck(s) to both healthz and readyz. All healthz checks
2929
// are automatically added to readyz, since we want to avoid the situation where the
3030
// apiserver is ready but not live.
31-
func (s *GenericAPIServer) AddHealthzChecks(checks ...healthz.HealthzChecker) error {
31+
func (s *GenericAPIServer) AddHealthChecks(checks ...healthz.HealthChecker) error {
3232
return s.AddDelayedHealthzChecks(0, checks...)
3333
}
3434

3535
// AddReadyzChecks allows you to add a HealthzCheck to readyz.
36-
func (s *GenericAPIServer) AddReadyzChecks(checks ...healthz.HealthzChecker) error {
36+
func (s *GenericAPIServer) AddReadyzChecks(checks ...healthz.HealthChecker) error {
3737
s.readyzLock.Lock()
3838
defer s.readyzLock.Unlock()
3939
return s.addReadyzChecks(checks...)
4040
}
4141

4242
// addReadyzChecks allows you to add a HealthzCheck to readyz.
4343
// premise: readyzLock has been obtained
44-
func (s *GenericAPIServer) addReadyzChecks(checks ...healthz.HealthzChecker) error {
44+
func (s *GenericAPIServer) addReadyzChecks(checks ...healthz.HealthChecker) error {
4545
if s.readyzChecksInstalled {
4646
return fmt.Errorf("unable to add because the readyz endpoint has already been created")
4747
}
@@ -94,7 +94,7 @@ func (c shutdownCheck) Check(req *http.Request) error {
9494
// grace period has not yet elapsed. One may want to set a grace period in order to prevent
9595
// the kubelet from restarting the kube-apiserver due to long-ish boot sequences. Readyz health
9696
// checks have no grace period, since we want readyz to fail while boot has not completed.
97-
func (s *GenericAPIServer) AddDelayedHealthzChecks(delay time.Duration, checks ...healthz.HealthzChecker) error {
97+
func (s *GenericAPIServer) AddDelayedHealthzChecks(delay time.Duration, checks ...healthz.HealthChecker) error {
9898
s.healthzLock.Lock()
9999
defer s.healthzLock.Unlock()
100100
if s.healthzChecksInstalled {
@@ -110,7 +110,7 @@ func (s *GenericAPIServer) AddDelayedHealthzChecks(delay time.Duration, checks .
110110
}
111111

112112
// delayedHealthCheck wraps a health check which will not fail until the explicitly defined delay has elapsed.
113-
func delayedHealthCheck(check healthz.HealthzChecker, clock clock.Clock, delay time.Duration) healthz.HealthzChecker {
113+
func delayedHealthCheck(check healthz.HealthChecker, clock clock.Clock, delay time.Duration) healthz.HealthChecker {
114114
return delayedHealthzCheck{
115115
check,
116116
clock.Now().Add(delay),
@@ -119,7 +119,7 @@ func delayedHealthCheck(check healthz.HealthzChecker, clock clock.Clock, delay t
119119
}
120120

121121
type delayedHealthzCheck struct {
122-
check healthz.HealthzChecker
122+
check healthz.HealthChecker
123123
startCheck time.Time
124124
clock clock.Clock
125125
}

0 commit comments

Comments
 (0)