Skip to content

cleanup: replace dial with newclient #8196

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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

janardhanvissa
Copy link
Contributor

addresses: #7049

RELEASE NOTES: None

@arjan-bal
Copy link
Contributor

Is this PR ready for review?

@janardhanvissa
Copy link
Contributor Author

Is this PR ready for review?

yes, please

@janardhanvissa janardhanvissa force-pushed the replacing-dial-to-newclient branch from 6458128 to d672f29 Compare April 23, 2025 07:21
Copy link
Contributor

@arjan-bal arjan-bal left a comment

Choose a reason for hiding this comment

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

There are a lot of unnecessary log message changes added in this PR. This makes it really hard to spot and review actual code changes.

t.Fatalf("Failed to create new client: %v", err)
t.Fatalf("grpc.NewClient(%q) = %v", lis.Addr().String(), err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These log messages are suggested by Easwar's in other PR. Please see the discussion using the below links.

#7967 (comment)
#7967 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think Easwar expected you to change log messages throughout the entire repo. The log messages are relatively harmless and can be fixed incrementally when people work on these parts of the codebase. Fixing them in a PR with real code changes makes it hard for reviewers to focus on the important parts.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert this file as all the changes are only in error messages.

@@ -166,7 +165,7 @@ func (s) TestEndpointShardingBasic(t *testing.T) {
}
cc, err := grpc.NewClient(mr.Scheme()+":///", dOpts...)
if err != nil {
log.Fatalf("Failed to create new client: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please only change log to t, the error message is fine.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert changes in this file as they are only error message changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert changes in this file as they are only error message changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert.

@@ -308,7 +308,7 @@ func (s) TestCZTopChannelRegistrationAndDeletionWhenDialFail(t *testing.T) {
// Make dial fails (due to no transport security specified)
_, err := grpc.NewClient("fake.addr")
if err == nil {
t.Fatal("expecting dial to fail")
t.Fatalf("grpc.NewClient() failed: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

The message being replaced was the opposite, please fix.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert.

@@ -274,7 +274,6 @@ func (te *test) clientConn() *grpc.ClientConn {
}
opts := []grpc.DialOption{
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithBlock(),
Copy link
Contributor

Choose a reason for hiding this comment

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

If you are removing WithBlock, you need to ensure the clientconn is ready before the function returns it. I ssupect this is the reason for the race conditions that you're seeing. Please use cc.Connect and testutils.AwaitState here to restore the behviour.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing that out — you're absolutely right. Removing WithBlock without ensuring the connection is ready was likely the cause of the race conditions. I've now updated the code to call cc.Connect() and use testutils.AwaitState to properly wait for Ready before returning. Apologies for overlooking this earlier!

Comment on lines 789 to 801
func checkPickerUpdated(t *testing.T, d *gotData, e *expectedData) {
var (
ok bool
st *stats.PickerUpdated
)
if st, ok = d.s.(*stats.PickerUpdated); !ok {
t.Fatalf("got %T, want PickerUpdated", d.s)
}
if d.ctx == nil {
t.Fatalf("d.ctx = nil, want <non-nil>")
}
st.IsClient() // TODO remove this.
}
Copy link
Contributor

@arjan-bal arjan-bal Apr 28, 2025

Choose a reason for hiding this comment

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

Please revert any assertion changes, we don't want to change the test logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

reverted

Copy link

codecov bot commented Apr 29, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.16%. Comparing base (b0d1203) to head (6fb73b9).
Report is 39 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8196      +/-   ##
==========================================
+ Coverage   82.06%   82.16%   +0.09%     
==========================================
  Files         410      417       +7     
  Lines       40233    41356    +1123     
==========================================
+ Hits        33018    33979     +961     
- Misses       5854     5950      +96     
- Partials     1361     1427      +66     
Files with missing lines Coverage Δ
credentials/insecure/insecure.go 81.81% <ø> (ø)
dialoptions.go 90.80% <ø> (ø)

... and 95 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@janardhanvissa
Copy link
Contributor Author

I've addressed all the comments by reverting the changes related to log message updates and fixing the race condition by calling cc.Connect() and using AwaitState to wait for the READY state.

@janardhanvissa janardhanvissa removed their assignment Apr 30, 2025
@vinothkumarr227
Copy link
Contributor

@arjan-bal I think Janardhan has reverted the unnecessary changes in the PR. It should be ready for review now.

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.

4 participants