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

xds/resolver: generate channel ID randomly #5591

Merged
merged 3 commits into from
Aug 22, 2022

Conversation

dfawley
Copy link
Member

@dfawley dfawley commented Aug 17, 2022

This change keeps our code in sync with the spec change at grpc/proposal#320. We would rather generate a purely random number for this identifier to ensure different clients are extremely unlikely to generate the same identifier.

cc @apolcyn

RELEASE NOTES: none

@dfawley dfawley added the Type: Feature New features or improvements in behavior label Aug 17, 2022
@dfawley dfawley added this to the 1.50 Release milestone Aug 17, 2022
@dfawley dfawley requested a review from zasweq August 17, 2022 23:27
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.

Some nits.

// Hash the ClientConn pointer which logically uniquely
// identifies the client.
policyHash = xxhash.Sum64String(fmt.Sprintf("%p", &cs.r.cc))
policyHash = cs.r.clientID
Copy link
Contributor

Choose a reason for hiding this comment

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

Update HashPolicyTypeChannelID's comment please.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done; PTAL

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant in xdsresource.

Copy link
Member Author

Choose a reason for hiding this comment

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

Whoops. Done.

@@ -184,6 +186,9 @@ type xdsResolver struct {
activeClusters map[string]*clusterInfo

curConfigSelector *configSelector

// A random number which uniquely identifies this client.
clientID uint64
Copy link
Contributor

Choose a reason for hiding this comment

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

Switch to channelID? Also comment feels weird, "this client" in a resolver. I know the Client Conn owns this resolver with a 1:1 cardinality but this comment feels weird.

Copy link
Member Author

Choose a reason for hiding this comment

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

Switched. Not sure about "feels weird" or how to resolve that, but I changed the comment a bit. In the future please be more specific about what's wrong and/or how you would fix it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah sorry I meant this client is in reference to what? Your comment change works for me.

@zasweq zasweq assigned dfawley and unassigned zasweq Aug 19, 2022
@dfawley dfawley assigned zasweq and unassigned dfawley Aug 19, 2022
@zasweq zasweq assigned dfawley and unassigned zasweq Aug 20, 2022
@zasweq
Copy link
Contributor

zasweq commented Aug 22, 2022

Still LGTM, go ahead and merge.

@zasweq zasweq assigned zasweq and dfawley and unassigned dfawley and zasweq Aug 22, 2022
@dfawley dfawley changed the title xds/resolver: generate client ID randomly xds/resolver: generate channel ID randomly Aug 22, 2022
@dfawley dfawley merged commit 02fbca0 into grpc:master Aug 22, 2022
@dfawley dfawley deleted the randomPolicyHash branch August 22, 2022 19:53
dfawley added a commit to dfawley/grpc-go that referenced this pull request Aug 23, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Feature New features or improvements in behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants