Skip to content
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

etcdserver/api/v3rpc: debug-log client disconnect on TLS, http/2 stream CANCEL #9178

Merged
merged 2 commits into from
Jan 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .words
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ cancelation
cluster_proxy
defragment
defragmenting
errClientDisconnected
etcd
gRPC
goroutine
Expand All @@ -43,4 +44,3 @@ too_many_pings
uncontended
unprefixed
unlisting

24 changes: 22 additions & 2 deletions etcdserver/api/v3rpc/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package v3rpc

import (
"context"
"strings"

"github.com/coreos/etcd/auth"
"github.com/coreos/etcd/etcdserver"
Expand Down Expand Up @@ -91,6 +92,25 @@ func isClientCtxErr(ctxErr error, err error) bool {
if !ok {
return false
}
code := ev.Code()
return code == codes.Canceled || code == codes.DeadlineExceeded

switch ev.Code() {
case codes.Canceled, codes.DeadlineExceeded:
// client-side context cancel or deadline exceeded
// "rpc error: code = Canceled desc = context canceled"
// "rpc error: code = DeadlineExceeded desc = context deadline exceeded"
return true
case codes.Unavailable:
msg := ev.Message()
// client-side context cancel or deadline exceeded with TLS ("http2.errClientDisconnected")
// "rpc error: code = Unavailable desc = client disconnected"
if msg == "client disconnected" {
return true
}
// "grpc/transport.ClientTransport.CloseStream" on canceled streams
// "rpc error: code = Unavailable desc = stream error: stream ID 21; CANCEL")
if strings.HasPrefix(msg, "stream error: ") && strings.HasSuffix(msg, "; CANCEL") {
return true
}
}
return false
}