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

Verify deadlines are correctly propagated #772

Merged
merged 3 commits into from
Feb 6, 2024
Merged

Conversation

jhump
Copy link
Member

@jhump jhump commented Feb 6, 2024

I noticed in the code the other day that we do verify the timeout, by having the server echo back the timeout it observed and then having the test runner check that against the timeout that the client should have sent.

So I was surprised that this didn't manifest as failed tests in connect-kotlin, which I now know (from getting pretty deep into the code) does not work -- it simply never tried to set deadline headers. (And it's not easy to add with it's current implementation structure, so I'll probably leave it as "known failing" until we can fix other problems with timeouts.)

Anyhow, when digging into why this didn't tickle any failure in connect-kotlin, it's because the only test cases that actually set the timeout always fail with a timeout error (so the client never gets back a response and cannot see the timeout that the server observed).

So this adds a new test suite to verify deadlines are correctly propagated. And it also required some fixes in the grpc-go server implementation in this repo, which was not reporting them correctly, which caused failures in the make runservertests target.

@@ -36,7 +36,7 @@ import (
"google.golang.org/protobuf/types/known/anypb"
)

const timeoutCheckGracePeriodMillis = 500
const timeoutCheckGracePeriodMillis = 100
Copy link
Member Author

@jhump jhump Feb 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that the tolerances in actual timeout tests are on the order of 100 millis, the value here seemed egregiously generous. So I tightened it down to 100 milliseconds. This exists because some implementations (including connect-go) start the timeout clock when a deadline is configured, not when the RPC is actually sent.

So this grace period (admittedly still a bit generous) allows up to 100 milliseconds to elapse in the client implementation between the time the timeout is configured and the time it is written into RPC header metadata.

@@ -62,11 +62,12 @@ func (c *conformanceServiceServer) Unary(
if err := grpc.SetTrailer(ctx, trailerMD); err != nil {
return nil, err
}
time.Sleep((time.Duration(req.ResponseDefinition.ResponseDelayMs) * time.Millisecond))
time.Sleep(time.Duration(req.ResponseDefinition.ResponseDelayMs) * time.Millisecond)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change ("remove redundant parentheses") was suggested by GoLand, so I went ahead and accepted here and throughout.

@jhump jhump requested a review from smaye81 February 6, 2024 14:35
@jhump jhump merged commit 6d47d92 into main Feb 6, 2024
5 checks passed
@jhump jhump deleted the jh/deadline-propagation branch February 6, 2024 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants