-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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: Add server features support to Bootstrapper #7271
Changes from 1 commit
0b1b9d9
fe503de
cef5941
d8a8d70
c700e81
f4de628
f592405
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -602,6 +602,7 @@ public synchronized XdsClient returnObject(Object object) { | |
*/ | ||
abstract static class XdsChannelFactory { | ||
private static final XdsChannelFactory DEFAULT_INSTANCE = new XdsChannelFactory() { | ||
List<?> serverFeatures; | ||
|
||
/** | ||
* Creates a channel to the first server in the given list. | ||
|
@@ -611,6 +612,7 @@ ManagedChannel createChannel(List<ServerInfo> servers) { | |
checkArgument(!servers.isEmpty(), "No management server provided."); | ||
XdsLogger logger = XdsLogger.withPrefix("xds-client-channel-factory"); | ||
ServerInfo serverInfo = servers.get(0); | ||
serverFeatures = serverInfo.getServerFeatures(); | ||
String serverUri = serverInfo.getServerUri(); | ||
logger.log(XdsLogLevel.INFO, "Creating channel to {0}", serverUri); | ||
List<ChannelCreds> channelCredsList = serverInfo.getChannelCredentials(); | ||
|
@@ -633,6 +635,11 @@ ManagedChannel createChannel(List<ServerInfo> servers) { | |
.keepAliveTime(5, TimeUnit.MINUTES) | ||
.build(); | ||
} | ||
|
||
@Override | ||
List<?> getSelectedServerFeatures() { | ||
return serverFeatures; | ||
} | ||
}; | ||
|
||
static XdsChannelFactory getInstance() { | ||
|
@@ -643,5 +650,14 @@ static XdsChannelFactory getInstance() { | |
* Creates a channel to one of the provided management servers. | ||
*/ | ||
abstract ManagedChannel createChannel(List<ServerInfo> servers); | ||
|
||
/** | ||
* Gets features of the server that the channel is created for. Value is only available | ||
* after {@link #createChannel} is called. | ||
*/ | ||
@Nullable | ||
List<?> getSelectedServerFeatures() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't make sense to put such an API here. This makes a factory class stateful. Maybe it is time to eliminate Last time when I was doing some local e2e test for traffic splitting and routing, the gRPC channel is using plaintext, but the xDS channel is fixed to use TLS (if not google_default) instead of falling back to use the same configuration as its parent channel. This is broken for Java. It is not bitting us because we are always using TLS if not google_default in production. We should support such a feature correctly. Basically, the creation of xDS channel will be done outside XdsClientImpl. For EDS only's code path, we are roughly able to do it with For now, I think a better way is to change the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem is coming from the factory or whatever structure being used for XdsClientIml consumes a list of server_urls. When you create the channel from it, you must know the index of the server_url that is selected, so that you can know the corresponding server feature. If it's only a single server_url, there is no problem at all. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A workaround is we pass just one There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is what I mean:
The output of creating channel contains the server feature. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also thought about that, which introduces yet another class and I had thought you wouldn't like it. I'm totally okay with it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. :( Why would you think introducing a new class is bad? 😢 This looks fairly natural with channel and protocol feature encapsulated together. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
return null; | ||
} | ||
} | ||
} |
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.
Given that the format of server_features is undefined. Maybe it's better to just parse it to a String list.
The parser should not try to interpret what is being parsed. It's just a list of string. "xds_v3" should be defined in the consumer class, which is
XdsChannelFactory
(e.g.,String PROTOCOL_VERSION = "xds_v3
). The channel factory looks up the parsed server features and check if the expected protocol version setting is there.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.
The log here should just print out what is parsed literally.
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.
What do you mean actually? The following?
Or just pick all string type items in the list?
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, just use
JsonUtil.getListOfStrings
.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.