]> git.feebdaed.xyz Git - 0xmirror/grpc-go.git/commitdiff
client: Add error log for missing health package import during health check (#8595)
authorArjan Singh Bal <46515553+arjan-bal@users.noreply.github.com>
Fri, 3 Oct 2025 04:08:57 +0000 (09:38 +0530)
committerGitHub <noreply@github.com>
Fri, 3 Oct 2025 04:08:57 +0000 (09:38 +0530)
Addresses: https://github.com/grpc/grpc-go/issues/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

balancer_wrapper.go

index 948a21ef68338c7164b69ffc31005e17023f1099..2c760e623f630ba165fe62102505dfbdc878f39e 100644 (file)
@@ -450,13 +450,14 @@ func (acbw *acBalancerWrapper) healthListenerRegFn() func(context.Context, func(
        if acbw.ccb.cc.dopts.disableHealthCheck {
                return noOpRegisterHealthListenerFn
        }
+       cfg := acbw.ac.cc.healthCheckConfig()
+       if cfg == nil {
+               return noOpRegisterHealthListenerFn
+       }
        regHealthLisFn := internal.RegisterClientHealthCheckListener
        if regHealthLisFn == nil {
                // The health package is not imported.
-               return noOpRegisterHealthListenerFn
-       }
-       cfg := acbw.ac.cc.healthCheckConfig()
-       if cfg == nil {
+               channelz.Error(logger, acbw.ac.channelz, "Health check is requested but health package is not imported.")
                return noOpRegisterHealthListenerFn
        }
        return func(ctx context.Context, listener func(balancer.SubConnState)) func() {