Skip to content

Commit 6325504

Browse files
authored
client: Add error log for missing health package import during health check (#8595)
Addresses: #8590 When using the health producer for health checks, and the health package is not imported by the application, a no op health producer is used without logging any errors. This PR adds an error log similar to the one for the old health checks started by the subchannel. https://github.com/grpc/grpc-go/blob/e35080456c7071b6d55887080ef78809c163640c/clientconn.go#L1475-L1481 RELEASE NOTES: N/A
1 parent 9a1d8d8 commit 6325504

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

balancer_wrapper.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -450,13 +450,14 @@ func (acbw *acBalancerWrapper) healthListenerRegFn() func(context.Context, func(
450450
if acbw.ccb.cc.dopts.disableHealthCheck {
451451
return noOpRegisterHealthListenerFn
452452
}
453+
cfg := acbw.ac.cc.healthCheckConfig()
454+
if cfg == nil {
455+
return noOpRegisterHealthListenerFn
456+
}
453457
regHealthLisFn := internal.RegisterClientHealthCheckListener
454458
if regHealthLisFn == nil {
455459
// The health package is not imported.
456-
return noOpRegisterHealthListenerFn
457-
}
458-
cfg := acbw.ac.cc.healthCheckConfig()
459-
if cfg == nil {
460+
channelz.Error(logger, acbw.ac.channelz, "Health check is requested but health package is not imported.")
460461
return noOpRegisterHealthListenerFn
461462
}
462463
return func(ctx context.Context, listener func(balancer.SubConnState)) func() {

0 commit comments

Comments
 (0)