@@ -142,12 +142,17 @@ func (edsImpl *edsBalancerImpl) handleChildPolicy(name string, config json.RawMe
142
142
continue
143
143
}
144
144
for lid , config := range bgwc .configs {
145
+ lidJSON , err := lid .ToString ()
146
+ if err != nil {
147
+ edsImpl .logger .Errorf ("failed to marshal LocalityID: %#v, skipping this locality" , lid )
148
+ continue
149
+ }
145
150
// TODO: (eds) add support to balancer group to support smoothly
146
151
// switching sub-balancers (keep old balancer around until new
147
152
// balancer becomes ready).
148
- bgwc .bg .Remove (lid . String () )
149
- bgwc .bg .Add (lid . String () , edsImpl .subBalancerBuilder )
150
- bgwc .bg .UpdateClientConnState (lid . String () , balancer.ClientConnState {
153
+ bgwc .bg .Remove (lidJSON )
154
+ bgwc .bg .Add (lidJSON , edsImpl .subBalancerBuilder )
155
+ bgwc .bg .UpdateClientConnState (lidJSON , balancer.ClientConnState {
151
156
ResolverState : resolver.State {Addresses : config .addrs },
152
157
})
153
158
// This doesn't need to manually update picker, because the new
@@ -285,6 +290,11 @@ func (edsImpl *edsBalancerImpl) handleEDSResponsePerPriority(bgwc *balancerGroup
285
290
// One balancer for each locality.
286
291
287
292
lid := locality .ID
293
+ lidJSON , err := lid .ToString ()
294
+ if err != nil {
295
+ edsImpl .logger .Errorf ("failed to marshal LocalityID: %#v, skipping this locality" , lid )
296
+ continue
297
+ }
288
298
newLocalitiesSet [lid ] = struct {}{}
289
299
290
300
newWeight := locality .Weight
@@ -319,8 +329,8 @@ func (edsImpl *edsBalancerImpl) handleEDSResponsePerPriority(bgwc *balancerGroup
319
329
config , ok := bgwc .configs [lid ]
320
330
if ! ok {
321
331
// A new balancer, add it to balancer group and balancer map.
322
- bgwc .stateAggregator .Add (lid . String () , newWeight )
323
- bgwc .bg .Add (lid . String () , edsImpl .subBalancerBuilder )
332
+ bgwc .stateAggregator .Add (lidJSON , newWeight )
333
+ bgwc .bg .Add (lidJSON , edsImpl .subBalancerBuilder )
324
334
config = & localityConfig {
325
335
weight : newWeight ,
326
336
}
@@ -343,23 +353,28 @@ func (edsImpl *edsBalancerImpl) handleEDSResponsePerPriority(bgwc *balancerGroup
343
353
344
354
if weightChanged {
345
355
config .weight = newWeight
346
- bgwc .stateAggregator .UpdateWeight (lid . String () , newWeight )
356
+ bgwc .stateAggregator .UpdateWeight (lidJSON , newWeight )
347
357
rebuildStateAndPicker = true
348
358
}
349
359
350
360
if addrsChanged {
351
361
config .addrs = newAddrs
352
- bgwc .bg .UpdateClientConnState (lid . String () , balancer.ClientConnState {
362
+ bgwc .bg .UpdateClientConnState (lidJSON , balancer.ClientConnState {
353
363
ResolverState : resolver.State {Addresses : newAddrs },
354
364
})
355
365
}
356
366
}
357
367
358
368
// Delete localities that are removed in the latest response.
359
369
for lid := range bgwc .configs {
370
+ lidJSON , err := lid .ToString ()
371
+ if err != nil {
372
+ edsImpl .logger .Errorf ("failed to marshal LocalityID: %#v, skipping this locality" , lid )
373
+ continue
374
+ }
360
375
if _ , ok := newLocalitiesSet [lid ]; ! ok {
361
- bgwc .stateAggregator .Remove (lid . String () )
362
- bgwc .bg .Remove (lid . String () )
376
+ bgwc .stateAggregator .Remove (lidJSON )
377
+ bgwc .bg .Remove (lidJSON )
363
378
delete (bgwc .configs , lid )
364
379
edsImpl .logger .Infof ("Locality %v deleted" , lid )
365
380
rebuildStateAndPicker = true
0 commit comments