@@ -129,6 +129,15 @@ func (sb *serverBuilder) Build(tlsConfig *tls.Config, statsRegistry prometheus.R
129129 }
130130 }
131131
132+ // Ensure that the health service has the same ClientNames as the other
133+ // services, so that health checks can be performed by clients which are
134+ // allowed to connect to the server.
135+ healthService := sb .cfg .Services [healthpb .Health_ServiceDesc .ServiceName ]
136+ for as := range acceptedSANs {
137+ healthService .ClientNames = append (healthService .ClientNames , as )
138+ }
139+ sb .cfg .Services [healthpb .Health_ServiceDesc .ServiceName ] = healthService
140+
132141 creds , err := bcreds .NewServerCredentials (tlsConfig , acceptedSANs )
133142 if err != nil {
134143 return nil , err
@@ -224,8 +233,12 @@ func (sb *serverBuilder) Build(tlsConfig *tls.Config, statsRegistry prometheus.R
224233
225234// initLongRunningCheck initializes a goroutine which will periodically check
226235// the health of the provided service and update the health server accordingly.
236+ //
237+ // TODO(#8255): Remove the service parameter and instead rely on transitioning
238+ // the overall health of the server (e.g. "") instead of individual services.
227239func (sb * serverBuilder ) initLongRunningCheck (shutdownCtx context.Context , service string , checkImpl func (context.Context ) error ) {
228240 // Set the initial health status for the service.
241+ sb .healthSrv .SetServingStatus ("" , healthpb .HealthCheckResponse_NOT_SERVING )
229242 sb .healthSrv .SetServingStatus (service , healthpb .HealthCheckResponse_NOT_SERVING )
230243
231244 // check is a helper function that checks the health of the service and, if
@@ -249,10 +262,14 @@ func (sb *serverBuilder) initLongRunningCheck(shutdownCtx context.Context, servi
249262 }
250263
251264 if next != healthpb .HealthCheckResponse_SERVING {
265+ sb .logger .Errf ("transitioning health of %q from %q to %q, due to: %s" , sb .cfg .Address , last , next , err )
252266 sb .logger .Errf ("transitioning health of %q from %q to %q, due to: %s" , service , last , next , err )
253267 } else {
268+ sb .logger .Infof ("transitioning health of %q from %q to %q" , sb .cfg .Address , last , next )
254269 sb .logger .Infof ("transitioning health of %q from %q to %q" , service , last , next )
270+
255271 }
272+ sb .healthSrv .SetServingStatus ("" , next )
256273 sb .healthSrv .SetServingStatus (service , next )
257274 return next
258275 }
0 commit comments