-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Conversation
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done; PTAL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant in xdsresource.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Still LGTM, go ahead and merge. |
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