-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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: make comparison of server configs in bootstrap more reliable #6112
Conversation
@arvindbr8 : FYI, this change could cause merge conflicts with your A53 PR. Also, I don't remember where you are storing the |
fcf0c22
to
e71d352
Compare
e71d352
to
cf10dac
Compare
// Also ensure that a new LRS stream is not created. | ||
sCtx, sCancel = context.WithTimeout(ctx, defaultTestShortTimeout) | ||
defer sCancel() | ||
if _, err := mgmtServer.LRSServer.LRSStreamOpenChan.Receive(ctx); err == nil { |
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.
This should be sCtx
, right? Otherwise this waits 10 seconds?
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.
Oh yeah, thanks.
features := "" | ||
if len(sc.ServerFeatures) != 0 { | ||
features = strings.Join(sc.ServerFeatures, "-") | ||
} |
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.
Since strings.Join
returns ""
when given an empty slice, this can be simplified to:
features := strings.Join(sc.ServerFeatures, "-")
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, thanks.
case (sc != nil) != (other != nil): | ||
return false |
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.
FWIW: if sc == nil || other == nil
is equivalent given the preceding case
; I'm not sure which is more readable, but I find this form with 3 !=
s to be a little confusing, personally.
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 agree that sc == nil || other == nil
is much easier to read than (sc != nil) != (other != nil)
when considered in isolation. But when used here, the former requires carrying over of state from the previous case
, because we need to remember that both are not nil
to make complete sense of this statement. But the latter is more self-contained as it simply compares the nil
ness of one with the other.
I think I might have written it as if sc == nil || other == nil
if I had written this whole method as a series of if
conditions, instead of a case statement.
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.
Thanks for the review.
// Also ensure that a new LRS stream is not created. | ||
sCtx, sCancel = context.WithTimeout(ctx, defaultTestShortTimeout) | ||
defer sCancel() | ||
if _, err := mgmtServer.LRSServer.LRSStreamOpenChan.Receive(ctx); err == nil { |
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.
Oh yeah, thanks.
features := "" | ||
if len(sc.ServerFeatures) != 0 { | ||
features = strings.Join(sc.ServerFeatures, "-") | ||
} |
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, thanks.
case (sc != nil) != (other != nil): | ||
return false |
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 agree that sc == nil || other == nil
is much easier to read than (sc != nil) != (other != nil)
when considered in isolation. But when used here, the former requires carrying over of state from the previous case
, because we need to remember that both are not nil
to make complete sense of this statement. But the latter is more self-contained as it simply compares the nil
ness of one with the other.
I think I might have written it as if sc == nil || other == nil
if I had written this whole method as a series of if
conditions, instead of a case statement.
When the
clusterimpl
LB policy receives a config update, it checks if theload_reporting_server
configuration has changed. If so, it closes the existing LRS stream and creates a new one.Unfortunately this equality comparison was broken because the
bootstrap.ServerConfig
struct contains agrpc.DialOption
to store the configured credentials. The implemention of this dial option (like many others) uses a function pointer which is not very amenable to comparisons. So, even if two configuration specify the same transport credentials, the equality comparison will fail.This PR addresses this issue and ensures that the LRS stream is not closed and re-created when the actual
load_reporting_server
config has not changed.Summary of changes:
ChannelCreds
type in the bootstrap package to representchannel_credentials
specified as part of the server config.ServerConfig
type in the bootstrap package in the following ways:ChannelCreds
type.ServerConfigFromJSON
.server_features
as part of the server config. This also needs to be used for equality comparisons.This fixes an internal P1 issue that is blocking the federation release.
Fixes #6097
RELEASE NOTES: