Skip to content

Commit

Permalink
[lds_rds_inline] pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
menghanl committed Mar 31, 2021
1 parent 61b2d0e commit 4475811
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion xds/internal/client/client.go
Expand Up @@ -202,7 +202,7 @@ type ListenerUpdate struct {
// returned inside LDS.
//
// Only one of RouteConfigName and InlineRouteConfig is set.
InlineRouteConfig RouteConfigUpdate
InlineRouteConfig *RouteConfigUpdate

// MaxStreamDuration contains the HTTP connection manager's
// common_http_protocol_options.max_stream_duration field, or zero if
Expand Down
2 changes: 1 addition & 1 deletion xds/internal/client/lds_test.go
Expand Up @@ -689,7 +689,7 @@ func (s) TestUnmarshalListener_ClientSide(t *testing.T) {
resources: []*anypb.Any{v3LisWithInlineRoute},
wantUpdate: map[string]ListenerUpdate{
v3LDSTarget: {
InlineRouteConfig: RouteConfigUpdate{
InlineRouteConfig: &RouteConfigUpdate{
VirtualHosts: []*VirtualHost{{
Domains: []string{v3LDSTarget},
Routes: []*Route{{Prefix: newStringP("/"), WeightedClusters: map[string]WeightedCluster{clusterName: {Weight: 1}}}},
Expand Down
2 changes: 1 addition & 1 deletion xds/internal/client/xds.go
Expand Up @@ -116,7 +116,7 @@ func processClientSideListener(lis *v3listenerpb.Listener, logger *grpclog.Prefi
if err != nil {
return nil, fmt.Errorf("failed to parse inline RDS resp: %v", err)
}
update.InlineRouteConfig = routeU
update.InlineRouteConfig = &routeU
case nil:
return nil, fmt.Errorf("no RouteSpecifier: %+v", apiLis)
default:
Expand Down
7 changes: 3 additions & 4 deletions xds/internal/resolver/watch_service.go
Expand Up @@ -110,9 +110,8 @@ func (w *serviceUpdateWatcher) handleLDSResp(update xdsclient.ListenerUpdate, er
httpFilterConfig: update.HTTPFilters,
}

if update.RouteConfigName == "" {
// RDS name from update is empty string, the LDS resp received has an
// inline RDS resource.
if update.InlineRouteConfig != nil {
// The LDS resp received has an inline RDS resource.

// If there was an RDS watch, cancel it.
w.rdsName = ""
Expand All @@ -122,7 +121,7 @@ func (w *serviceUpdateWatcher) handleLDSResp(update xdsclient.ListenerUpdate, er
}

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

Expand Down
4 changes: 2 additions & 2 deletions xds/internal/resolver/watch_service_test.go
Expand Up @@ -396,7 +396,7 @@ func (s) TestServiceWatchInlineRDS(t *testing.T) {
}},
}
wantUpdate2 := serviceUpdate{virtualHost: wantVirtualHosts2}
xdsC.InvokeWatchListenerCallback(xdsclient.ListenerUpdate{InlineRouteConfig: xdsclient.RouteConfigUpdate{
xdsC.InvokeWatchListenerCallback(xdsclient.ListenerUpdate{InlineRouteConfig: &xdsclient.RouteConfigUpdate{
VirtualHosts: []*xdsclient.VirtualHost{wantVirtualHosts2},
}}, nil)
// This inline RDS resource should cause the RDS watch to be canceled.
Expand All @@ -423,7 +423,7 @@ func (s) TestServiceWatchInlineRDS(t *testing.T) {
}

// Switch LDS resp to a LDS with inline RDS resource again.
xdsC.InvokeWatchListenerCallback(xdsclient.ListenerUpdate{InlineRouteConfig: xdsclient.RouteConfigUpdate{
xdsC.InvokeWatchListenerCallback(xdsclient.ListenerUpdate{InlineRouteConfig: &xdsclient.RouteConfigUpdate{
VirtualHosts: []*xdsclient.VirtualHost{wantVirtualHosts2},
}}, nil)
// This inline RDS resource should cause the RDS watch to be canceled.
Expand Down

0 comments on commit 4475811

Please sign in to comment.