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

grpc-js: xDS: handle insecure and google_default bootstrap creds #1568

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions packages/grpc-js/src/xds-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import * as protoLoader from '@grpc/proto-loader';
import { loadPackageDefinition } from './make-client';
import * as adsTypes from './generated/ads';
import * as lrsTypes from './generated/lrs';
import { createGoogleDefaultCredentials } from './channel-credentials';
import { createGoogleDefaultCredentials, ChannelCredentials } from './channel-credentials';
import { loadBootstrapInfo } from './xds-bootstrap';
import { ClientDuplexStream, ServiceError } from './call';
import { StatusObject } from './call-stream';
Expand Down Expand Up @@ -805,17 +805,38 @@ export class XdsClient {
...node,
client_features: ['envoy.lrs.supports_send_all_clusters'],
};
const credentialsConfigs = bootstrapInfo.xdsServers[0].channelCreds;
let channelCreds: ChannelCredentials | null = null;
for (const config of credentialsConfigs) {
if (config.type === 'google_default') {
channelCreds = createGoogleDefaultCredentials();
break;
} else if (config.type === 'insecure') {
channelCreds = ChannelCredentials.createInsecure();
break;
}
}
if (channelCreds === null) {
trace('Failed to initialize xDS Client. No valid credentials types found.');
// Bubble this error up to any listeners
this.reportStreamError({
code: Status.INTERNAL,
details: 'Failed to initialize xDS Client. No valid credentials types found.',
metadata: new Metadata(),
});
return;
}
trace('Starting xDS client connected to server URI ' + bootstrapInfo.xdsServers[0].serverUri);
this.adsClient = new protoDefinitions.envoy.service.discovery.v2.AggregatedDiscoveryService(
bootstrapInfo.xdsServers[0].serverUri,
createGoogleDefaultCredentials(),
channelCreds,
channelArgs
);
this.maybeStartAdsStream();

this.lrsClient = new protoDefinitions.envoy.service.load_stats.v2.LoadReportingService(
bootstrapInfo.xdsServers[0].serverUri,
createGoogleDefaultCredentials(),
channelCreds,
{channelOverride: this.adsClient.getChannel()}
);
this.maybeStartLrsStream();
Expand Down