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: make xds client a singleton #4015

Merged
merged 5 commits into from
Nov 12, 2020
Merged

Conversation

menghanl
Copy link
Contributor

@menghanl menghanl commented Nov 5, 2020

  • 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()

@menghanl menghanl added the Type: Feature New features or improvements in behavior label Nov 5, 2020
@menghanl menghanl added this to the 1.34 Release milestone Nov 5, 2020
@menghanl menghanl requested a review from easwars November 5, 2020 19:16
@menghanl
Copy link
Contributor Author

menghanl commented Nov 5, 2020

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

Copy link
Contributor

@easwars easwars left a 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.

type clientImpl struct {
done *grpcsync.Event
config *bootstrap.Config
cc *grpc.ClientConn // Connection to the xDS server
Copy link
Contributor

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

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.

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.
Copy link
Contributor

Choose a reason for hiding this comment

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

s/cross/across

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

}
}

// NewWithConfigForTesting is exported for testing only. For prod uses, call
Copy link
Contributor

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?

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.

watchExpiryTimeout := time.Duration(0)
if overrideWatchExpiryTImeout {
func clientOpts(balancerName string, overrideWatchExpiryTimeout bool) (*bootstrap.Config, time.Duration) {
watchExpiryTimeout := time.Second * 15
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe: watchExpiryTimeout := defaultWatchExpiryTimeout?

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

xds/internal/client/tests/client_test.go Show resolved Hide resolved
xds/internal/client/client.go Show resolved Hide resolved
@easwars easwars assigned menghanl and unassigned easwars Nov 9, 2020
@menghanl menghanl assigned easwars and unassigned menghanl Nov 9, 2020
@@ -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
Copy link
Contributor

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/

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

Creds: grpc.WithInsecure(),
NodeProto: &v2corepb.Node{},
TransportAPI: version.TransportV2,
}, 15*time.Second)
Copy link
Contributor

Choose a reason for hiding this comment

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

Use the const here?

Copy link
Contributor Author

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.
Copy link
Contributor

Choose a reason for hiding this comment

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

s/an/a

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

@easwars easwars assigned menghanl and unassigned easwars Nov 10, 2020
- 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()
@menghanl menghanl merged commit 6caf9d8 into grpc:master Nov 12, 2020
@menghanl menghanl deleted the xds_client_singleton branch November 12, 2020 19:08
davidkhala pushed a commit to Hyperledger-TWGC/grpc that referenced this pull request Dec 7, 2020
- 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()
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 25, 2021
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.

None yet

2 participants