@@ -26,6 +26,8 @@ import ChannelControlHelper = experimental.ChannelControlHelper;
26
26
import registerLoadBalancerType = experimental . registerLoadBalancerType ;
27
27
import TypedLoadBalancingConfig = experimental . TypedLoadBalancingConfig ;
28
28
import parseLoadBalancingConfig = experimental . parseLoadBalancingConfig ;
29
+ import StatusOr = experimental . StatusOr ;
30
+ import statusOrFromValue = experimental . statusOrFromValue ;
29
31
import { XdsConfig } from './xds-dependency-manager' ;
30
32
import { LocalityEndpoint , PriorityChildRaw } from './load-balancer-priority' ;
31
33
import { Locality__Output } from './generated/envoy/config/core/v3/Locality' ;
@@ -205,7 +207,7 @@ function getLeafClusters(xdsConfig: XdsConfig, rootCluster: string, depth = 0):
205
207
if ( ! maybeClusterConfig ) {
206
208
return [ ] ;
207
209
}
208
- if ( ! maybeClusterConfig . success ) {
210
+ if ( ! maybeClusterConfig . ok ) {
209
211
return [ rootCluster ] ;
210
212
}
211
213
if ( maybeClusterConfig . value . children . type === 'aggregate' ) {
@@ -240,26 +242,27 @@ export class CdsLoadBalancer implements LoadBalancer {
240
242
}
241
243
242
244
updateAddressList (
243
- endpointList : Endpoint [ ] ,
245
+ endpointList : StatusOr < Endpoint [ ] > ,
244
246
lbConfig : TypedLoadBalancingConfig ,
245
- options : ChannelOptions
246
- ) : void {
247
+ options : ChannelOptions ,
248
+ resolutionNote : string
249
+ ) : boolean {
247
250
if ( ! ( lbConfig instanceof CdsLoadBalancingConfig ) ) {
248
251
trace ( 'Discarding address list update with unrecognized config ' + JSON . stringify ( lbConfig , undefined , 2 ) ) ;
249
- return ;
252
+ return false ;
250
253
}
251
254
trace ( 'Received update with config ' + JSON . stringify ( lbConfig , undefined , 2 ) ) ;
252
255
const xdsConfig = options [ XDS_CONFIG_KEY ] as XdsConfig ;
253
256
const clusterName = lbConfig . getCluster ( ) ;
254
257
const maybeClusterConfig = xdsConfig . clusters . get ( clusterName ) ;
255
258
if ( ! maybeClusterConfig ) {
256
259
trace ( 'Received update with no config for cluster ' + clusterName ) ;
257
- return ;
260
+ return false ;
258
261
}
259
- if ( ! maybeClusterConfig . success ) {
262
+ if ( ! maybeClusterConfig . ok ) {
260
263
this . childBalancer . destroy ( ) ;
261
264
this . channelControlHelper . updateState ( connectivityState . TRANSIENT_FAILURE , new UnavailablePicker ( maybeClusterConfig . error ) , maybeClusterConfig . error . details ) ;
262
- return ;
265
+ return true ;
263
266
}
264
267
const clusterConfig = maybeClusterConfig . value ;
265
268
@@ -270,8 +273,8 @@ export class CdsLoadBalancer implements LoadBalancer {
270
273
} catch ( e ) {
271
274
trace ( 'xDS config parsing failed with error ' + ( e as Error ) . message ) ;
272
275
const errorMessage = `xDS config parsing failed with error ${ ( e as Error ) . message } ` ;
273
- this . channelControlHelper . updateState ( connectivityState . TRANSIENT_FAILURE , new UnavailablePicker ( { code : status . UNAVAILABLE , details : errorMessage } ) , errorMessage ) ;
274
- return ;
276
+ this . channelControlHelper . updateState ( connectivityState . TRANSIENT_FAILURE , new UnavailablePicker ( { code : status . UNAVAILABLE , details : ` ${ errorMessage } Resolution note: ${ resolutionNote } ` } ) , errorMessage ) ;
277
+ return true ;
275
278
}
276
279
const priorityChildren : { [ name : string ] : PriorityChildRaw } = { } ;
277
280
for ( const cluster of leafClusters ) {
@@ -296,16 +299,16 @@ export class CdsLoadBalancer implements LoadBalancer {
296
299
} catch ( e ) {
297
300
trace ( 'LB policy config parsing failed with error ' + ( e as Error ) . message ) ;
298
301
const errorMessage = `LB policy config parsing failed with error ${ ( e as Error ) . message } ` ;
299
- this . channelControlHelper . updateState ( connectivityState . TRANSIENT_FAILURE , new UnavailablePicker ( { code : status . UNAVAILABLE , details : errorMessage } ) , errorMessage ) ;
300
- return ;
302
+ this . channelControlHelper . updateState ( connectivityState . TRANSIENT_FAILURE , new UnavailablePicker ( { code : status . UNAVAILABLE , details : ` ${ errorMessage } Resolution note: ${ resolutionNote } ` } ) , errorMessage ) ;
303
+ return true ;
301
304
}
302
- this . childBalancer . updateAddressList ( endpointList , typedChildConfig , { ...options , [ ROOT_CLUSTER_KEY ] : clusterName } ) ;
305
+ this . childBalancer . updateAddressList ( endpointList , typedChildConfig , { ...options , [ ROOT_CLUSTER_KEY ] : clusterName } , resolutionNote ) ;
303
306
} else {
304
307
if ( ! clusterConfig . children . endpoints ) {
305
308
trace ( 'Received update with no resolved endpoints for cluster ' + clusterName ) ;
306
309
const errorMessage = `Cluster ${ clusterName } resolution failed: ${ clusterConfig . children . resolutionNote } ` ;
307
310
this . channelControlHelper . updateState ( connectivityState . TRANSIENT_FAILURE , new UnavailablePicker ( { code : status . UNAVAILABLE , details : errorMessage } ) , errorMessage ) ;
308
- return ;
311
+ return false ;
309
312
}
310
313
const newPriorityNames : string [ ] = [ ] ;
311
314
const newLocalityPriorities = new Map < string , number > ( ) ;
@@ -317,7 +320,7 @@ export class CdsLoadBalancer implements LoadBalancer {
317
320
if ( AGGREGATE_CLUSTER_BACKWARDS_COMPAT ) {
318
321
if ( typeof options [ ROOT_CLUSTER_KEY ] === 'string' ) {
319
322
const maybeRootClusterConfig = xdsConfig . clusters . get ( options [ ROOT_CLUSTER_KEY ] ) ;
320
- if ( maybeRootClusterConfig ?. success ) {
323
+ if ( maybeRootClusterConfig ?. ok ) {
321
324
endpointPickingPolicy = maybeRootClusterConfig . value . cluster . lbPolicyConfig ;
322
325
}
323
326
}
@@ -409,26 +412,26 @@ export class CdsLoadBalancer implements LoadBalancer {
409
412
typedChildConfig = parseLoadBalancingConfig ( childConfig ) ;
410
413
} catch ( e ) {
411
414
trace ( 'LB policy config parsing failed with error ' + ( e as Error ) . message ) ;
412
- const errorMessage = `LB policy config parsing failed with error ${ ( e as Error ) . message } ` ;
415
+ const errorMessage = `LB policy config parsing failed with error ${ ( e as Error ) . message } . Resolution note: ${ resolutionNote } ` ;
413
416
this . channelControlHelper . updateState ( connectivityState . TRANSIENT_FAILURE , new UnavailablePicker ( { code : status . UNAVAILABLE , details : errorMessage } ) , errorMessage ) ;
414
- return ;
417
+ return false ;
415
418
}
416
419
const childOptions : ChannelOptions = { ...options } ;
417
420
if ( clusterConfig . cluster . securityUpdate ) {
418
421
const securityUpdate = clusterConfig . cluster . securityUpdate ;
419
422
const xdsClient = options [ XDS_CLIENT_KEY ] as XdsClient ;
420
423
const caCertProvider = xdsClient . getCertificateProvider ( securityUpdate . caCertificateProviderInstance ) ;
421
424
if ( ! caCertProvider ) {
422
- const errorMessage = `Cluster ${ clusterName } configured with CA certificate provider ${ securityUpdate . caCertificateProviderInstance } not in bootstrap` ;
425
+ const errorMessage = `Cluster ${ clusterName } configured with CA certificate provider ${ securityUpdate . caCertificateProviderInstance } not in bootstrap. Resolution note: ${ resolutionNote } ` ;
423
426
this . channelControlHelper . updateState ( connectivityState . TRANSIENT_FAILURE , new UnavailablePicker ( { code : status . UNAVAILABLE , details : errorMessage } ) , errorMessage ) ;
424
- return ;
427
+ return false ;
425
428
}
426
429
if ( securityUpdate . identityCertificateProviderInstance ) {
427
430
const identityCertProvider = xdsClient . getCertificateProvider ( securityUpdate . identityCertificateProviderInstance ) ;
428
431
if ( ! identityCertProvider ) {
429
- const errorMessage = `Cluster ${ clusterName } configured with identity certificate provider ${ securityUpdate . identityCertificateProviderInstance } not in bootstrap` ;
432
+ const errorMessage = `Cluster ${ clusterName } configured with identity certificate provider ${ securityUpdate . identityCertificateProviderInstance } not in bootstrap. Resolution note: ${ resolutionNote } ` ;
430
433
this . channelControlHelper . updateState ( connectivityState . TRANSIENT_FAILURE , new UnavailablePicker ( { code : status . UNAVAILABLE , details : errorMessage } ) , errorMessage ) ;
431
- return ;
434
+ return false ;
432
435
}
433
436
childOptions [ IDENTITY_CERT_PROVIDER_KEY ] = identityCertProvider ;
434
437
}
@@ -440,8 +443,9 @@ export class CdsLoadBalancer implements LoadBalancer {
440
443
trace ( 'Configured subject alternative name matcher: ' + sanMatcher ) ;
441
444
childOptions [ SAN_MATCHER_KEY ] = this . latestSanMatcher ;
442
445
}
443
- this . childBalancer . updateAddressList ( childEndpointList , typedChildConfig , childOptions ) ;
446
+ this . childBalancer . updateAddressList ( statusOrFromValue ( childEndpointList ) , typedChildConfig , childOptions , resolutionNote ) ;
444
447
}
448
+ return true ;
445
449
}
446
450
exitIdle ( ) : void {
447
451
this . childBalancer . exitIdle ( ) ;
0 commit comments