Skip to content

xds: Compare parsed GrpcService configs by their source and add a key - #13215

Open
shivaspeaks wants to merge 6 commits into
grpc:masterfrom
shivaspeaks:xds-grpcservice-key
Open

shivaspeaks wants to merge 6 commits into
grpc:masterfrom
shivaspeaks:xds-grpcservice-key

Conversation

@shivaspeaks

@shivaspeaks shivaspeaks commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Parsed GrpcService configs couldn't be compared. ConfiguredChannelCredentials.equals() compared the built ChannelCredentials, which use identity, and call credentials kept no record of their configuration (raised in #12492).

ConfiguredChannelCredentials and the new ConfiguredCallCredentials now keep the type and data of the configuration the credentials were built from, and compare by those, replacing ChannelCredsConfig. The data is the serialized config proto, or the bootstrap JSON config. grpc-go's credentials have carried this identity since grpc/grpc-go#9319.

GrpcServiceConfig.key() returns a SHA-256 hash of the config's fields, so equal configs get equal keys and no key holds credentials. grpc-go's Config.Key() (grpc/grpc-go#9508) returns the fields themselves, but this key will appear in LB configs, logs and errors, so it's hashed.

The autosharding LB policy's xDS integration (gRFC A119) will use the key as its channel factory key.

Credential parse errors now also keep the protobuf exception as their cause (raised in #12492).

@shivaspeaks

shivaspeaks commented Dec 2, 2026 •

Copy link
Copy Markdown
Member Author

Summary of the major changes in this PR:

1. Credentials are compared by the config they were built from

  • ConfiguredChannelCredentials now holds (channelCredentials, type, data), and the new ConfiguredCallCredentials holds (callCredentials, type, data).
  • equals() and hashCode() use only type and data. The built credentials are carried along but not compared, since they only have identity equality. This matches grpc-go's credential Identity{Type, Data} (xds: Implement GrpcService parsing and shared side channels (gRFC A102) grpc-go#9319).
  • Where type and data come from:
    • proto plugin: the Any's type URL and value (the serialized config message);
    • bootstrap JSON: the entry's "type", and its "config" serialized in its own key order. As in grpc-go, which compares the raw bytes, keys in a different order count as different. null values are kept, and a missing "config" counts as {}, which is what the credentials provider receives.
  • Both are plain final classes instead of AutoValue. create() rejects nulls, and toString() prints only the type, since data can hold secrets such as an access token.

2. ChannelCredsConfig is removed (@Internal)

  • ChannelCredsConfig, ProtoChannelCredsConfig and JsonChannelCredsConfig are gone; callers use type() and data() instead.

3. Call credentials keep their config

  • AllowedGrpcService.callCredentials() (Optional<CallCredentials>) is replaced by configuredCallCredentials(), an ImmutableList<ConfiguredCallCredentials> that defaults to empty.
  • GoogleGrpcConfig stores the list the same way. callCredentials() is now derived: it combines the list with CompositeCallCredentials, so existing callers are unchanged.

4. GrpcServiceConfig.key()

  • Returns the SHA-256 hex of the config's fields: the target, the channel credentials' type and data, each call credential's type and data in order, the timeout, and the initial metadata in order.
  • Two configs get the same key exactly when they're equal, barring collisions.
  • It's a hash because it will appear in LB configs, logs and errors, so it can't hold tokens or metadata values. grpc-go's Config.Key() (internal/xds: support a Key() method on grpcservice.Config grpc-go#9508) returns the fields themselves.
  • The A119 autosharding xDS integration (next PR) will use it as the channel factory key.

5. Smaller changes

  • Credential parse errors keep the InvalidProtocolBufferException as their cause.
  • ExtAuthzFilter builds the combined call credentials once instead of twice.

Behavior notes

  • No runtime change: ext_authz and ext_proc build the same credentials and channels as before. Nothing compares configs at runtime yet, since the channel cache was removed in Ext_proc filter and client interceptor #12792.
  • Equality errs toward "different". The same credential kind from a proto and from bootstrap, reordered call credentials or headers, and reordered bootstrap JSON keys all count as different. At worst that costs an extra channel, never a wrongly shared one.
  • Bootstrap call_creds are still ignored (A97 TODO), now as an empty list.

@shivaspeaks
shivaspeaks marked this pull request as ready for review December 2, 2026 09:09

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.

1 participant