-
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
Suppress server log message when EOF without receiving data for preface #1052
Conversation
@menghanl is already working on adding different levels to logging. This should be taken care of there. Menghan can confirm further when he's back. |
@menghanl Any chance your changes are going in soon? I have to keep moving the patch forward when I pull due to current code being super-noisy when used behind a tcp balancer. |
The first step (#922) should be done by the end of this week. |
transport/http2_server.go
Outdated
grpclog.Printf("transport: http2Server.HandleStreams failed to receive the preface from client: %v", err) | ||
if n, err := io.ReadFull(t.conn, preface); err != nil { | ||
// Only log if it isn't a simple tcp accept check (ie: tcp balancer doing open/close socket) | ||
if n > 0 || err != io.EOF { |
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.
Let's just need to check io.EOF
here. If n>0, err will be ErrUnexpectedEOF
.
From the doc of ReadFull
:
The error is EOF only if no bytes were read.
If an EOF happens after reading some but not all the bytes,
ReadFull returns ErrUnexpectedEOF.
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.
makes sense, updated...
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.
Thanks for the fix.
LGTM.
When using a TCP load balancer (ie: AWS ELB), they do health checks by simply opening a connection to your port and then closing it.
Just to test if you can accept a connection.
Currently, this causes a log message of:
This change suppresses that log message if, and only if, no bytes were received.
Basically, it allows a GRPC server to be used behind a simple TCP load balancer without spamming your logs.