Skip to content

Commit

Permalink
pick_first: de-experiment pick first (#6549)
Browse files Browse the repository at this point in the history
  • Loading branch information
mohanli-ml authored Aug 14, 2023
1 parent 2821d7f commit 402ba09
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
5 changes: 2 additions & 3 deletions internal/envconfig/envconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ var (
// checking which NACKs configs specifying ring sizes > 8*1024*1024 (~8M).
RingHashCap = uint64FromEnv("GRPC_RING_HASH_CAP", 4096, 1, 8*1024*1024)
// PickFirstLBConfig is set if we should support configuration of the
// pick_first LB policy, which can be enabled by setting the environment
// variable "GRPC_EXPERIMENTAL_PICKFIRST_LB_CONFIG" to "true".
PickFirstLBConfig = boolFromEnv("GRPC_EXPERIMENTAL_PICKFIRST_LB_CONFIG", false)
// pick_first LB policy.
PickFirstLBConfig = boolFromEnv("GRPC_EXPERIMENTAL_PICKFIRST_LB_CONFIG", true)
// ALTSMaxConcurrentHandshakes is the maximum number of concurrent ALTS
// handshakes that can be performed.
ALTSMaxConcurrentHandshakes = uint64FromEnv("GRPC_ALTS_MAX_CONCURRENT_HANDSHAKES", 100, 1, 100)
Expand Down
24 changes: 22 additions & 2 deletions xds/internal/xdsclient/xdslbregistry/xdslbregistry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,26 @@ func (s) TestConvertToServiceConfigSuccess(t *testing.T) {
wantConfig: `[{"round_robin": {}}]`,
pfDisabled: true,
},
{
name: "pick_first_enabled_pf_rr_use_pick_first",
policy: &v3clusterpb.LoadBalancingPolicy{
Policies: []*v3clusterpb.LoadBalancingPolicy_Policy{
{
TypedExtensionConfig: &v3corepb.TypedExtensionConfig{
TypedConfig: testutils.MarshalAny(&v3pickfirstpb.PickFirst{
ShuffleAddressList: true,
}),
},
},
{
TypedExtensionConfig: &v3corepb.TypedExtensionConfig{
TypedConfig: testutils.MarshalAny(&v3roundrobinpb.RoundRobin{}),
},
},
},
},
wantConfig: `[{"pick_first": { "shuffleAddressList": true }}]`,
},
{
name: "custom_lb_type_v3_struct",
policy: &v3clusterpb.LoadBalancingPolicy{
Expand Down Expand Up @@ -297,9 +317,9 @@ func (s) TestConvertToServiceConfigSuccess(t *testing.T) {
defer func(old bool) { envconfig.XDSRingHash = old }(envconfig.XDSRingHash)
envconfig.XDSRingHash = false
}
if !test.pfDisabled {
if test.pfDisabled {
defer func(old bool) { envconfig.PickFirstLBConfig = old }(envconfig.PickFirstLBConfig)
envconfig.PickFirstLBConfig = true
envconfig.PickFirstLBConfig = false
}
rawJSON, err := xdslbregistry.ConvertToServiceConfig(test.policy, 0)
if err != nil {
Expand Down

0 comments on commit 402ba09

Please sign in to comment.