Skip to content

Commit 6351a55

Browse files
authored
xds: remove env var protetion of advanced routing features (#4529)
1 parent 95e48a8 commit 6351a55

File tree

11 files changed

+15
-145
lines changed

11 files changed

+15
-145
lines changed

internal/xds/env/env.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ const (
3939
// When both bootstrap FileName and FileContent are set, FileName is used.
4040
BootstrapFileContentEnv = "GRPC_XDS_BOOTSTRAP_CONFIG"
4141

42-
circuitBreakingSupportEnv = "GRPC_XDS_EXPERIMENTAL_CIRCUIT_BREAKING"
43-
timeoutSupportEnv = "GRPC_XDS_EXPERIMENTAL_ENABLE_TIMEOUT"
44-
faultInjectionSupportEnv = "GRPC_XDS_EXPERIMENTAL_FAULT_INJECTION"
4542
clientSideSecuritySupportEnv = "GRPC_XDS_EXPERIMENTAL_SECURITY_SUPPORT"
4643
aggregateAndDNSSupportEnv = "GRPC_XDS_EXPERIMENTAL_ENABLE_AGGREGATE_AND_LOGICAL_DNS_CLUSTER"
4744

@@ -63,17 +60,6 @@ var (
6360
// When both bootstrap FileName and FileContent are set, FileName is used.
6461
BootstrapFileContent = os.Getenv(BootstrapFileContentEnv)
6562

66-
// CircuitBreakingSupport indicates whether circuit breaking support is
67-
// enabled, which can be disabled by setting the environment variable
68-
// "GRPC_XDS_EXPERIMENTAL_CIRCUIT_BREAKING" to "false".
69-
CircuitBreakingSupport = !strings.EqualFold(os.Getenv(circuitBreakingSupportEnv), "false")
70-
// TimeoutSupport indicates whether support for max_stream_duration in
71-
// route actions is enabled. This can be disabled by setting the
72-
// environment variable "GRPC_XDS_EXPERIMENTAL_ENABLE_TIMEOUT" to "false".
73-
TimeoutSupport = !strings.EqualFold(os.Getenv(timeoutSupportEnv), "false")
74-
// FaultInjectionSupport is used to control both fault injection and HTTP
75-
// filter support.
76-
FaultInjectionSupport = !strings.EqualFold(os.Getenv(faultInjectionSupportEnv), "false")
7763
// ClientSideSecuritySupport is used to control processing of security
7864
// configuration on the client-side.
7965
//

xds/internal/balancer/edsbalancer/eds_impl.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import (
3131
"google.golang.org/grpc/connectivity"
3232
"google.golang.org/grpc/internal"
3333
"google.golang.org/grpc/internal/grpclog"
34-
"google.golang.org/grpc/internal/xds/env"
3534
"google.golang.org/grpc/resolver"
3635
"google.golang.org/grpc/status"
3736
xdsi "google.golang.org/grpc/xds/internal"
@@ -418,9 +417,6 @@ func (edsImpl *edsBalancerImpl) handleSubConnStateChange(sc balancer.SubConn, s
418417

419418
// updateServiceRequestsConfig handles changes to the circuit breaking configuration.
420419
func (edsImpl *edsBalancerImpl) updateServiceRequestsConfig(serviceName string, max *uint32) {
421-
if !env.CircuitBreakingSupport {
422-
return
423-
}
424420
edsImpl.pickerMu.Lock()
425421
var updatePicker bool
426422
if edsImpl.serviceRequestsCounter == nil || edsImpl.serviceRequestsCounter.ServiceName != serviceName {

xds/internal/balancer/edsbalancer/eds_impl_test.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import (
3535
"google.golang.org/grpc/balancer/roundrobin"
3636
"google.golang.org/grpc/connectivity"
3737
"google.golang.org/grpc/internal/balancer/stub"
38-
"google.golang.org/grpc/internal/xds/env"
3938
xdsinternal "google.golang.org/grpc/xds/internal"
4039
"google.golang.org/grpc/xds/internal/balancer/balancergroup"
4140
"google.golang.org/grpc/xds/internal/testutils"
@@ -575,10 +574,6 @@ func (s) TestEDS_UpdateSubBalancerName(t *testing.T) {
575574
}
576575

577576
func (s) TestEDS_CircuitBreaking(t *testing.T) {
578-
origCircuitBreakingSupport := env.CircuitBreakingSupport
579-
env.CircuitBreakingSupport = true
580-
defer func() { env.CircuitBreakingSupport = origCircuitBreakingSupport }()
581-
582577
cc := testutils.NewTestClientConn(t)
583578
edsb := newEDSBalancerImpl(cc, balancer.BuildOptions{}, nil, nil, nil)
584579
edsb.enqueueChildBalancerStateUpdate = edsb.updateState
@@ -812,10 +807,6 @@ func (s) TestDropPicker(t *testing.T) {
812807
}
813808

814809
func (s) TestEDS_LoadReport(t *testing.T) {
815-
origCircuitBreakingSupport := env.CircuitBreakingSupport
816-
env.CircuitBreakingSupport = true
817-
defer func() { env.CircuitBreakingSupport = origCircuitBreakingSupport }()
818-
819810
// We create an xdsClientWrapper with a dummy xdsClient which only
820811
// implements the LoadStore() method to return the underlying load.Store to
821812
// be used.

xds/internal/httpfilter/fault/fault.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import (
3333
"google.golang.org/grpc/codes"
3434
"google.golang.org/grpc/internal/grpcrand"
3535
iresolver "google.golang.org/grpc/internal/resolver"
36-
"google.golang.org/grpc/internal/xds/env"
3736
"google.golang.org/grpc/metadata"
3837
"google.golang.org/grpc/status"
3938
"google.golang.org/grpc/xds/internal/httpfilter"
@@ -63,9 +62,7 @@ var statusMap = map[int]codes.Code{
6362
}
6463

6564
func init() {
66-
if env.FaultInjectionSupport {
67-
httpfilter.Register(builder{})
68-
}
65+
httpfilter.Register(builder{})
6966
}
7067

7168
type builder struct {

xds/internal/httpfilter/fault/fault_test.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@ import (
4040
"google.golang.org/grpc/internal/grpctest"
4141
"google.golang.org/grpc/internal/testutils"
4242
"google.golang.org/grpc/internal/xds"
43-
"google.golang.org/grpc/internal/xds/env"
4443
"google.golang.org/grpc/metadata"
4544
"google.golang.org/grpc/status"
46-
"google.golang.org/grpc/xds/internal/httpfilter"
4745
xtestutils "google.golang.org/grpc/xds/internal/testutils"
4846
"google.golang.org/grpc/xds/internal/testutils/e2e"
4947
"google.golang.org/protobuf/types/known/wrapperspb"
@@ -140,13 +138,6 @@ func clientSetup(t *testing.T) (*e2e.ManagementServer, string, uint32, func()) {
140138
}
141139
}
142140

143-
func init() {
144-
env.FaultInjectionSupport = true
145-
// Manually register to avoid a race between this init and the one that
146-
// check the env var to register the fault injection filter.
147-
httpfilter.Register(builder{})
148-
}
149-
150141
func (s) TestFaultInjection_Unary(t *testing.T) {
151142
type subcase struct {
152143
name string

xds/internal/resolver/serviceconfig.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
"google.golang.org/grpc/codes"
2929
iresolver "google.golang.org/grpc/internal/resolver"
3030
"google.golang.org/grpc/internal/wrr"
31-
"google.golang.org/grpc/internal/xds/env"
3231
"google.golang.org/grpc/status"
3332
"google.golang.org/grpc/xds/internal/balancer/clustermanager"
3433
"google.golang.org/grpc/xds/internal/httpfilter"
@@ -179,7 +178,7 @@ func (cs *configSelector) SelectConfig(rpcInfo iresolver.RPCInfo) (*iresolver.RP
179178
Interceptor: interceptor,
180179
}
181180

182-
if env.TimeoutSupport && rt.maxStreamDuration != 0 {
181+
if rt.maxStreamDuration != 0 {
183182
config.MethodConfig.Timeout = &rt.maxStreamDuration
184183
}
185184

xds/internal/resolver/xds_resolver_test.go

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ import (
3838
iresolver "google.golang.org/grpc/internal/resolver"
3939
"google.golang.org/grpc/internal/testutils"
4040
"google.golang.org/grpc/internal/wrr"
41-
"google.golang.org/grpc/internal/xds/env"
4241
"google.golang.org/grpc/resolver"
4342
"google.golang.org/grpc/serviceconfig"
4443
"google.golang.org/grpc/status"
@@ -686,7 +685,6 @@ func (s) TestXDSResolverWRR(t *testing.T) {
686685
}
687686

688687
func (s) TestXDSResolverMaxStreamDuration(t *testing.T) {
689-
defer func(old bool) { env.TimeoutSupport = old }(env.TimeoutSupport)
690688
xdsC := fakeclient.NewClient()
691689
xdsR, tcc, cancel := testSetup(t, setupOpts{
692690
xdsClientFunc: func() (xdsclient.XDSClient, error) { return xdsC, nil },
@@ -740,35 +738,25 @@ func (s) TestXDSResolverMaxStreamDuration(t *testing.T) {
740738
}
741739

742740
testCases := []struct {
743-
name string
744-
method string
745-
timeoutSupport bool
746-
want *time.Duration
741+
name string
742+
method string
743+
want *time.Duration
747744
}{{
748-
name: "RDS setting",
749-
method: "/foo/method",
750-
timeoutSupport: true,
751-
want: newDurationP(5 * time.Second),
745+
name: "RDS setting",
746+
method: "/foo/method",
747+
want: newDurationP(5 * time.Second),
752748
}, {
753-
name: "timeout support disabled",
754-
method: "/foo/method",
755-
timeoutSupport: false,
756-
want: nil,
749+
name: "explicit zero in RDS; ignore LDS",
750+
method: "/bar/method",
751+
want: nil,
757752
}, {
758-
name: "explicit zero in RDS; ignore LDS",
759-
method: "/bar/method",
760-
timeoutSupport: true,
761-
want: nil,
762-
}, {
763-
name: "no config in RDS; fallback to LDS",
764-
method: "/baz/method",
765-
timeoutSupport: true,
766-
want: newDurationP(time.Second),
753+
name: "no config in RDS; fallback to LDS",
754+
method: "/baz/method",
755+
want: newDurationP(time.Second),
767756
}}
768757

769758
for _, tc := range testCases {
770759
t.Run(tc.name, func(t *testing.T) {
771-
env.TimeoutSupport = tc.timeoutSupport
772760
req := iresolver.RPCInfo{
773761
Method: tc.method,
774762
Context: context.Background(),

xds/internal/xdsclient/cds_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,6 @@ func (s) TestValidateCluster_Success(t *testing.T) {
303303
},
304304
}
305305

306-
origCircuitBreakingSupport := env.CircuitBreakingSupport
307-
env.CircuitBreakingSupport = true
308-
defer func() { env.CircuitBreakingSupport = origCircuitBreakingSupport }()
309306
oldAggregateAndDNSSupportEnv := env.AggregateAndDNSSupportEnv
310307
env.AggregateAndDNSSupportEnv = true
311308
defer func() { env.AggregateAndDNSSupportEnv = oldAggregateAndDNSSupportEnv }()

xds/internal/xdsclient/lds_test.go

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import (
3434
"google.golang.org/protobuf/types/known/durationpb"
3535

3636
"google.golang.org/grpc/internal/testutils"
37-
"google.golang.org/grpc/internal/xds/env"
3837
"google.golang.org/grpc/xds/internal/httpfilter"
3938
"google.golang.org/grpc/xds/internal/version"
4039

@@ -186,7 +185,6 @@ func (s) TestUnmarshalListener_ClientSide(t *testing.T) {
186185
wantUpdate map[string]ListenerUpdate
187186
wantMD UpdateMetadata
188187
wantErr bool
189-
disableFI bool // disable fault injection
190188
}{
191189
{
192190
name: "non-listener resource",
@@ -358,18 +356,6 @@ func (s) TestUnmarshalListener_ClientSide(t *testing.T) {
358356
Version: testVersion,
359357
},
360358
},
361-
{
362-
name: "v3 with custom filter, fault injection disabled",
363-
resources: []*anypb.Any{v3LisWithFilters(customFilter)},
364-
wantUpdate: map[string]ListenerUpdate{
365-
v3LDSTarget: {RouteConfigName: v3RouteConfigName, MaxStreamDuration: time.Second, Raw: v3LisWithFilters(customFilter)},
366-
},
367-
wantMD: UpdateMetadata{
368-
Status: ServiceStatusACKed,
369-
Version: testVersion,
370-
},
371-
disableFI: true,
372-
},
373359
{
374360
name: "v3 with two filters with same name",
375361
resources: []*anypb.Any{v3LisWithFilters(customFilter, customFilter)},
@@ -477,22 +463,6 @@ func (s) TestUnmarshalListener_ClientSide(t *testing.T) {
477463
Version: testVersion,
478464
},
479465
},
480-
{
481-
name: "v3 with error filter, fault injection disabled",
482-
resources: []*anypb.Any{v3LisWithFilters(errFilter)},
483-
wantUpdate: map[string]ListenerUpdate{
484-
v3LDSTarget: {
485-
RouteConfigName: v3RouteConfigName,
486-
MaxStreamDuration: time.Second,
487-
Raw: v3LisWithFilters(errFilter),
488-
},
489-
},
490-
wantMD: UpdateMetadata{
491-
Status: ServiceStatusACKed,
492-
Version: testVersion,
493-
},
494-
disableFI: true,
495-
},
496466
{
497467
name: "v2 listener resource",
498468
resources: []*anypb.Any{v2Lis},
@@ -572,9 +542,6 @@ func (s) TestUnmarshalListener_ClientSide(t *testing.T) {
572542

573543
for _, test := range tests {
574544
t.Run(test.name, func(t *testing.T) {
575-
oldFI := env.FaultInjectionSupport
576-
env.FaultInjectionSupport = !test.disableFI
577-
578545
update, md, err := UnmarshalListener(testVersion, test.resources, nil)
579546
if (err != nil) != test.wantErr {
580547
t.Fatalf("UnmarshalListener(), got err: %v, wantErr: %v", err, test.wantErr)
@@ -585,7 +552,6 @@ func (s) TestUnmarshalListener_ClientSide(t *testing.T) {
585552
if diff := cmp.Diff(md, test.wantMD, cmpOptsIgnoreDetails); diff != "" {
586553
t.Errorf("got unexpected metadata, diff (-got +want): %v", diff)
587554
}
588-
env.FaultInjectionSupport = oldFI
589555
})
590556
}
591557
}
@@ -1287,10 +1253,6 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) {
12871253

12881254
for _, test := range tests {
12891255
t.Run(test.name, func(t *testing.T) {
1290-
oldFI := env.FaultInjectionSupport
1291-
env.FaultInjectionSupport = true
1292-
defer func() { env.FaultInjectionSupport = oldFI }()
1293-
12941256
gotUpdate, md, err := UnmarshalListener(testVersion, test.resources, nil)
12951257
if (err != nil) != (test.wantErr != "") {
12961258
t.Fatalf("UnmarshalListener(), got err: %v, wantErr: %v", err, test.wantErr)

xds/internal/xdsclient/rds_test.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929
"github.com/google/go-cmp/cmp"
3030
"github.com/google/go-cmp/cmp/cmpopts"
3131
"google.golang.org/grpc/internal/testutils"
32-
"google.golang.org/grpc/internal/xds/env"
3332
"google.golang.org/grpc/xds/internal/httpfilter"
3433
"google.golang.org/grpc/xds/internal/version"
3534
"google.golang.org/protobuf/types/known/durationpb"
@@ -88,7 +87,6 @@ func (s) TestRDSGenerateRDSUpdateFromRouteConfiguration(t *testing.T) {
8887
rc *v3routepb.RouteConfiguration
8988
wantUpdate RouteConfigUpdate
9089
wantError bool
91-
disableFI bool // disable fault injection
9290
}{
9391
{
9492
name: "default-route-match-field-is-nil",
@@ -474,28 +472,17 @@ func (s) TestRDSGenerateRDSUpdateFromRouteConfiguration(t *testing.T) {
474472
rc: goodRouteConfigWithFilterConfigs(map[string]*anypb.Any{"foo": wrappedOptionalFilter("unknown.custom.filter")}),
475473
wantUpdate: goodUpdateWithFilterConfigs(nil),
476474
},
477-
{
478-
name: "good-route-config-with-http-err-filter-config-fi-disabled",
479-
disableFI: true,
480-
rc: goodRouteConfigWithFilterConfigs(map[string]*anypb.Any{"foo": errFilterConfig}),
481-
wantUpdate: goodUpdateWithFilterConfigs(nil),
482-
},
483475
}
484476

485477
for _, test := range tests {
486478
t.Run(test.name, func(t *testing.T) {
487-
oldFI := env.FaultInjectionSupport
488-
env.FaultInjectionSupport = !test.disableFI
489-
490479
gotUpdate, gotError := generateRDSUpdateFromRouteConfiguration(test.rc, nil, false)
491480
if (gotError != nil) != test.wantError ||
492481
!cmp.Equal(gotUpdate, test.wantUpdate, cmpopts.EquateEmpty(),
493482
cmp.Transformer("FilterConfig", func(fc httpfilter.FilterConfig) string {
494483
return fmt.Sprint(fc)
495484
})) {
496485
t.Errorf("generateRDSUpdateFromRouteConfiguration(%+v, %v) returned unexpected, diff (-want +got):\\n%s", test.rc, ldsTarget, cmp.Diff(test.wantUpdate, gotUpdate, cmpopts.EquateEmpty()))
497-
498-
env.FaultInjectionSupport = oldFI
499486
}
500487
})
501488
}
@@ -815,7 +802,6 @@ func (s) TestRoutesProtoToSlice(t *testing.T) {
815802
routes []*v3routepb.Route
816803
wantRoutes []*Route
817804
wantErr bool
818-
disableFI bool // disable fault injection
819805
}{
820806
{
821807
name: "no path",
@@ -1182,12 +1168,6 @@ func (s) TestRoutesProtoToSlice(t *testing.T) {
11821168
routes: goodRouteWithFilterConfigs(map[string]*anypb.Any{"foo": wrappedOptionalFilter("custom.filter")}),
11831169
wantRoutes: goodUpdateWithFilterConfigs(map[string]httpfilter.FilterConfig{"foo": filterConfig{Override: customFilterConfig}}),
11841170
},
1185-
{
1186-
name: "with custom HTTP filter config, FI disabled",
1187-
disableFI: true,
1188-
routes: goodRouteWithFilterConfigs(map[string]*anypb.Any{"foo": customFilterConfig}),
1189-
wantRoutes: goodUpdateWithFilterConfigs(nil),
1190-
},
11911171
{
11921172
name: "with erroring custom HTTP filter config",
11931173
routes: goodRouteWithFilterConfigs(map[string]*anypb.Any{"foo": errFilterConfig}),
@@ -1198,12 +1178,6 @@ func (s) TestRoutesProtoToSlice(t *testing.T) {
11981178
routes: goodRouteWithFilterConfigs(map[string]*anypb.Any{"foo": wrappedOptionalFilter("err.custom.filter")}),
11991179
wantErr: true,
12001180
},
1201-
{
1202-
name: "with erroring custom HTTP filter config, FI disabled",
1203-
disableFI: true,
1204-
routes: goodRouteWithFilterConfigs(map[string]*anypb.Any{"foo": errFilterConfig}),
1205-
wantRoutes: goodUpdateWithFilterConfigs(nil),
1206-
},
12071181
{
12081182
name: "with unknown custom HTTP filter config",
12091183
routes: goodRouteWithFilterConfigs(map[string]*anypb.Any{"foo": unknownFilterConfig}),
@@ -1226,10 +1200,6 @@ func (s) TestRoutesProtoToSlice(t *testing.T) {
12261200

12271201
for _, tt := range tests {
12281202
t.Run(tt.name, func(t *testing.T) {
1229-
oldFI := env.FaultInjectionSupport
1230-
env.FaultInjectionSupport = !tt.disableFI
1231-
defer func() { env.FaultInjectionSupport = oldFI }()
1232-
12331203
got, err := routesProtoToSlice(tt.routes, nil, false)
12341204
if (err != nil) != tt.wantErr {
12351205
t.Fatalf("routesProtoToSlice() error = %v, wantErr %v", err, tt.wantErr)

0 commit comments

Comments
 (0)