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: Canonicalize string returned by ClientConn.Target() and resolver.Address.String() #6923

Merged
merged 4 commits into from Feb 15, 2024

Conversation

zasweq
Copy link
Contributor

@zasweq zasweq commented Jan 17, 2024

This PR canoncializes the string returned from Target() on the ClientConn. This is a behavior change, but ok because API is marked experimental.

RELEASE NOTES:

  • grpc: Canonicalize string returned by ClientConn.Target() and resolver.Address.String()

@zasweq zasweq added the Type: API Change Breaking API changes (experimental APIs only!) label Jan 17, 2024
@zasweq zasweq added this to the 1.61 Release milestone Jan 17, 2024
@zasweq zasweq requested a review from dfawley January 17, 2024 00:42
Copy link

codecov bot commented Jan 17, 2024

Codecov Report

Merging #6923 (756a69f) into master (ddd377f) will decrease coverage by 1.18%.
Report is 28 commits behind head on master.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6923      +/-   ##
==========================================
- Coverage   83.51%   82.34%   -1.18%     
==========================================
  Files         287      296       +9     
  Lines       30920    31453     +533     
==========================================
+ Hits        25824    25900      +76     
- Misses       4020     4491     +471     
+ Partials     1076     1062      -14     
Files Coverage Δ
clientconn.go 90.75% <100.00%> (-0.36%) ⬇️
resolver/resolver.go 94.44% <100.00%> (ø)

... and 46 files with indirect coverage changes

@zasweq
Copy link
Contributor Author

zasweq commented Jan 17, 2024

Discussed offline; currently adding more test cases (and made a t-test)

@dfawley dfawley added Type: Behavior Change Behavior changes not categorized as bugs and removed Type: API Change Breaking API changes (experimental APIs only!) labels Jan 17, 2024
@dfawley dfawley changed the title grpc: Canonicalize target string on ClientConn grpc: Canonicalize string returned by ClientConn.Target() and resolver.Address.String() Jan 17, 2024
@dfawley dfawley assigned zasweq and unassigned dfawley Jan 17, 2024
@dfawley
Copy link
Member

dfawley commented Jan 17, 2024

Change LGTM; let me know when you add more tests.

@zasweq zasweq modified the milestones: 1.61 Release, 1.62 Release Jan 23, 2024
@zasweq
Copy link
Contributor Author

zasweq commented Feb 2, 2024

Added a t-test.

@zasweq zasweq assigned dfawley and unassigned zasweq Feb 2, 2024
clientconn.go Outdated
@@ -883,14 +883,14 @@ func (cc *ClientConn) channelzMetric() *channelz.ChannelInternalMetric {
}
}

// Target returns the target string of the ClientConn.
// Target returns the canonicalized target string of the ClientConn.
Copy link
Member

Choose a reason for hiding this comment

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

Let's use "canonical" since "canonicalize" isn't a word.

Target returns the canonical target string...

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 haha.

@@ -283,7 +283,7 @@ func (t Target) Endpoint() string {

// String returns a string representation of Target.
Copy link
Member

Choose a reason for hiding this comment

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

add "canonical".

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 827 to 831
{
name: "canonicalized-target-nonexistent",
addr: "nonexist:///non.existent",
targetWant: "passthrough:///nonexist:///non.existent",
},
Copy link
Member

Choose a reason for hiding this comment

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

Also test dns:hostname:port->dns:///hostname:port.

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.

@zasweq zasweq assigned zasweq and unassigned dfawley Feb 5, 2024
@zasweq zasweq assigned dfawley and unassigned zasweq Feb 5, 2024
@ginayeh ginayeh modified the milestones: 1.62 Release, 1.63 Release Feb 8, 2024
@@ -281,9 +281,9 @@ func (t Target) Endpoint() string {
return strings.TrimPrefix(endpoint, "/")
}

// String returns a string representation of Target.
// String returns a canonical string representation of Target.
Copy link
Member

Choose a reason for hiding this comment

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

Super nit: "the canonical", please... there is only one canonical version of something.

@dfawley dfawley assigned zasweq and unassigned dfawley Feb 15, 2024
@zasweq zasweq merged commit 3ae77e6 into grpc:master Feb 15, 2024
14 checks passed
arvindbr8 added a commit to arvindbr8/grpc-go that referenced this pull request Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Behavior Change Behavior changes not categorized as bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants