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

grpc: update clientStreamAttempt context with transport context #7096

Merged
merged 4 commits into from
May 2, 2024

Conversation

aranjans
Copy link
Contributor

@aranjans aranjans commented Apr 4, 2024

Fixes #6947

RELEASE NOTES:

  • stats: Fix bug where peer was not set in context when calling stats handler for OutPayload, InPayload, End.

@aranjans aranjans marked this pull request as ready for review April 4, 2024 17:34
Copy link

codecov bot commented Apr 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.32%. Comparing base (92f6dd0) to head (82b47c5).
Report is 49 commits behind head on master.

❗ Current head 82b47c5 differs from pull request most recent head 776e341. Consider uploading reports for the commit 776e341 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7096      +/-   ##
==========================================
+ Coverage   81.29%   81.32%   +0.03%     
==========================================
  Files         340      345       +5     
  Lines       33890    33926      +36     
==========================================
+ Hits        27550    27590      +40     
+ Misses       5178     5176       -2     
+ Partials     1162     1160       -2     
Files Coverage Δ
stream.go 81.49% <100.00%> (+0.10%) ⬆️

... and 18 files with indirect coverage changes

@arvindbr8 arvindbr8 self-requested a review April 4, 2024 18:52
@arvindbr8 arvindbr8 self-assigned this Apr 4, 2024
@arvindbr8 arvindbr8 added this to the 1.64 Release milestone Apr 5, 2024
@arvindbr8
Copy link
Member

Great work!

“the best code is no code at all..."

Are we sure this fixes everything that #6947 talks about? If so, do you mind adding the test output to this PR?

Also it's interesting that our CI didn't catch this. Let's add one as part of this change. One good place I can think of is to add this would be when tests (extras) run the examples/stats example.
@dfawley: do you have a recommendation?

@arvindbr8 arvindbr8 assigned aranjans and unassigned arvindbr8 Apr 5, 2024
@arvindbr8
Copy link
Member

Actually I would just add another go test for this. Let's not complicate this with adding it to extras

Copy link
Member

@arvindbr8 arvindbr8 left a comment

Choose a reason for hiding this comment

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

For accounting: so that you can re-request a review when its ready

@aranjans aranjans force-pushed the aranjans_6947 branch 2 times, most recently from 9152685 to 1463ef5 Compare April 10, 2024 17:15
@ginayeh ginayeh assigned arvindbr8 and unassigned aranjans Apr 10, 2024
test/stats_test.go Outdated Show resolved Hide resolved
test/stats_test.go Outdated Show resolved Hide resolved
test/stats_test.go Outdated Show resolved Hide resolved
test/stats_test.go Outdated Show resolved Hide resolved

ctx := context.Background()
client := testgrpc.NewTestServiceClient(conn)
interop.DoClientStreaming(ctx, client)
Copy link
Member

Choose a reason for hiding this comment

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

Might be useful to have a subtest for each RPC type (unary, bidi, etc)

Copy link
Member

Choose a reason for hiding this comment

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

This doesnt seem to be resolved?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Zach suggested here to have single RPC type.

test/stats_test.go Outdated Show resolved Hide resolved
test/stats_test.go Outdated Show resolved Hide resolved
test/stats_test.go Outdated Show resolved Hide resolved
Copy link
Member

@arvindbr8 arvindbr8 left a comment

Choose a reason for hiding this comment

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

