-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
health, grpc: Deliver health service updates through the health listener #7900
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7900 +/- ##
==========================================
- Coverage 82.13% 82.04% -0.10%
==========================================
Files 377 378 +1
Lines 38179 38258 +79
==========================================
+ Hits 31360 31389 +29
- Misses 5525 5561 +36
- Partials 1294 1308 +14
|
ab9cd38
to
956bd64
Compare
health/producer.go
Outdated
cancelDone: doneCh, | ||
cancel: grpcsync.OnceFunc(func() { | ||
close(doneCh) | ||
}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider a grpcsync.Event
instead of having two fields here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was using the two fields, one to trigger the cancellation of the context that is passed to the health client and the second to wait till the health check client to return. Waiting for the client close isn't required. The health checking in addrConn also cancels the context and lets the client shut down asynchronously. I got rid of the channel to wait for the client to return here.
Lines 1342 to 1354 in c1b6b37
onClose := func(r transport.GoAwayReason) { | |
ac.mu.Lock() | |
defer ac.mu.Unlock() | |
// adjust params based on GoAwayReason | |
ac.adjustParams(r) | |
if ctx.Err() != nil { | |
// Already shut down or connection attempt canceled. tearDown() or | |
// updateAddrs() already cleared the transport and canceled hctx | |
// via ac.ctx, and we expected this connection to be closed, so do | |
// nothing here. | |
return | |
} | |
hcancel() |
balancer_wrapper.go
Outdated
if acbw.healthData != hd { | ||
return | ||
} | ||
if registerFn == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to implement a nopHealthListener
that is actually a real implementation that only reports Ready
, once, to avoid special-case handling here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored to make this method return either the heallh producer's register listener function or a no-op register listener function.
a45a236
to
5cf90ee
Compare
As part of the dualstack changes described in A61, client side health check updates need to be delivered through the health listener instead of the raw connectivity listener. This PR creates a
health producer
that manages the health service client and allows registration of a listener for receiving updates. TheRegisterHealthListener
method inacBalancerWrapper
decides whether client side health checking is enabled, if it is, it registers the health listener with the health producer.acBalancerWrapper
wraps the LB policy's listener to synchronize updates from the health producer.Existing health check tests are run against the health producer when the
GRPC_EXPERIMENTAL_ENABLE_NEW_PICK_FIRST
is set totrue
.RELEASE NOTES: N/A