Skip to content

Commit 6cea491

Browse files
authored
Merge pull request #1917 from murgatroid99/grpc-js-xds_test_fixes
grpc-js-xds: A few fixes for xDS tests
2 parents 5e8f5fa + 1eea4b7 commit 6cea491

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

packages/grpc-js-xds/scripts/xds.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ GRPC_NODE_TRACE=xds_client,xds_resolver,cds_balancer,eds_balancer,priority,weigh
5959
--gcp_suffix=$(date '+%s') \
6060
--verbose \
6161
${XDS_V3_OPT-} \
62-
--client_cmd="$(which node) grpc-node/packages/grpc-js-xds/build/interop/xds-interop-client \
62+
--client_cmd="$(which node) --enable-source-maps grpc-node/packages/grpc-js-xds/build/interop/xds-interop-client \
6363
--server=xds:///{server_uri} \
6464
--stats_port={stats_port} \
6565
--qps={qps} \

packages/grpc-js-xds/src/xds-bootstrap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function validateXdsServerConfig(obj: any): XdsServerConfig {
109109
return {
110110
serverUri: obj.server_uri,
111111
channelCreds: obj.channel_creds.map(validateChannelCredsConfig),
112-
serverFeatures: obj.server_features
112+
serverFeatures: obj.server_features ?? []
113113
};
114114
}
115115

packages/grpc-js-xds/src/xds-client.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,16 @@ export class XdsClient {
341341
return;
342342
}
343343
trace('Loaded bootstrap info: ' + JSON.stringify(bootstrapInfo, undefined, 2));
344+
if (bootstrapInfo.xdsServers.length < 1) {
345+
trace('Failed to initialize xDS Client. No servers provided in bootstrap info.');
346+
// Bubble this error up to any listeners
347+
this.reportStreamError({
348+
code: status.INTERNAL,
349+
details: 'Failed to initialize xDS Client. No servers provided in bootstrap info.',
350+
metadata: new Metadata(),
351+
});
352+
return;
353+
}
344354
if (bootstrapInfo.xdsServers[0].serverFeatures.indexOf('xds_v3') >= 0) {
345355
this.apiVersion = XdsApiVersion.V3;
346356
} else {
@@ -425,8 +435,7 @@ export class XdsClient {
425435
{channelOverride: channel}
426436
);
427437
this.maybeStartLrsStream();
428-
},
429-
(error) => {
438+
}).catch((error) => {
430439
trace('Failed to initialize xDS Client. ' + error.message);
431440
// Bubble this error up to any listeners
432441
this.reportStreamError({

packages/grpc-js/src/server.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,10 @@ export class Server {
268268
};
269269
}
270270

271+
const deferredCallback = (error: Error | null, port: number) => {
272+
process.nextTick(() => callback(error, port));
273+
}
274+
271275
const setupServer = (): http2.Http2Server | http2.Http2SecureServer => {
272276
let http2Server: http2.Http2Server | http2.Http2SecureServer;
273277
if (creds._isSecure()) {
@@ -309,6 +313,7 @@ export class Server {
309313
const http2Server = setupServer();
310314
return new Promise<number | Error>((resolve, reject) => {
311315
function onError(err: Error): void {
316+
trace('Failed to bind ' + subchannelAddressToString(address) + ' with error ' + err.message);
312317
resolve(err);
313318
}
314319

@@ -356,6 +361,7 @@ export class Server {
356361
const http2Server = setupServer();
357362
return new Promise<BindResult>((resolve, reject) => {
358363
function onError(err: Error): void {
364+
trace('Failed to bind ' + subchannelAddressToString(address) + ' with error ' + err.message);
359365
resolve(bindWildcardPort(addressList.slice(1)));
360366
}
361367

@@ -384,7 +390,7 @@ export class Server {
384390
// We only want one resolution result. Discard all future results
385391
resolverListener.onSuccessfulResolution = () => {};
386392
if (addressList.length === 0) {
387-
callback(new Error(`No addresses resolved for port ${port}`), 0);
393+
deferredCallback(new Error(`No addresses resolved for port ${port}`), 0);
388394
return;
389395
}
390396
let bindResultPromise: Promise<BindResult>;
@@ -407,26 +413,26 @@ export class Server {
407413
if (bindResult.count === 0) {
408414
const errorString = `No address added out of total ${addressList.length} resolved`;
409415
logging.log(LogVerbosity.ERROR, errorString);
410-
callback(new Error(errorString), 0);
416+
deferredCallback(new Error(errorString), 0);
411417
} else {
412418
if (bindResult.count < addressList.length) {
413419
logging.log(
414420
LogVerbosity.INFO,
415421
`WARNING Only ${bindResult.count} addresses added out of total ${addressList.length} resolved`
416422
);
417423
}
418-
callback(null, bindResult.port);
424+
deferredCallback(null, bindResult.port);
419425
}
420426
},
421427
(error) => {
422428
const errorString = `No address added out of total ${addressList.length} resolved`;
423429
logging.log(LogVerbosity.ERROR, errorString);
424-
callback(new Error(errorString), 0);
430+
deferredCallback(new Error(errorString), 0);
425431
}
426432
);
427433
},
428434
onError: (error) => {
429-
callback(new Error(error.details), 0);
435+
deferredCallback(new Error(error.details), 0);
430436
},
431437
};
432438

0 commit comments

Comments
 (0)