diff --git a/xds/internal/balancer/edsbalancer/xds_client_wrapper.go b/xds/internal/balancer/edsbalancer/xds_client_wrapper.go index 4b7146c94bc5..73e8f6e1ca09 100644 --- a/xds/internal/balancer/edsbalancer/xds_client_wrapper.go +++ b/xds/internal/balancer/edsbalancer/xds_client_wrapper.go @@ -216,12 +216,11 @@ func (c *xdsclientWrapper) updateXDSClient(config *EDSConfig, attr *attributes.A // // This usually means load report needs to be restarted, but this function does // NOT do that. Caller needs to call startLoadReport separately. -func (c *xdsclientWrapper) startEndpointsWatch(nameToWatch string) { +func (c *xdsclientWrapper) startEndpointsWatch() { if c.xdsClient == nil { return } - c.edsServiceName = nameToWatch if c.cancelEndpointsWatch != nil { c.cancelEndpointsWatch() } @@ -260,7 +259,6 @@ func (c *xdsclientWrapper) loadStore() load.PerClusterReporter { if c == nil || c.load.store == nil { return nil } - // return c.xdsClient.LoadStore().PerCluster(c.edsServiceName, "") return c.load } @@ -273,7 +271,8 @@ func (c *xdsclientWrapper) handleUpdate(config *EDSConfig, attr *attributes.Attr // - the xds_client is updated // - the xds_client didn't change, but the edsServiceName changed if clientChanged || c.edsServiceName != config.EDSServiceName { - c.startEndpointsWatch(config.EDSServiceName) + c.edsServiceName = config.EDSServiceName + c.startEndpointsWatch() // TODO: this update for the LRS service name is too early. It should // only apply to the new EDS response. But this is applied to the RPCs // before the new EDS response. To fully fix this, the EDS balancer diff --git a/xds/internal/client/load/store.go b/xds/internal/client/load/store.go index df8c46b59e29..c0c741f670f8 100644 --- a/xds/internal/client/load/store.go +++ b/xds/internal/client/load/store.go @@ -27,7 +27,7 @@ const negativeOneUInt64 = ^uint64(0) // A pair of cluster and service name. The same cluster can be used by multiple // services, and one service can use multiple clusters. So we need a pair with // both name to accurately indicate where the load belongs. -type clusterAndServiceNames struct { +type storeKey struct { cluster string service string } @@ -36,13 +36,13 @@ type clusterAndServiceNames struct { // LRS. It is safe for concurrent use. type Store struct { mu sync.RWMutex - clusters map[clusterAndServiceNames]*PerClusterStore + clusters map[storeKey]*PerClusterStore } // NewStore creates a Store. func NewStore() *Store { return &Store{ - clusters: make(map[clusterAndServiceNames]*PerClusterStore), + clusters: make(map[storeKey]*PerClusterStore), } } @@ -53,7 +53,7 @@ func (ls *Store) PerCluster(clusterName, serviceName string) *PerClusterStore { return nil } - k := clusterAndServiceNames{ + k := storeKey{ cluster: clusterName, service: serviceName, }