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

cleanup: replace dial with newclient #7920

Merged
merged 18 commits into from
Dec 18, 2024

Conversation

janardhanvissa
Copy link
Contributor

@janardhanvissa janardhanvissa commented Dec 11, 2024

Partially address: #7049

RELEASE NOTES: None

@arjan-bal
Copy link
Contributor

The tests are failing, please fix the failures. In the future, please ensure that tests pass locally before raising a PR.

go test ./... -count=1 -failfast                                                         

@arjan-bal arjan-bal self-requested a review December 11, 2024 05:26
@arjan-bal arjan-bal added the Type: Internal Cleanup Refactors, etc label Dec 11, 2024
@arjan-bal arjan-bal added this to the 1.70 Release milestone Dec 11, 2024
@janardhanvissa
Copy link
Contributor Author

The tests are failing, please fix the failures. In the future, please ensure that tests pass locally before raising a PR.

go test ./... -count=1 -failfast                                                         

I have tested locally before pushing the code, nothing is failing. Let me re-trigger the PR.

@janardhanvissa janardhanvissa force-pushed the newclient-insteadof-dial branch from c5b8178 to 76915bd Compare December 11, 2024 10:20
test/creds_test.go Outdated Show resolved Hide resolved
test/creds_test.go Outdated Show resolved Hide resolved
resolver_balancer_ext_test.go Outdated Show resolved Hide resolved
test/creds_test.go Outdated Show resolved Hide resolved
test/creds_test.go Outdated Show resolved Hide resolved
@arjan-bal
Copy link
Contributor

arjan-bal commented Dec 13, 2024

The test failure for the new pickfirst policy seem to be because the DNS resolver is resolving localhost to both the IPv4 and IPv6 addresses, while the server listens only on the IPv4 address. Can you change the following line to la := "[::]:0" and see if the test passes?

la := "localhost:0"

This should make the server listen on both the IPv4 and IPv6 localhost addresses.

Copy link

codecov bot commented Dec 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.29%. Comparing base (e4d084a) to head (93a17b6).
Report is 9 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7920      +/-   ##
==========================================
+ Coverage   82.05%   82.29%   +0.23%     
==========================================
  Files         377      379       +2     
  Lines       38180    38261      +81     
==========================================
+ Hits        31330    31487     +157     
+ Misses       5549     5491      -58     
+ Partials     1301     1283      -18     

see 37 files with indirect coverage changes

@janardhanvissa
Copy link
Contributor Author

The test failure for the new pickfirst policy seem to be because the DNS resolver is resolving localhost to both the IPv4 and IPv6 addresses, while the server listens only on the IPv4 address. Can you change the following line to la := "[::]:0" and see if the test passes?

la := "localhost:0"

This should make the server listen on both the IPv4 and IPv6 localhost addresses.

Yeah, it's working, thanks

balancer/grpclb/grpclb_test.go Show resolved Hide resolved
balancer/grpclb/grpclb_test.go Show resolved Hide resolved
@@ -609,7 +609,7 @@ func (te *test) listenAndServe(ts testgrpc.TestServiceServer, listen func(networ
if te.serverInitialConnWindowSize > 0 {
sopts = append(sopts, grpc.InitialConnWindowSize(te.serverInitialConnWindowSize))
}
la := "localhost:0"
la := "[::]:0"
Copy link
Contributor

@arjan-bal arjan-bal Dec 16, 2024

Choose a reason for hiding this comment

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

@dfawley this is required to fix test failures with the new pickfirst. localhost is being resolved to both IPv4 and IPv6 addresses on Github, while net.Listen("tcp", "localhost") is listening only on the IPv4 address. The resolver list has the IPv4 address followed by the IPv6 one. The old pickfirst reports the first connectivity error while the new pickfirst reports the latest error.

Using [::] makes the listener bind to all (possibly non-local) interfaces. Is this a concern? We could instead update the test to send "127.0.0.1" through the name resolver.

Copy link
Member

Choose a reason for hiding this comment

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

We should avoid net.Listen("localhost"), and use net.Listen(":port") instead. That will make it listen on both ipv4 and ipv6 addresses.

Copy link
Contributor

Choose a reason for hiding this comment

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

@janardhanvissa can you please change this to ":0"?

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

@@ -460,7 +460,7 @@ func (s) TestGRPCLB_Basic(t *testing.T) {
}
cc, err := grpc.NewClient(r.Scheme()+":///"+beServerName, dopts...)
if err != nil {
t.Fatalf("Failed to dial to the backend %v", err)
t.Fatalf("Failed to create a newclient to the backend %v", err)
Copy link
Member

Choose a reason for hiding this comment

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

Nit: "... create a client for the backend" everywhere, please.

OR, ("grpc.NewClient(%q) failed unexpectedly: %v", target, err)

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

@@ -609,7 +609,7 @@ func (te *test) listenAndServe(ts testgrpc.TestServiceServer, listen func(networ
if te.serverInitialConnWindowSize > 0 {
sopts = append(sopts, grpc.InitialConnWindowSize(te.serverInitialConnWindowSize))
}
la := "localhost:0"
la := "[::]:0"
Copy link
Member

Choose a reason for hiding this comment

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

We should avoid net.Listen("localhost"), and use net.Listen(":port") instead. That will make it listen on both ipv4 and ipv6 addresses.

@dfawley dfawley removed their assignment Dec 16, 2024
@janardhanvissa janardhanvissa force-pushed the newclient-insteadof-dial branch from cc0aa2e to 647c7d2 Compare December 17, 2024 18:34
@arjan-bal arjan-bal assigned dfawley and unassigned janardhanvissa Dec 17, 2024
@dfawley dfawley merged commit 56a14ba into grpc:master Dec 18, 2024
15 checks passed
vinothkumarr227 pushed a commit to vinothkumarr227/grpc-go that referenced this pull request Dec 23, 2024
vinothkumarr227 added a commit to vinothkumarr227/grpc-go that referenced this pull request Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants