Skip to content

Commit

Permalink
Responded to Doug's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
zasweq committed Nov 16, 2021
1 parent 44160e9 commit 8a6bf55
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
26 changes: 9 additions & 17 deletions xds/internal/resolver/serviceconfig.go
Expand Up @@ -133,11 +133,7 @@ type routeCluster struct {

type route struct {
m *xdsresource.CompositeMatcher // converted from route matchers

// Exactly one of clusterSpecifierPlugin or clusters will be set.
clusterSpecifierPlugin string
clusters wrr.WRR // holds *routeCluster entries

maxStreamDuration time.Duration
// map from filter name to its config
httpFilterConfigOverride map[string]httpfilter.FilterConfig
Expand Down Expand Up @@ -179,15 +175,9 @@ func (cs *configSelector) SelectConfig(rpcInfo iresolver.RPCInfo) (*iresolver.RP
return nil, errNoMatchedRouteFound
}

var cluster *routeCluster
if rt.clusterSpecifierPlugin != "" {
cluster.name = rt.clusterSpecifierPlugin
// cluster.httpFilterConfigOverride = /*Do cluster specifier plugins even have http filter config overrides*/
} else {
cluster, ok := rt.clusters.Next().(*routeCluster)
if !ok {
return nil, status.Errorf(codes.Internal, "error retrieving cluster for match: %v (%T)", cluster, cluster)
}
cluster, ok := rt.clusters.Next().(*routeCluster)
if !ok {
return nil, status.Errorf(codes.Internal, "error retrieving cluster for match: %v (%T)", cluster, cluster)
}


Expand Down Expand Up @@ -381,17 +371,19 @@ func (r *xdsResolver) newConfigSelector(su serviceUpdate) (*configSelector, erro
}

for i, rt := range su.virtualHost.Routes {
clusters := newWRR()
if rt.ClusterSpecifierPlugin != "" {
clusters.Add(&routeCluster{
name: "cluster:" + rt.ClusterSpecifierPlugin,
}, 1)

ci := r.activeClusters["cluster_specifier_plugin:" + rt.ClusterSpecifierPlugin]
if ci == nil {
ci = &clusterInfo{refCount: 0}
r.activeClusters["cluster_specifier_plugin:" + rt.ClusterSpecifierPlugin] = ci
}
cs.clusters["cluster_specifier_plugin:" + rt.ClusterSpecifierPlugin] = ci

cs.routes[i].clusterSpecifierPlugin = "cluster_specifier_plugin:" + rt.ClusterSpecifierPlugin
} else {
clusters := newWRR()
for cluster, wc := range rt.WeightedClusters {
clusters.Add(&routeCluster{
name: "cluster:" + cluster,
Expand All @@ -408,8 +400,8 @@ func (r *xdsResolver) newConfigSelector(su serviceUpdate) (*configSelector, erro
}
cs.clusters["cluster:" + cluster] = ci
}
cs.routes[i].clusters = clusters
}
cs.routes[i].clusters = clusters

var err error
cs.routes[i].m, err = xdsresource.RouteToMatcher(rt)
Expand Down
6 changes: 3 additions & 3 deletions xds/internal/resolver/watch_service.go
Expand Up @@ -124,7 +124,7 @@ func (w *serviceUpdateWatcher) handleLDSResp(update xdsresource.ListenerUpdate,
}

// Handle the inline RDS update as if it's from an RDS watch.
w.updateVirtualHostsFromRDS(*update.InlineRouteConfig)
w.applyRouteConfigUpdate(*update.InlineRouteConfig)
return
}

Expand Down Expand Up @@ -155,7 +155,7 @@ func (w *serviceUpdateWatcher) handleLDSResp(update xdsresource.ListenerUpdate,
w.rdsCancel = w.c.WatchRouteConfig(update.RouteConfigName, w.handleRDSResp)
}

func (w *serviceUpdateWatcher) updateVirtualHostsFromRDS(update xdsresource.RouteConfigUpdate) {
func (w *serviceUpdateWatcher) applyRouteConfigUpdate(update xdsresource.RouteConfigUpdate) {
matchVh := xdsresource.FindBestMatchingVirtualHost(w.serviceName, update.VirtualHosts)
if matchVh == nil {
// No matching virtual host found.
Expand Down Expand Up @@ -184,7 +184,7 @@ func (w *serviceUpdateWatcher) handleRDSResp(update xdsresource.RouteConfigUpdat
w.serviceCb(serviceUpdate{}, err)
return
}
w.updateVirtualHostsFromRDS(update)
w.applyRouteConfigUpdate(update)
}

func (w *serviceUpdateWatcher) close() {
Expand Down

0 comments on commit 8a6bf55

Please sign in to comment.