Skip to content

Commit b17cf47

Browse files
dfawleyarvindbr8
authored andcommitted
envconfig: remove env vars for on-by-default features (grpc#6749)
1 parent 15643a2 commit b17cf47

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+77
-814
lines changed

internal/envconfig/envconfig.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,11 @@ import (
2828
var (
2929
// TXTErrIgnore is set if TXT errors should be ignored ("GRPC_GO_IGNORE_TXT_ERRORS" is not "false").
3030
TXTErrIgnore = boolFromEnv("GRPC_GO_IGNORE_TXT_ERRORS", true)
31-
// AdvertiseCompressors is set if registered compressor should be advertised
32-
// ("GRPC_GO_ADVERTISE_COMPRESSORS" is not "false").
33-
AdvertiseCompressors = boolFromEnv("GRPC_GO_ADVERTISE_COMPRESSORS", true)
3431
// RingHashCap indicates the maximum ring size which defaults to 4096
3532
// entries but may be overridden by setting the environment variable
3633
// "GRPC_RING_HASH_CAP". This does not override the default bounds
3734
// checking which NACKs configs specifying ring sizes > 8*1024*1024 (~8M).
3835
RingHashCap = uint64FromEnv("GRPC_RING_HASH_CAP", 4096, 1, 8*1024*1024)
39-
// PickFirstLBConfig is set if we should support configuration of the
40-
// pick_first LB policy.
41-
PickFirstLBConfig = boolFromEnv("GRPC_EXPERIMENTAL_PICKFIRST_LB_CONFIG", true)
4236
// LeastRequestLB is set if we should support the least_request_experimental
4337
// LB policy, which can be enabled by setting the environment variable
4438
// "GRPC_EXPERIMENTAL_ENABLE_LEAST_REQUEST" to "true".

internal/envconfig/xds.go

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -50,46 +50,7 @@ var (
5050
//
5151
// When both bootstrap FileName and FileContent are set, FileName is used.
5252
XDSBootstrapFileContent = os.Getenv(XDSBootstrapFileContentEnv)
53-
// XDSRingHash indicates whether ring hash support is enabled, which can be
54-
// disabled by setting the environment variable
55-
// "GRPC_XDS_EXPERIMENTAL_ENABLE_RING_HASH" to "false".
56-
XDSRingHash = boolFromEnv("GRPC_XDS_EXPERIMENTAL_ENABLE_RING_HASH", true)
57-
// XDSClientSideSecurity is used to control processing of security
58-
// configuration on the client-side.
59-
//
60-
// Note that there is no env var protection for the server-side because we
61-
// have a brand new API on the server-side and users explicitly need to use
62-
// the new API to get security integration on the server.
63-
XDSClientSideSecurity = boolFromEnv("GRPC_XDS_EXPERIMENTAL_SECURITY_SUPPORT", true)
64-
// XDSAggregateAndDNS indicates whether processing of aggregated cluster and
65-
// DNS cluster is enabled, which can be disabled by setting the environment
66-
// variable "GRPC_XDS_EXPERIMENTAL_ENABLE_AGGREGATE_AND_LOGICAL_DNS_CLUSTER"
67-
// to "false".
68-
XDSAggregateAndDNS = boolFromEnv("GRPC_XDS_EXPERIMENTAL_ENABLE_AGGREGATE_AND_LOGICAL_DNS_CLUSTER", true)
69-
70-
// XDSRBAC indicates whether xDS configured RBAC HTTP Filter is enabled,
71-
// which can be disabled by setting the environment variable
72-
// "GRPC_XDS_EXPERIMENTAL_RBAC" to "false".
73-
XDSRBAC = boolFromEnv("GRPC_XDS_EXPERIMENTAL_RBAC", true)
74-
// XDSOutlierDetection indicates whether outlier detection support is
75-
// enabled, which can be disabled by setting the environment variable
76-
// "GRPC_EXPERIMENTAL_ENABLE_OUTLIER_DETECTION" to "false".
77-
XDSOutlierDetection = boolFromEnv("GRPC_EXPERIMENTAL_ENABLE_OUTLIER_DETECTION", true)
78-
// XDSFederation indicates whether federation support is enabled, which can
79-
// be enabled by setting the environment variable
80-
// "GRPC_EXPERIMENTAL_XDS_FEDERATION" to "true".
81-
XDSFederation = boolFromEnv("GRPC_EXPERIMENTAL_XDS_FEDERATION", true)
82-
83-
// XDSRLS indicates whether processing of Cluster Specifier plugins and
84-
// support for the RLS CLuster Specifier is enabled, which can be disabled by
85-
// setting the environment variable "GRPC_EXPERIMENTAL_XDS_RLS_LB" to
86-
// "false".
87-
XDSRLS = boolFromEnv("GRPC_EXPERIMENTAL_XDS_RLS_LB", true)
8853

8954
// C2PResolverTestOnlyTrafficDirectorURI is the TD URI for testing.
9055
C2PResolverTestOnlyTrafficDirectorURI = os.Getenv("GRPC_TEST_ONLY_GOOGLE_C2P_RESOLVER_TRAFFIC_DIRECTOR_URI")
91-
// XDSCustomLBPolicy indicates whether Custom LB Policies are enabled, which
92-
// can be disabled by setting the environment variable
93-
// "GRPC_EXPERIMENTAL_XDS_CUSTOM_LB_CONFIG" to "false".
94-
XDSCustomLBPolicy = boolFromEnv("GRPC_EXPERIMENTAL_XDS_CUSTOM_LB_CONFIG", true)
9556
)

internal/grpcutil/compressor.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ package grpcutil
2020

2121
import (
2222
"strings"
23-
24-
"google.golang.org/grpc/internal/envconfig"
2523
)
2624

2725
// RegisteredCompressorNames holds names of the registered compressors.
@@ -40,8 +38,5 @@ func IsCompressorNameRegistered(name string) bool {
4038
// RegisteredCompressors returns a string of registered compressor names
4139
// separated by comma.
4240
func RegisteredCompressors() string {
43-
if !envconfig.AdvertiseCompressors {
44-
return ""
45-
}
4641
return strings.Join(RegisteredCompressorNames, ",")
4742
}

internal/grpcutil/compressor_test.go

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,13 @@ package grpcutil
2020

2121
import (
2222
"testing"
23-
24-
"google.golang.org/grpc/internal/envconfig"
2523
)
2624

2725
func TestRegisteredCompressors(t *testing.T) {
2826
defer func(c []string) { RegisteredCompressorNames = c }(RegisteredCompressorNames)
29-
defer func(v bool) { envconfig.AdvertiseCompressors = v }(envconfig.AdvertiseCompressors)
3027
RegisteredCompressorNames = []string{"gzip", "snappy"}
31-
tests := []struct {
32-
desc string
33-
enabled bool
34-
want string
35-
}{
36-
{desc: "compressor_ad_disabled", enabled: false, want: ""},
37-
{desc: "compressor_ad_enabled", enabled: true, want: "gzip,snappy"},
38-
}
39-
for _, tt := range tests {
40-
envconfig.AdvertiseCompressors = tt.enabled
41-
compressors := RegisteredCompressors()
42-
if compressors != tt.want {
43-
t.Fatalf("Unexpected compressors got:%s, want:%s", compressors, tt.want)
44-
}
28+
if got, want := RegisteredCompressors(), "gzip,snappy"; got != want {
29+
t.Fatalf("Unexpected compressors got:%s, want:%s", got, want)
30+
4531
}
4632
}

internal/testutils/xds/bootstrap/bootstrap.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,9 @@ func Contents(opts Options) ([]byte, error) {
116116
cfg.XdsServers[0].ServerFeatures = append(cfg.XdsServers[0].ServerFeatures, "ignore_resource_deletion")
117117
}
118118

119-
auths := make(map[string]authority)
120-
if envconfig.XDSFederation {
121-
// This will end up using the top-level server list for new style
122-
// resources with empty authority.
123-
auths[""] = authority{}
124-
}
119+
// This will end up using the top-level server list for new style
120+
// resources with empty authority.
121+
auths := map[string]authority{"": {}}
125122
for n, auURI := range opts.Authorities {
126123
auths[n] = authority{XdsServers: []server{{
127124
ServerURI: auURI,

pickfirst.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525

2626
"google.golang.org/grpc/balancer"
2727
"google.golang.org/grpc/connectivity"
28-
"google.golang.org/grpc/internal/envconfig"
2928
internalgrpclog "google.golang.org/grpc/internal/grpclog"
3029
"google.golang.org/grpc/internal/grpcrand"
3130
"google.golang.org/grpc/internal/pretty"
@@ -65,19 +64,6 @@ type pfConfig struct {
6564
}
6665

6766
func (*pickfirstBuilder) ParseConfig(js json.RawMessage) (serviceconfig.LoadBalancingConfig, error) {
68-
if !envconfig.PickFirstLBConfig {
69-
// Prior to supporting loadbalancing configuration, the pick_first LB
70-
// policy did not implement the balancer.ConfigParser interface. This
71-
// meant that if a non-empty configuration was passed to it, the service
72-
// config unmarshaling code would throw a warning log, but would
73-
// continue using the pick_first LB policy. The code below ensures the
74-
// same behavior is retained if the env var is not set.
75-
if string(js) != "{}" {
76-
logger.Warningf("Ignoring non-empty balancer configuration %q for the pick_first LB policy", string(js))
77-
}
78-
return nil, nil
79-
}
80-
8167
var cfg pfConfig
8268
if err := json.Unmarshal(js, &cfg); err != nil {
8369
return nil, fmt.Errorf("pickfirst: unable to unmarshal LB policy config: %s, error: %v", string(js), err)

test/compressor_test.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import (
3131
"google.golang.org/grpc"
3232
"google.golang.org/grpc/codes"
3333
"google.golang.org/grpc/encoding"
34-
"google.golang.org/grpc/internal/envconfig"
3534
"google.golang.org/grpc/internal/stubserver"
3635
"google.golang.org/grpc/metadata"
3736
"google.golang.org/grpc/status"
@@ -408,23 +407,6 @@ func (s) TestUnregisteredSetSendCompressorFailure(t *testing.T) {
408407
})
409408
}
410409

411-
func (s) TestUnadvertisedSetSendCompressorFailure(t *testing.T) {
412-
// Disable client compressor advertisement.
413-
defer func(b bool) { envconfig.AdvertiseCompressors = b }(envconfig.AdvertiseCompressors)
414-
envconfig.AdvertiseCompressors = false
415-
416-
resCompressor := "gzip"
417-
wantErr := status.Error(codes.Unknown, "unable to set send compressor: client does not support compressor \"gzip\"")
418-
419-
t.Run("unary", func(t *testing.T) {
420-
testUnarySetSendCompressorFailure(t, resCompressor, wantErr)
421-
})
422-
423-
t.Run("stream", func(t *testing.T) {
424-
testStreamSetSendCompressorFailure(t, resCompressor, wantErr)
425-
})
426-
}
427-
428410
func testUnarySetSendCompressorFailure(t *testing.T, resCompressor string, wantErr error) {
429411
ss := &stubserver.StubServer{
430412
EmptyCallF: func(ctx context.Context, in *testpb.Empty) (*testpb.Empty, error) {

test/pickfirst_test.go

Lines changed: 2 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import (
3333
"google.golang.org/grpc/credentials/insecure"
3434
"google.golang.org/grpc/internal"
3535
"google.golang.org/grpc/internal/channelz"
36-
"google.golang.org/grpc/internal/envconfig"
3736
"google.golang.org/grpc/internal/grpcrand"
3837
"google.golang.org/grpc/internal/stubserver"
3938
"google.golang.org/grpc/internal/testutils"
@@ -376,8 +375,6 @@ func (s) TestPickFirst_StickyTransientFailure(t *testing.T) {
376375

377376
// Tests the PF LB policy with shuffling enabled.
378377
func (s) TestPickFirst_ShuffleAddressList(t *testing.T) {
379-
defer func(old bool) { envconfig.PickFirstLBConfig = old }(envconfig.PickFirstLBConfig)
380-
envconfig.PickFirstLBConfig = true
381378
const serviceConfig = `{"loadBalancingConfig": [{"pick_first":{ "shuffleAddressList": true }}]}`
382379

383380
// Install a shuffler that always reverses two entries.
@@ -429,45 +426,6 @@ func (s) TestPickFirst_ShuffleAddressList(t *testing.T) {
429426
}
430427
}
431428

432-
// Tests the PF LB policy with the environment variable support of address list
433-
// shuffling disabled.
434-
func (s) TestPickFirst_ShuffleAddressListDisabled(t *testing.T) {
435-
defer func(old bool) { envconfig.PickFirstLBConfig = old }(envconfig.PickFirstLBConfig)
436-
envconfig.PickFirstLBConfig = false
437-
const serviceConfig = `{"loadBalancingConfig": [{"pick_first":{ "shuffleAddressList": true }}]}`
438-
439-
// Install a shuffler that always reverses two entries.
440-
origShuf := grpcrand.Shuffle
441-
defer func() { grpcrand.Shuffle = origShuf }()
442-
grpcrand.Shuffle = func(n int, f func(int, int)) {
443-
if n != 2 {
444-
t.Errorf("Shuffle called with n=%v; want 2", n)
445-
return
446-
}
447-
f(0, 1) // reverse the two addresses
448-
}
449-
450-
// Set up our backends.
451-
cc, r, backends := setupPickFirst(t, 2)
452-
addrs := stubBackendsToResolverAddrs(backends)
453-
454-
ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
455-
defer cancel()
456-
457-
// Send a config with shuffling enabled. This will reverse the addresses,
458-
// so we should connect to backend 1 if shuffling is supported. However
459-
// with it disabled at the start of the test, we will connect to backend 0
460-
// instead.
461-
shufState := resolver.State{
462-
ServiceConfig: parseServiceConfig(t, r, serviceConfig),
463-
Addresses: []resolver.Address{addrs[0], addrs[1]},
464-
}
465-
r.UpdateState(shufState)
466-
if err := pickfirst.CheckRPCsToBackend(ctx, cc, addrs[0]); err != nil {
467-
t.Fatal(err)
468-
}
469-
}
470-
471429
// Test config parsing with the env var turned on and off for various scenarios.
472430
func (s) TestPickFirst_ParseConfig_Success(t *testing.T) {
473431
// Install a shuffler that always reverses two entries.
@@ -483,49 +441,23 @@ func (s) TestPickFirst_ParseConfig_Success(t *testing.T) {
483441

484442
tests := []struct {
485443
name string
486-
envVar bool
487444
serviceConfig string
488445
wantFirstAddr bool
489446
}{
490447
{
491-
name: "env var disabled with empty pickfirst config",
492-
envVar: false,
493-
serviceConfig: `{"loadBalancingConfig": [{"pick_first":{}}]}`,
494-
wantFirstAddr: true,
495-
},
496-
{
497-
name: "env var disabled with non-empty good pickfirst config",
498-
envVar: false,
499-
serviceConfig: `{"loadBalancingConfig": [{"pick_first":{ "shuffleAddressList": true }}]}`,
500-
wantFirstAddr: true,
501-
},
502-
{
503-
name: "env var disabled with non-empty bad pickfirst config",
504-
envVar: false,
505-
serviceConfig: `{"loadBalancingConfig": [{"pick_first":{ "shuffleAddressList": 666 }}]}`,
506-
wantFirstAddr: true,
507-
},
508-
{
509-
name: "env var enabled with empty pickfirst config",
510-
envVar: true,
448+
name: "empty pickfirst config",
511449
serviceConfig: `{"loadBalancingConfig": [{"pick_first":{}}]}`,
512450
wantFirstAddr: true,
513451
},
514452
{
515-
name: "env var enabled with empty good pickfirst config",
516-
envVar: true,
453+
name: "empty good pickfirst config",
517454
serviceConfig: `{"loadBalancingConfig": [{"pick_first":{ "shuffleAddressList": true }}]}`,
518455
wantFirstAddr: false,
519456
},
520457
}
521458

522459
for _, test := range tests {
523460
t.Run(test.name, func(t *testing.T) {
524-
// Set the env var as specified by the test table.
525-
origPickFirstLBConfig := envconfig.PickFirstLBConfig
526-
envconfig.PickFirstLBConfig = test.envVar
527-
defer func() { envconfig.PickFirstLBConfig = origPickFirstLBConfig }()
528-
529461
// Set up our backends.
530462
cc, r, backends := setupPickFirst(t, 2)
531463
addrs := stubBackendsToResolverAddrs(backends)
@@ -555,10 +487,6 @@ func (s) TestPickFirst_ParseConfig_Success(t *testing.T) {
555487

556488
// Test config parsing for a bad service config.
557489
func (s) TestPickFirst_ParseConfig_Failure(t *testing.T) {
558-
origPickFirstLBConfig := envconfig.PickFirstLBConfig
559-
envconfig.PickFirstLBConfig = true
560-
defer func() { envconfig.PickFirstLBConfig = origPickFirstLBConfig }()
561-
562490
// Service config should fail with the below config. Name resolvers are
563491
// expected to perform this parsing before they push the parsed service
564492
// config to the channel.

test/xds/xds_client_affinity_test.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525

2626
"google.golang.org/grpc"
2727
"google.golang.org/grpc/credentials/insecure"
28-
"google.golang.org/grpc/internal/envconfig"
2928
"google.golang.org/grpc/internal/stubserver"
3029
"google.golang.org/grpc/internal/testutils"
3130
"google.golang.org/grpc/internal/testutils/xds/e2e"
@@ -84,12 +83,6 @@ func ringhashCluster(clusterName, edsServiceName string) *v3clusterpb.Cluster {
8483
// propagated to pick the ring_hash policy. It doesn't test the affinity
8584
// behavior in ring_hash policy.
8685
func (s) TestClientSideAffinitySanityCheck(t *testing.T) {
87-
defer func() func() {
88-
old := envconfig.XDSRingHash
89-
envconfig.XDSRingHash = true
90-
return func() { envconfig.XDSRingHash = old }
91-
}()()
92-
9386
managementServer, nodeID, _, resolver, cleanup1 := e2e.SetupManagementServer(t, e2e.ManagementServerOptions{})
9487
defer cleanup1()
9588

test/xds/xds_client_custom_lb_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,6 @@ func clusterWithLBConfiguration(t *testing.T, clusterName, edsServiceName string
9393
// first) child load balancing policy, and asserts the correct distribution
9494
// based on the locality weights and the endpoint picking policy specified.
9595
func (s) TestWrrLocality(t *testing.T) {
96-
oldCustomLBSupport := envconfig.XDSCustomLBPolicy
97-
envconfig.XDSCustomLBPolicy = true
98-
defer func() {
99-
envconfig.XDSCustomLBPolicy = oldCustomLBSupport
100-
}()
10196
oldLeastRequestLBSupport := envconfig.LeastRequestLB
10297
envconfig.LeastRequestLB = true
10398
defer func() {

0 commit comments

Comments
 (0)