Handle changing EDS service name, add comments

This commit is contained in:
Michael Lumish 2020-07-23 10:08:50 -07:00
parent 044da58c76
commit ef225cba30
1 changed files with 18 additions and 1 deletions

View File

@ -282,13 +282,30 @@ export class EdsLoadBalancer implements LoadBalancer {
this.lastestConfig = lbConfig;
this.latestAttributes = attributes;
this.xdsClient = attributes.xdsClient;
this.edsServiceName = lbConfig.eds.edsServiceName ?? lbConfig.eds.cluster;
const newEdsServiceName = lbConfig.eds.edsServiceName ?? lbConfig.eds.cluster;
/* If the name is changing, disable the old watcher before adding the new
* one */
if (this.isWatcherActive && this.edsServiceName !== newEdsServiceName) {
this.xdsClient.removeEndpointWatcher(this.edsServiceName!, this.watcher);
/* Setting isWatcherActive to false here lets us have one code path for
* calling addEndpointWatcher */
this.isWatcherActive = false;
/* If we have a new name, the latestEdsUpdate does not correspond to
* the new config, so it is no longer valid */
this.latestEdsUpdate = null;
}
this.edsServiceName = newEdsServiceName;
if (!this.isWatcherActive) {
this.xdsClient.addEndpointWatcher(this.edsServiceName, this.watcher);
this.isWatcherActive = true;
}
/* If updateAddressList is called after receiving an update and the update
* is still valid, we want to update the child config with the information
* in the new EdsLoadBalancingConfig. */
this.updateChild();
}
exitIdle(): void {