-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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 xds client a singleton #4015
Conversation
menghanl
commented
Nov 5, 2020
•
edited
edited
- xdsclient.New() no longer takes any input, all configs are from bootstrap file
- added a NewForTesting()
- The returned *Client is a wrapper of the underlying client implementation, for ref-couting
- xds-resolver and xds-server no longer calls bootstrap.NewConfig. It only calls xdsclient.New()
This PR doesn't include the change in balancers to call xdsclient.New() (instead of getting client from attributes). Will make that change in a separate PR (because it touches many tests). |
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.
Looks good overall. Some minor nits.
xds/internal/client/client.go
Outdated
type clientImpl struct { | ||
done *grpcsync.Event | ||
config *bootstrap.Config | ||
cc *grpc.ClientConn // Connection to the xDS server |
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.
Nit: can we call it the management server
instead. Since we have a server-side implementation of xDS now, it is confusing when we say xDS server
. Would be better to be unambiguous going forward:
- xDS-enabled gRPC server: to refer to our xDS implementation on the server side
- management server or control plane: to refer to the server implementing the xDS protocol
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.
We have "xDS server" all over the tests. Didn't update all of them.
I think in writing, it's not that bad, we probably will write xds.Server to refer to the gRPC server.
// various dynamic resources. | ||
// | ||
// The xds client is a singleton. It will be shared by the xds resolver and | ||
// balancer implementations, cross multiple ClientConns and Servers. |
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.
s/cross/across
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
} | ||
} | ||
|
||
// NewWithConfigForTesting is exported for testing only. For prod uses, call |
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.
Maybe we can skip the For prod uses, call New().
part?
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.
xds/internal/client/client_test.go
Outdated
watchExpiryTimeout := time.Duration(0) | ||
if overrideWatchExpiryTImeout { | ||
func clientOpts(balancerName string, overrideWatchExpiryTimeout bool) (*bootstrap.Config, time.Duration) { | ||
watchExpiryTimeout := time.Second * 15 |
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.
Maybe: watchExpiryTimeout := defaultWatchExpiryTimeout
?
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
@@ -61,10 +61,10 @@ var gRPCVersion = fmt.Sprintf("%s %s", gRPCUserAgentName, grpc.Version) | |||
var bootstrapFileReadFunc = ioutil.ReadFile | |||
|
|||
// Config provides the xDS client with several key bits of information that it | |||
// requires in its interaction with an xDS server. The Config is initialized | |||
// from the bootstrap file. | |||
// requires in its interaction with an management server. The Config is |
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.
Nit: s/an management server/the management server/
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
Creds: grpc.WithInsecure(), | ||
NodeProto: &v2corepb.Node{}, | ||
TransportAPI: version.TransportV2, | ||
}, 15*time.Second) |
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.
Use the const here?
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 test is in a different package (because it needs to import v2
).
I added a const for it.
@@ -16,7 +16,7 @@ | |||
* | |||
*/ | |||
|
|||
// Package fakeserver provides a fake implementation of an xDS server. | |||
// Package fakeserver provides a fake implementation of an management server. |
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.
s/an/a
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
- xdsclient.New() no longer takes any input, all configs are from bootstrap file - added a NewForTesting() - The returned *Client is a wrapper of the underlying client implementation, for ref-couting - xds-resolver no longer calls bootstrap.NewConfig. It only calls xdsclient.New()
799ef3e
to
81d73d6
Compare
- xdsclient.New() no longer takes any input, all configs are from bootstrap file - added a NewForTesting() - The returned *Client is a wrapper of the underlying client implementation, for ref-couting - xds-resolver and xds-server no longer calls bootstrap.NewConfig. It only calls xdsclient.New()