Skip to content

Commit bba5d5c

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

File tree

7 files changed

+5
-54
lines changed

7 files changed

+5
-54
lines changed

test/xds/xds_client_custom_lb_test.go

-7
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

-4
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.go

-2
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ func ConvertToServiceConfig(lbPolicy *v3clusterpb.LoadBalancingPolicy, depth int
6969
converter := m[policy.GetTypedExtensionConfig().GetTypedConfig().GetTypeUrl()]
7070
// "Any entry not in the above list is unsupported and will be skipped."
7171
// - A52
72-
// This includes Least Request as well, since grpc-go does not support
73-
// the Least Request Load Balancing Policy.
7472
if converter == nil {
7573
continue
7674
}

xds/internal/xdsclient/xdslbregistry/xdslbregistry_test.go

+3-32
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"
@@ -45,6 +44,7 @@ import (
4544
v3clusterpb "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3"
4645
v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
4746
v3leastrequestpb "github.com/envoyproxy/go-control-plane/envoy/extensions/load_balancing_policies/least_request/v3"
47+
v3maglevpb "github.com/envoyproxy/go-control-plane/envoy/extensions/load_balancing_policies/maglev/v3"
4848
v3pickfirstpb "github.com/envoyproxy/go-control-plane/envoy/extensions/load_balancing_policies/pick_first/v3"
4949
v3ringhashpb "github.com/envoyproxy/go-control-plane/envoy/extensions/load_balancing_policies/ring_hash/v3"
5050
v3roundrobinpb "github.com/envoyproxy/go-control-plane/envoy/extensions/load_balancing_policies/round_robin/v3"
@@ -69,17 +69,13 @@ func wrrLocalityBalancerConfig(childPolicy *internalserviceconfig.BalancerConfig
6969
}
7070

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

7875
tests := []struct {
7976
name string
8077
policy *v3clusterpb.LoadBalancingPolicy
8178
wantConfig string // JSON config
82-
lrEnabled bool
8379
}{
8480
{
8581
name: "ring_hash",
@@ -112,7 +108,6 @@ func (s) TestConvertToServiceConfigSuccess(t *testing.T) {
112108
},
113109
},
114110
wantConfig: `[{"least_request_experimental": { "choiceCount": 3 }}]`,
115-
lrEnabled: true,
116111
},
117112
{
118113
name: "pick_first_shuffle",
@@ -197,26 +192,6 @@ func (s) TestConvertToServiceConfigSuccess(t *testing.T) {
197192
},
198193
wantConfig: `[{"pick_first": { "shuffleAddressList": true }}]`,
199194
},
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-
},
220195
{
221196
name: "custom_lb_type_v3_struct",
222197
policy: &v3clusterpb.LoadBalancingPolicy{
@@ -307,10 +282,6 @@ func (s) TestConvertToServiceConfigSuccess(t *testing.T) {
307282

308283
for _, test := range tests {
309284
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-
}
314285
rawJSON, err := xdslbregistry.ConvertToServiceConfig(test.policy, 0)
315286
if err != nil {
316287
t.Fatalf("ConvertToServiceConfig(%s) failed: %v", pretty.ToJSON(test.policy), err)
@@ -381,8 +352,8 @@ func (s) TestConvertToServiceConfigFailure(t *testing.T) {
381352
},
382353
{
383354
TypedExtensionConfig: &v3corepb.TypedExtensionConfig{
384-
// Not supported by gRPC-Go.
385-
TypedConfig: testutils.MarshalAny(t, &v3leastrequestpb.LeastRequest{}),
355+
// Maglev is not yet supported by gRPC.
356+
TypedConfig: testutils.MarshalAny(t, &v3maglevpb.Maglev{}),
386357
},
387358
},
388359
},

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

-3
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

-4
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

xds/internal/xdsclient/xdsresource/unmarshal_cds_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func (s) TestValidateCluster_Failure(t *testing.T) {
107107
wantErr: true,
108108
},
109109
{
110-
name: "non-round-robin-or-ring-hash-lb-policy",
110+
name: "unsupported-lb-policy",
111111
cluster: &v3clusterpb.Cluster{
112112
ClusterDiscoveryType: &v3clusterpb.Cluster_Type{Type: v3clusterpb.Cluster_EDS},
113113
EdsClusterConfig: &v3clusterpb.Cluster_EdsClusterConfig{
@@ -117,7 +117,7 @@ func (s) TestValidateCluster_Failure(t *testing.T) {
117117
},
118118
},
119119
},
120-
LbPolicy: v3clusterpb.Cluster_LEAST_REQUEST,
120+
LbPolicy: v3clusterpb.Cluster_MAGLEV,
121121
},
122122
wantErr: true,
123123
},

0 commit comments

Comments
 (0)