-
Notifications
You must be signed in to change notification settings - Fork 4.5k
transport: Prevent sending negative timeouts #8312
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
transport: Prevent sending negative timeouts #8312
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #8312 +/- ##
==========================================
+ Coverage 82.19% 82.22% +0.03%
==========================================
Files 419 419
Lines 41992 41992
==========================================
+ Hits 34516 34530 +14
+ Misses 6008 5997 -11
+ Partials 1468 1465 -3
🚀 New features to boost your workflow:
|
test/end2end_test.go
Outdated
@@ -5342,7 +5342,7 @@ func testRPCTimeout(t *testing.T, e env) { | |||
ResponseSize: respSize, | |||
Payload: payload, | |||
} | |||
for i := -1; i <= 10; i++ { | |||
for i := 1; i <= 10; i++ { | |||
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(i)*time.Millisecond) |
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.
This is even worrysome. If it takes >1ms before the timeout is computed by grpc, then it could fail. It seems like there's probably something in our code that we should change that prevents the client from sending a negative deadline instead.
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.
Made the fix to validate the timeout on the client side and return a DeadlineExceeded
error.
87ad73f
to
bcc45b0
Compare
bcc45b0
to
e1bcc17
Compare
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.
Nice, thank you for fixing this!
test/end2end_test.go
Outdated
defer server.Stop() | ||
|
||
if err := server.StartClient(); err != nil { | ||
t.Fatal(err) |
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.
This should say what it's doing in the error message, to make debugging a failure easier.
After #8290 is merged, negative timeout values fail the request with an internal status instead of a deadline exceeded. This test uses negative deadlines and can fail if the server sends an internal error before the client sees the deadline expire.
Sample failure: https://github.com/grpc/grpc-go/actions/runs/14979137997/job/42078795928?pr=8308
The client checks the deadline expiry before creating a stream.
grpc-go/stream.go
Lines 410 to 413 in 709023d
However, the deadline may expire after this check, but before the
grpc-timeout
header is created.RELEASE NOTES:
grpc-timeout
header is created.