-
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: gracefully close peer handler #7879
Conversation
140338e
to
723d247
Compare
embed/etcd.go
Outdated
if plns[i], err = rafthttp.NewListener(u, &cfg.PeerTLSInfo); err != nil { | ||
return nil, err | ||
var l net.Listener | ||
l, err = rafthttp.NewListener(u, &cfg.PeerTLSInfo) |
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.
l, lerr :=
to avoid the var l net.Listener
?
embed/etcd.go
Outdated
// gracefully shutdown http.Server; close open listeners, idle connections | ||
// pass canceled context to close existing idle connections only once | ||
// and not delay the server shutdown | ||
serr := srv.Shutdown(canceled) |
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.
return srv.Shutdown(canceled)
?
embed/etcd.go
Outdated
@@ -51,7 +55,9 @@ const ( | |||
|
|||
// Etcd contains a running etcd server and its listeners. | |||
type Etcd struct { | |||
Peers []net.Listener | |||
peerServeFuncs []func() 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.
type Etcd struct {
Peers []peerListener
...
}
...
type peerListener struct {
net.Listener
serve func() error
close func(context.Context) error
}
?
3b6e852
to
823f9b3
Compare
Apparently this breaks in EXPECT_DEBUG=1 go test -v -run TestCtlV3AuthMemberRemove
EXPECT_DEBUG=1 go test -v -run TestCtlV3MemberRemove Both pass |
ce2e79c
to
1367d54
Compare
Signed-off-by: Gyu-Ho Lee <[email protected]>
All fixed (it had to start rafthttp layer first). PTAL. |
@@ -226,12 +260,18 @@ func startPeerListeners(cfg *Config) (plns []net.Listener, err error) { | |||
plog.Warningf("The scheme of peer url %s is HTTP while client cert auth (--peer-client-cert-auth) is enabled. Ignored client cert auth for this url.", u.String()) | |||
} | |||
} | |||
if plns[i], err = rafthttp.NewListener(u, &cfg.PeerTLSInfo); err != nil { | |||
peers[i] = &peerListener{close: func(context.Context) error { return 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.
Just curious, why are we initializing the close function here?
Passing canceled context to close existing idle connections only once and to not delay the server shutdown. And make
embed.Etcd.Peers
non-exported (need release note).c.f. #6174