LGTM. I would like @zasweq to take a look at this as well.

}
t.Cleanup(func() {
if err := conn.Close(); err != nil {
t.Error(err)
Copy link
Member

Choose a reason for hiding this comment

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

optional: This t.Error is not really in the essence of the test. I think maybe we can get rid of it.

Copy link
Member

Choose a reason for hiding this comment

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

And this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@arvindbr8 arvindbr8 requested a review from zasweq April 17, 2024 00:32
@arvindbr8 arvindbr8 assigned zasweq and unassigned arvindbr8 Apr 17, 2024
@dfawley dfawley changed the title Update clientStreamAttempt context with transport context grpc: update clientStreamAttempt context with transport context Apr 17, 2024
@aranjans aranjans requested a review from zasweq April 19, 2024 06:50
@zasweq zasweq assigned aranjans and unassigned zasweq Apr 19, 2024
Copy link
Contributor

@zasweq zasweq left a comment

Choose a reason for hiding this comment

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

Looks great overall, some minor nits and replied to some comments with technical context.

test/stats_test.go Outdated Show resolved Hide resolved
Comment on lines 40 to 43
// Define expected stats callouts and whether a peer object should be populated.
// Note:
// * Begin stats don't have peer information as the RPC begins before peer resolution.
// * PickerUpdated stats don't have peer information as the picker operates without transport-level knowledge.
Copy link
Contributor

Choose a reason for hiding this comment

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

Please wrap comments to 80 characters. The guidance for this repo is comments wrapped to 80 characters, but we do not have a length maximum for code line characters.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

test/stats_test.go Outdated Show resolved Hide resolved
test/stats_test.go Outdated Show resolved Hide resolved
test/stats_test.go Outdated Show resolved Hide resolved
go func() {
errCh <- grpcServer.Serve(l)
}()
t.Cleanup(func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you switch one below too?

test/stats_test.go Outdated Show resolved Hide resolved
test/stats_test.go Outdated Show resolved Hide resolved
test/stats_test.go Outdated Show resolved Hide resolved
test/stats_test.go Outdated Show resolved Hide resolved
@zasweq zasweq assigned aranjans and unassigned zasweq Apr 22, 2024
Copy link
Contributor

@zasweq zasweq left a comment

Choose a reason for hiding this comment

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

LGTM.

// verifies that peer is sent for OutPayload, InPayload, End
// stats handlers.
// verifies that peer is sent all stats handler callouts instead
// of begin and pickerUpdated
Copy link
Contributor

Choose a reason for hiding this comment

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

Capitalize and period at the end.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines 41 to 45
// Stats callouts & peer object population.
// Note:
// * Begin stats don't have peer information as the RPC begins before peer resolution.
// * PickerUpdated stats don't have peer information as the picker operates without transport-level knowledge.
// * Begin stats lack peer info (RPC starts pre-resolution).
// * PickerUpdated: no peer info (picker lacks transport details).
Copy link
Contributor

Choose a reason for hiding this comment

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

No you can keep the full comment, just wrap it to 80 characters. Just make sure it wraps 80 by 80.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

go func() {
errCh <- grpcServer.Serve(l)
}()
t.Cleanup(func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ping on this.

@aranjans aranjans assigned zasweq and unassigned aranjans Apr 23, 2024
@aranjans aranjans force-pushed the aranjans_6947 branch 3 times, most recently from 72a3c5f to deb839a Compare April 23, 2024 17:43
@zasweq zasweq assigned aranjans and unassigned zasweq Apr 23, 2024
@zasweq
Copy link
Contributor

zasweq commented Apr 23, 2024

Please figure out and fix the race condition before we merge this.

Copy link
Member

@arvindbr8 arvindbr8 left a comment

Choose a reason for hiding this comment

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

Few comments from my previous pass seems to be unresolved, but marked resolved. Could you please respond to them before we can merge this?


ctx := context.Background()
client := testgrpc.NewTestServiceClient(conn)
interop.DoClientStreaming(ctx, client)
Copy link
Member

Choose a reason for hiding this comment

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

This doesnt seem to be resolved?

}
t.Cleanup(func() {
if err := conn.Close(); err != nil {
t.Error(err)
Copy link
Member

Choose a reason for hiding this comment

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

And this?

client := testgrpc.NewTestServiceClient(cc)
interop.DoClientStreaming(ctx, client)

sc := getUniqueRPCStatsCount(psh.args)
Copy link
Member

Choose a reason for hiding this comment

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

I would inline the logic here, better for readability and this helper is only being used once.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the comment

@aranjans aranjans force-pushed the aranjans_6947 branch 3 times, most recently from 9decab5 to 4cdfa42 Compare April 25, 2024 05:50
Copy link
Member

@arvindbr8 arvindbr8 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@purnesh42H purnesh42H left a comment

Choose a reason for hiding this comment

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

lgtm

@arvindbr8 arvindbr8 merged commit 796c615 into grpc:master May 2, 2024
12 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

stats: peer is not populated for all HandleRPC client callbacks
4 participants