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 channel creds required in bootstrap file #7396
Changes from 1 commit
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 |
---|---|---|
|
@@ -101,19 +101,19 @@ public static BootstrapInfo parseConfig(String rawData) throws IOException { | |
logger.log(XdsLogLevel.INFO, "xDS server URI: {0}", serverUri); | ||
List<ChannelCreds> channelCredsOptions = new ArrayList<>(); | ||
List<?> rawChannelCredsList = JsonUtil.getList(serverConfig, "channel_creds"); | ||
// List of channel creds is optional. | ||
if (rawChannelCredsList != null) { | ||
List<Map<String, ?>> channelCredsList = JsonUtil.checkObjectList(rawChannelCredsList); | ||
for (Map<String, ?> channelCreds : channelCredsList) { | ||
String type = JsonUtil.getString(channelCreds, "type"); | ||
if (type == null) { | ||
throw new IOException("Invalid bootstrap: 'xds_servers' contains server with " | ||
+ "unknown type 'channel_creds'."); | ||
} | ||
logger.log(XdsLogLevel.INFO, "Channel credentials option: {0}", type); | ||
ChannelCreds creds = new ChannelCreds(type, JsonUtil.getObject(channelCreds, "config")); | ||
channelCredsOptions.add(creds); | ||
if (rawChannelCredsList == null) { | ||
throw new IOException("Invalid bootstrap: 'channel_creds' required"); | ||
} | ||
List<Map<String, ?>> channelCredsList = JsonUtil.checkObjectList(rawChannelCredsList); | ||
for (Map<String, ?> channelCreds : channelCredsList) { | ||
String type = JsonUtil.getString(channelCreds, "type"); | ||
if (type == null) { | ||
throw new IOException("Invalid bootstrap: 'xds_servers' contains server with " | ||
+ "unknown type 'channel_creds'."); | ||
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 the case of 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. What I mean here is for "type unspecified". Reading bootstrap file should not contain the logic for interpreting the type that gRPC supports, that should be done at the time when the channel creds is actually used. Say the bootstrap file provides 100 channel creds options, the parser should not try to look up and check one by one. Only at the time this information is used, it would interpret it: going through the list to find the first one that gRPC supports. If none can be found, the gRPC client fails. 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's confusing to see "unknown type" while type not provided. "unknown type" sounds more like user provides a type but it's not recognized. "with type unspecified" might be more clear. 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. Sure, fixed the message. |
||
} | ||
logger.log(XdsLogLevel.INFO, "Channel credentials option: {0}", type); | ||
ChannelCreds creds = new ChannelCreds(type, JsonUtil.getObject(channelCreds, "config")); | ||
channelCredsOptions.add(creds); | ||
} | ||
List<String> serverFeatures = JsonUtil.getListOfStrings(serverConfig, "server_features"); | ||
if (serverFeatures != 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.
How about?
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.
Sounds fair. Updated to not allow empty list.