Skip to content

Commit 5812d40

Browse files
committed
xds: Remove temporary environment variable for least request.
Fixes grpc#8228.
1 parent 68205d5 commit 5812d40

File tree

5 files changed

+0
-48
lines changed

5 files changed

+0
-48
lines changed

test/xds/xds_client_custom_lb_test.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
_ "google.golang.org/grpc/balancer/leastrequest" // To register least_request
2929
_ "google.golang.org/grpc/balancer/weightedroundrobin" // To register weighted_round_robin
3030
"google.golang.org/grpc/credentials/insecure"
31-
"google.golang.org/grpc/internal/envconfig"
3231
"google.golang.org/grpc/internal/stubserver"
3332
"google.golang.org/grpc/internal/testutils"
3433
"google.golang.org/grpc/internal/testutils/roundrobin"
@@ -94,12 +93,6 @@ func clusterWithLBConfiguration(t *testing.T, clusterName, edsServiceName string
9493
// first) child load balancing policy, and asserts the correct distribution
9594
// based on the locality weights and the endpoint picking policy specified.
9695
func (s) TestWrrLocality(t *testing.T) {
97-
oldLeastRequestLBSupport := envconfig.LeastRequestLB
98-
envconfig.LeastRequestLB = true
99-
defer func() {
100-
envconfig.LeastRequestLB = oldLeastRequestLBSupport
101-
}()
102-
10396
backend1 := stubserver.StartTestService(t, nil)
10497
port1 := testutils.ParsePort(t, backend1.Address)
10598
defer backend1.Stop()

xds/internal/xdsclient/xdslbregistry/converter/converter.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import (
3232
"google.golang.org/grpc/balancer/pickfirst"
3333
"google.golang.org/grpc/balancer/roundrobin"
3434
"google.golang.org/grpc/balancer/weightedroundrobin"
35-
"google.golang.org/grpc/internal/envconfig"
3635
internalserviceconfig "google.golang.org/grpc/internal/serviceconfig"
3736
"google.golang.org/grpc/xds/internal/balancer/ringhash"
3837
"google.golang.org/grpc/xds/internal/balancer/wrrlocality"
@@ -176,9 +175,6 @@ func convertWeightedRoundRobinProtoToServiceConfig(rawProto []byte, _ int) (json
176175
}
177176

178177
func convertLeastRequestProtoToServiceConfig(rawProto []byte, _ int) (json.RawMessage, error) {
179-
if !envconfig.LeastRequestLB {
180-
return nil, nil
181-
}
182178
lrProto := &v3leastrequestpb.LeastRequest{}
183179
if err := proto.Unmarshal(rawProto, lrProto); err != nil {
184180
return nil, fmt.Errorf("failed to unmarshal resource: %v", err)

xds/internal/xdsclient/xdslbregistry/xdslbregistry_test.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727
"github.com/google/go-cmp/cmp"
2828
_ "google.golang.org/grpc/balancer/roundrobin"
2929
"google.golang.org/grpc/internal/balancer/stub"
30-
"google.golang.org/grpc/internal/envconfig"
3130
"google.golang.org/grpc/internal/grpctest"
3231
"google.golang.org/grpc/internal/pretty"
3332
internalserviceconfig "google.golang.org/grpc/internal/serviceconfig"
@@ -69,17 +68,13 @@ func wrrLocalityBalancerConfig(childPolicy *internalserviceconfig.BalancerConfig
6968
}
7069

7170
func (s) TestConvertToServiceConfigSuccess(t *testing.T) {
72-
defer func(old bool) { envconfig.LeastRequestLB = old }(envconfig.LeastRequestLB)
73-
envconfig.LeastRequestLB = false
74-
7571
const customLBPolicyName = "myorg.MyCustomLeastRequestPolicy"
7672
stub.Register(customLBPolicyName, stub.BalancerFuncs{})
7773

7874
tests := []struct {
7975
name string
8076
policy *v3clusterpb.LoadBalancingPolicy
8177
wantConfig string // JSON config
82-
lrEnabled bool
8378
}{
8479
{
8580
name: "ring_hash",
@@ -112,7 +107,6 @@ func (s) TestConvertToServiceConfigSuccess(t *testing.T) {
112107
},
113108
},
114109
wantConfig: `[{"least_request_experimental": { "choiceCount": 3 }}]`,
115-
lrEnabled: true,
116110
},
117111
{
118112
name: "pick_first_shuffle",
@@ -197,26 +191,6 @@ func (s) TestConvertToServiceConfigSuccess(t *testing.T) {
197191
},
198192
wantConfig: `[{"pick_first": { "shuffleAddressList": true }}]`,
199193
},
200-
{
201-
name: "least_request_disabled_pf_rr_use_first_supported",
202-
policy: &v3clusterpb.LoadBalancingPolicy{
203-
Policies: []*v3clusterpb.LoadBalancingPolicy_Policy{
204-
{
205-
TypedExtensionConfig: &v3corepb.TypedExtensionConfig{
206-
TypedConfig: testutils.MarshalAny(t, &v3leastrequestpb.LeastRequest{
207-
ChoiceCount: wrapperspb.UInt32(32),
208-
}),
209-
},
210-
},
211-
{
212-
TypedExtensionConfig: &v3corepb.TypedExtensionConfig{
213-
TypedConfig: testutils.MarshalAny(t, &v3roundrobinpb.RoundRobin{}),
214-
},
215-
},
216-
},
217-
},
218-
wantConfig: `[{"round_robin": {}}]`,
219-
},
220194
{
221195
name: "custom_lb_type_v3_struct",
222196
policy: &v3clusterpb.LoadBalancingPolicy{
@@ -307,10 +281,6 @@ func (s) TestConvertToServiceConfigSuccess(t *testing.T) {
307281

308282
for _, test := range tests {
309283
t.Run(test.name, func(t *testing.T) {
310-
if test.lrEnabled {
311-
defer func(old bool) { envconfig.LeastRequestLB = old }(envconfig.LeastRequestLB)
312-
envconfig.LeastRequestLB = true
313-
}
314284
rawJSON, err := xdslbregistry.ConvertToServiceConfig(test.policy, 0)
315285
if err != nil {
316286
t.Fatalf("ConvertToServiceConfig(%s) failed: %v", pretty.ToJSON(test.policy), err)

xds/internal/xdsclient/xdsresource/tests/unmarshal_cds_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727
"github.com/google/go-cmp/cmp/cmpopts"
2828
"google.golang.org/grpc/balancer/leastrequest"
2929
"google.golang.org/grpc/internal/balancer/stub"
30-
"google.golang.org/grpc/internal/envconfig"
3130
"google.golang.org/grpc/internal/grpctest"
3231
iserviceconfig "google.golang.org/grpc/internal/serviceconfig"
3332
"google.golang.org/grpc/internal/testutils"
@@ -105,8 +104,6 @@ func (s) TestValidateCluster_Success(t *testing.T) {
105104
t.Fatalf("Failed to create server config for testing: %v", err)
106105
}
107106

108-
defer func(old bool) { envconfig.LeastRequestLB = old }(envconfig.LeastRequestLB)
109-
envconfig.LeastRequestLB = true
110107
tests := []struct {
111108
name string
112109
cluster *v3clusterpb.Cluster

xds/internal/xdsclient/xdsresource/unmarshal_cds.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,6 @@ func validateClusterAndConstructClusterUpdate(cluster *v3clusterpb.Cluster, serv
133133
rhLBCfg := []byte(fmt.Sprintf("{\"minRingSize\": %d, \"maxRingSize\": %d}", minSize, maxSize))
134134
lbPolicy = []byte(fmt.Sprintf(`[{"ring_hash_experimental": %s}]`, rhLBCfg))
135135
case v3clusterpb.Cluster_LEAST_REQUEST:
136-
if !envconfig.LeastRequestLB {
137-
return ClusterUpdate{}, fmt.Errorf("unexpected lbPolicy %v in response: %+v", cluster.GetLbPolicy(), cluster)
138-
}
139-
140136
// "The configuration for the Least Request LB policy is the
141137
// least_request_lb_config field. The field is optional; if not present,
142138
// defaults will be assumed for all of its values." - A48

0 commit comments

Comments
 (0)