Skip to content

autosharding: implementation of EndpointMap, autosharding client and LB Policy - #13039

Open
shivaspeaks wants to merge 81 commits into
grpc:masterfrom
shivaspeaks:autosharding-part3-lazy-endpoints
Open

shivaspeaks wants to merge 81 commits into
grpc:masterfrom
shivaspeaks:autosharding-part3-lazy-endpoints

Conversation

@shivaspeaks

@shivaspeaks shivaspeaks commented Sep 8, 2026 •

Copy link
Copy Markdown
Member

@shivaspeaks
shivaspeaks marked this pull request as ready for review September 8, 2026 09:49
@shivaspeaks
shivaspeaks requested a review from sauravzg September 8, 2026 09:49

@sauravzg sauravzg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed all of source. Some comments may be outdated since this was a large PR and I have been incrementally reviewing it for quite some time.

@shivaspeaks
shivaspeaks requested a review from sauravzg November 9, 2026 13:02
@shivaspeaks

Copy link
Copy Markdown
Member Author

Merged master and updated autosharding/BUILD.bazel for the LB sources, now that the Bazel build (#13207) is in.

@sauravzg sauravzg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We are very close.

Most of the comments are "just update to the latest spec".

The two critical ones for me are the one about empty string and how we do endpoint location substitution, since they can break production.

I'd feel comfortable to pre-approve the PR and let you handle the remaining if those two are addressed.

return;
}
if (firstIdle == null && holder.state == IDLE) {
firstIdle = holder;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

String hostname =
endpoint.getAttributes().get(InternalEquivalentAddressGroup.ATTR_ADDRESS_NAME);
return hostname != null ? hostname : endpoint.getAddresses().get(0).toString();
return hostname != null ? hostname : addressName(endpoint.getAddresses().get(0));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We also need to handle the case of empty hostname.

.setAttributes(attributes)
.build());
if (!status.isOk()) {
// pick_first only rejects an address list it cannot use at all, which should not happen

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I recall commenting about it, not sure where it got lost or why you resolved it, I am don't feel comfortable about swallowing errors.
Even if it's rare , if there's a possibility of error , that should be fixed.

What do the other implementations do here?

I am also guessing this means some changes in this methods and it's chain of callers to propagate status.

byte[] key = args.getHeaders().get(keyHeader);
// The first value if the header was sent more than once; get() would return the last.
Iterable<byte[]> keys = args.getHeaders().getAll(keyHeader);
byte[] key = keys == null ? null : keys.iterator().next();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The grfc was changed to join them with comma likely.

if (key == null) {
// wait-for-ready RPCs keep waiting for a picker
// that can route them, and the others fail.
return PickResult.withError(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the grfc mentions to drop the rpc with internal error.

* yield null, so the result never depends on resolver ordering.
*/
@Nullable
private static String sharedLocality(List<EquivalentAddressGroup> endpoints) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think this is still correct . This returns incorrect target for cases where it tries to infer shared... when not beneat weighted target . Apart from correctness, the approach might be incorrect, we are trying to substitute an injected dependency with some business logic around how weighted target behaves, which can change in future.

My 2c would be to find a way to inject this by somehow making an internal attirbute in grpc-api or grpc-core and then have WeightedTarget point to it.
Maybe we can add a todo to move WeightedTarget to non xds ? c++ has it outside xds from what it seems which may be the right thing to do ?

Status.UNAVAILABLE
.withDescription(
"autosharding: channel factory rejected key '"
+ channelFactoryKey

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not ideal. channelFactoryKey may contain credentials. Might want to escalate to the other implementations to fix this since they seem to be doing it as well.

// RPCs are queued until a client reports, so the state is IDLE whatever the endpoints
// report. Reporting CONNECTING instead would keep a parent priority policy's failover
// timer running while the sharding service answers.
helper.updateBalancingState(IDLE, ASSIGNMENT_PENDING_PICKER);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This behaviour seems to have been changed in the grfc to report connecting. Pair this with changes for the initial connect timeout.

}
// A client only reports errors before it has reported an assignment, so an assignment in
// hand here came from a previous client. The new client's state replaces it.
logger.log(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

optional: Should we be logging warnings on each slicer assignment service error? Maybe we use fine? This is not critical so feel free to do what other implementations do.

}

@Override
public void requestConnection() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants