-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
embed: fix *grpc.Server panic on GracefulStop with TLS-enabled server #8987
Conversation
@jamesdphillips @xiang90 Semaphore CI in previous PR was not working for some reason. Creating a fresh branch for proper testing. |
embed/etcd.go
Outdated
@@ -82,7 +82,7 @@ type Etcd struct { | |||
type peerListener struct { | |||
net.Listener | |||
serve func() error | |||
close func(context.Context) error | |||
close func(time.Duration) error |
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.
https://golang.org/pkg/net/http/#Server.Shutdown takes context. i am not sure why we want to change to time.duration.
@@ -219,23 +219,30 @@ func (e *Etcd) Config() Config { | |||
return e.cfg | |||
} | |||
|
|||
// Close gracefully shuts down all servers/listeners. |
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.
we should mention there is a default timeout for the graceful shutdown. or we will do a force shutdown.
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.
@xiang90 Comments are added. PTAL.
embed/etcd.go
Outdated
shutdownNow := func() { | ||
// first, close the http.Server | ||
ctx, cancel := context.WithTimeout(context.Background(), timeout) | ||
ss.http.Shutdown(ctx) |
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.
@xiang90 Here we construct the context for Shutdown
?
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.
why not pass in ctx direction? i just not sure why we want duration at the first place.
embed/etcd.go
Outdated
timeout := 2 * time.Second | ||
if e.Server != nil { | ||
timeout = e.Server.Cfg.ReqTimeout() | ||
func stopServers(ss *servers, timeout time.Duration) { |
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.
why not take a context but time.duration?
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.
Ok, that works too. Let me change to context.
62aa2e3
to
efe2c19
Compare
*grpc.Server
panic on GracefulStop
with TLS-enabled server
*grpc.Server
panic on GracefulStop
with TLS-enabled server
lgtm if CIs all turn green. |
GitHub CI status polling seems outdated. All CIs passed (https://jenkins-etcd.prod.coreos.systems/job/etcd-proxy/3639/). Will merge tomorrow. |
Avoid panic when stopping gRPC Server if TLS configuration is present. Provided solution (attempts to) implement suggestion from gRPC team: grpc/grpc-go#1384 (comment). Fixes etcd-io#8916
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
Codecov Report
@@ Coverage Diff @@
## master #8987 +/- ##
=========================================
Coverage ? 76.03%
=========================================
Files ? 359
Lines ? 29819
Branches ? 0
=========================================
Hits ? 22672
Misses ? 5563
Partials ? 1584
Continue to review full report at Codecov.
|
Late response but thank you! |
Cherry-pick #8987. Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
Cherry-pick #8987. Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
Replace #8986.
Fix #8916.