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: fail to create xDS channel if no server with supported channel creds found #7400

Merged

Conversation

voidzcy
Copy link
Contributor

@voidzcy voidzcy commented Sep 8, 2020

Follow up for #7396.

The main change is to create the xDS channel outside XdsClient and creating the xDS channel can fail.

@voidzcy voidzcy force-pushed the impl/fail_to_create_xds_channel_if_needed branch from c1f54ce to 612b791 Compare September 15, 2020 19:28
@voidzcy voidzcy marked this pull request as ready for review September 15, 2020 19:29
@@ -129,8 +128,10 @@ public void handleResolvedAddresses(ResolvedAddresses resolvedAddresses) {
xdsClientPool = attributes.get(XdsAttributes.XDS_CLIENT_POOL);
if (xdsClientPool == null) {
final BootstrapInfo bootstrapInfo;
final XdsChannel channel;
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 EDS-only codepath will be deleted in #7391.

@@ -687,8 +623,4 @@ boolean isUseProtocolV3() {
return useProtocolV3;
}
}

interface XdsClientPoolFactory {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

More cleanup to be done to put RefCountedXdsClientObjectPool into its own file.

Copy link
Member

@dapengzhang0 dapengzhang0 left a comment

Choose a reason for hiding this comment

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

It would be easier to review if the first commit Move XdsChannelFactory to its own file and improve tests. is split into two commits with one pure move and the other pure modification; and moving interface XdsClientPoolFactory is not scattered in the first and third commit.

@Test
public void defaultUseV2ProtocolL() throws XdsInitializationException {
XdsChannel channel = createChannel(server1);
assertThat(channel.isUseProtocolV3()).isFalse();
Copy link
Member

Choose a reason for hiding this comment

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

You should also check
server1 with experimentalV3SupportEnvVar = true
and
server2 with experimentalV3SupportEnvVar = false
still do not support v3.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm... Doesn't need to be that throughout, right? It makes tests noisy to test trivial things deeply.

server1 with experimentalV3SupportEnvVar = true and server2 with experimentalV3SupportEnvVar = false

This really just tests the functionality of the environment variable, which is a temporary gate. IMO, we shouldn't bother testing it. Unit tests can also introduces bugs, so if something is trivial in implementation, we won't bother write tests for it.

@voidzcy
Copy link
Contributor Author

voidzcy commented Sep 18, 2020

It would be easier to review if the first commit Move XdsChannelFactory to its own file and improve tests. is split into two commits with one pure move and the other pure modification; and moving interface XdsClientPoolFactory is not scattered in the first and third commit.

I am sorry, commits are a bit screwed up.. 😢

*/
@Override
XdsChannel createChannel(List<ServerInfo> servers) throws XdsInitializationException {
checkArgument(!servers.isEmpty(), "No management server provided.");
Copy link
Member

Choose a reason for hiding this comment

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

Might as well throw XdsInitializationException?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Fixed.

@voidzcy voidzcy merged commit b31d683 into grpc:master Sep 19, 2020
dfawley pushed a commit to dfawley/grpc-java that referenced this pull request Jan 15, 2021
…reds found (grpc#7400)

Create the xDS channel outside the XdsClient. Throw an XdsInitializationException if the provided server list (parsed from the bootstrap file) can not be used to create such a channel. The exception is caught by the xDS resolver and propagated to the Channel gracefully as a name resolution error.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants