Skip to content

Conversation

@easwars
Copy link
Contributor

@easwars easwars commented Jul 21, 2023

Fixes #6469.

RELEASE NOTES:

  • pickfirst: guard config parsing on GRPC_EXPERIMENTAL_PICKFIRST_LB_CONFIG

@easwars easwars requested a review from dfawley July 21, 2023 20:06
@easwars easwars added this to the 1.57 Release milestone Jul 21, 2023
pickfirst.go Outdated
}

if envconfig.PickFirstLBConfig && b.cfg != nil && b.cfg.ShuffleAddressList {
if cfg != nil && cfg.ShuffleAddressList {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make cfg a value instead, to avoid the need for nil checks?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change ParseConfig to return a value instead of pointer, and switched to value here.

pickfirst.go Outdated
Comment on lines 123 to 130
var cfg *pfConfig
if state.BalancerConfig != nil {
cfg, ok := state.BalancerConfig.(*pfConfig)
var ok bool
cfg, ok = state.BalancerConfig.(*pfConfig)
if !ok {
return fmt.Errorf("pickfirstBalancer: received nil or illegal BalancerConfig (type %T): %v", state.BalancerConfig, state.BalancerConfig)
}
b.cfg = cfg
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose if you wanted to simplify this (optional):

cfg, ok := state.BalancerConfig.(*pfConfig)
if state.BalancerConfig != nil && !ok {
	return fmt.Errorf("illegal config")
}

And that (existing) "nil" in the error message is wrong, isn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, for both. Thanks.

@dfawley dfawley assigned easwars and unassigned dfawley Jul 24, 2023
@dfawley dfawley modified the milestones: 1.57 Release, 1.58 Release Jul 26, 2023
- use a config value instead of pointer
- simplify the LB config type assertion check
- fix the error message to not include `nil`
@easwars easwars assigned dfawley and unassigned easwars Jul 26, 2023
@dfawley dfawley assigned easwars and unassigned dfawley Jul 26, 2023
@easwars easwars merged commit 5ce5686 into grpc:master Jul 26, 2023
@easwars easwars deleted the pick_first_parse_config branch July 26, 2023 22:53
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pickfirst: parse configuration only if env var is turned on

2 participants