Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xds/internal/xdsclient: Add least request support in xDS #6517

Merged
merged 5 commits into from
Aug 16, 2023

Conversation

zasweq
Copy link
Contributor

@zasweq zasweq commented Aug 8, 2023

This PR adds least request support plumbed through xDS.

RELEASE NOTES:

  • xds/internal/xdsclient: Add least request support in xDS

@easwars
Copy link
Contributor

easwars commented Aug 10, 2023

Tests are still unhappy.

@easwars easwars assigned zasweq and unassigned easwars Aug 10, 2023
@zasweq zasweq added the Type: Feature New features or improvements in behavior label Aug 10, 2023
@zasweq zasweq added this to the 1.58 Release milestone Aug 10, 2023
@zasweq zasweq force-pushed the least-request-in-xds branch 2 times, most recently from cf9e1f5 to e5f50f2 Compare August 10, 2023 18:24
@zasweq
Copy link
Contributor Author

zasweq commented Aug 10, 2023

I think should be good to review. Sorry for missing that haha.

@zasweq zasweq assigned easwars and unassigned zasweq Aug 10, 2023
xds/internal/xdsclient/xdsresource/unmarshal_cds.go Outdated Show resolved Hide resolved
internal/balancer/leastrequest/leastrequest.go Outdated Show resolved Hide resolved
internal/balancer/leastrequest/leastrequest.go Outdated Show resolved Hide resolved
xds/internal/xdsclient/xdsresource/unmarshal_cds.go Outdated Show resolved Hide resolved
internal/balancer/leastrequest/balancer_test.go Outdated Show resolved Hide resolved
xds/internal/xdsclient/xdslbregistry/xdslbregistry_test.go Outdated Show resolved Hide resolved
@easwars easwars assigned zasweq and unassigned easwars Aug 10, 2023
@zasweq
Copy link
Contributor Author

zasweq commented Aug 11, 2023

Got to all comments. Thanks for the pass :D.

@zasweq zasweq assigned easwars and unassigned zasweq Aug 11, 2023
@zasweq zasweq force-pushed the least-request-in-xds branch 4 times, most recently from c031b2f to 8684203 Compare August 12, 2023 00:44
@easwars
Copy link
Contributor

easwars commented Aug 15, 2023

Could you please resolve the conflicts before I take another pass. Thanks.

@easwars easwars assigned zasweq and unassigned easwars Aug 15, 2023
@zasweq
Copy link
Contributor Author

zasweq commented Aug 15, 2023

Done. The thing that created conflicts was the deexperimentalization of pick first.

@zasweq zasweq assigned easwars and unassigned zasweq Aug 15, 2023
Copy link
Contributor

@easwars easwars left a comment

Choose a reason for hiding this comment

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

Some minor nits, LGTM modulo those.

ChoiceCount: wrapperspb.UInt32(2),
}),
// Least request's randomness of indexes to sample (unary RPCs which
// don't persist so never any actual RPC counts over iterations)
Copy link
Contributor

Choose a reason for hiding this comment

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

Something is incomplete in this sentence:

unary RPCs which don't persist so never any actual RPC counts over iterations

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to "The test performs a Unary RPC, and blocks until the RPC returns, and then makes the next RPC. Thus, over iterations, no RPC counts are present. This causes Least request's randomness of indexes to sample to converge onto a round robin distribution per locality. Thus, expect the same distribution as round robin above."

// "The configuration for the Least Request LB policy is the
// least_request_lb_config field. The field is optional; if not present,
// defaults will be assumed for all of its values." - A48
var choiceCount uint32 = defaultLeastRequestChoiceCount
Copy link
Contributor

Choose a reason for hiding this comment

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

Not asking you to change, but just FYI choiceCount := uint32(defaultLeastRequestChoiceCount) is shorter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switched. I feel like throughout the codebase and my years on the team, x := y vs. var x type = y has always been preferred for local vars declaration to a non zero value. Noted for future.

Comment on lines 339 to 342
if test.lrDisabled {
defer func(old bool) { envconfig.LeastRequestLB = old }(envconfig.LeastRequestLB)
envconfig.LeastRequestLB = false
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Default value of envconfig.LeastRequestLB is already false. You are setting it to true for the duration of the test at the top, and then setting it to false here again.

Why not have a lrEnabled field which is set to true only for tests that require it, and here, you can check for if test.lrEnabled { // set the env var to true }

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 :). Good suggestion.

if cc := lr.GetChoiceCount(); cc != nil {
choiceCount = cc.GetValue()
}
// nack if it's < 2, and also add test for it
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove the also add test for it part of it.

And probably quote the relevant language from the gRFC if that makes sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switched comment to: // "If choice_count < 2, the config will be rejected." - A48

@easwars easwars assigned zasweq and unassigned easwars Aug 16, 2023
@zasweq zasweq merged commit aca07ce into grpc:master Aug 16, 2023
10 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Feature New features or improvements in behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants