Skip to content

Conversation

@purnesh42H
Copy link
Contributor

@purnesh42H purnesh42H commented Jun 30, 2025

In internal usages of xdsclient, it was found that some resource type implementations (like MintCollection) expect wrapped resource to retrieve some information like ResourceName. Currently, xdsclient is sending the underlying raw resource to decoders which can break MintCollection resource type implementation (internal discussion).

This PR make the change to relay complete resource (including wrapped) to decoders and let them decode as they want.

RELEASE NOTES: None

@purnesh42H purnesh42H added Type: Bug Area: xDS Includes everything xDS related, including LB policies used with xDS. labels Jun 30, 2025
@purnesh42H purnesh42H added this to the 1.74 Release milestone Jun 30, 2025
@codecov
Copy link

codecov bot commented Jun 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.34%. Comparing base (dd718e4) to head (6cd3ed3).
Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8422      +/-   ##
==========================================
+ Coverage   82.27%   82.34%   +0.07%     
==========================================
  Files         414      414              
  Lines       40424    40421       -3     
==========================================
+ Hits        33259    33286      +27     
+ Misses       5795     5773      -22     
+ Partials     1370     1362       -8     
Files with missing lines Coverage Δ
xds/internal/clients/xdsclient/channel.go 78.84% <100.00%> (+0.79%) ⬆️
...ds/internal/xdsclient/xdsresource/resource_type.go 61.53% <100.00%> (+1.86%) ⬆️

... and 20 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
func (gd *GenericResourceTypeDecoder) Decode(resourceBytes []byte, gOpts xdsclient.DecodeOptions) (*xdsclient.DecodeResult, error) {
raw := &anypb.Any{TypeUrl: gd.ResourceType.TypeURL(), Value: resourceBytes}
rProto := &anypb.Any{}
if err := proto.Unmarshal(resourceBytes, rProto); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

It seems like such a waste to decode, encode, and re-decode this.

An Any is just a TypeURL and a []byte with the serialized proto data in it. Can we pass those two fields directly instead of the resourceBytes []byte that is a serialized proto message containing those two fields? This could then fill those in. Maybe just make a struct called AnyProto so it can extensibly mirror anypb.Any without putting a foreign symbol into our API?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. That's a good idea. It requires to change the Decode interface but its fine since no one is using the new client. Changed.

@purnesh42H purnesh42H requested a review from dfawley June 30, 2025 17:34
Copy link
Member

@dfawley dfawley left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!

@dfawley dfawley assigned purnesh42H and unassigned dfawley Jun 30, 2025
return "", listenerUpdate{}, fmt.Errorf("failed to unwrap resource: %v", err)
}
if !xdsresource.IsListenerResource(rProto.GetTypeUrl()) {
return "", listenerUpdate{}, fmt.Errorf("unexpected listener resource type: %q ", rProto.GetTypeUrl())
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Extra space at end of the error string.

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

@arjan-bal arjan-bal removed their assignment Jul 1, 2025
@purnesh42H purnesh42H merged commit f9cf0f6 into grpc:master Jul 2, 2025
15 checks passed
Pranjali-2501 pushed a commit to Pranjali-2501/grpc-go that referenced this pull request Jul 17, 2025
arjan-bal added a commit that referenced this pull request Jul 17, 2025
* xdsclient: preserve original bytes for decoding when the resource is wrapped (#8411)

* xds: Avoid error logs when setting fallback bootstrap config (#8419)

* xdsclient: relay marshalled bytes of complete resource proto to decoders (#8422)

* xds: give up pool lock before closing xdsclient channel (#8445)

* transport: release mutex before returning on expired deadlines in server streams (#8451)

---------

Co-authored-by: Easwar Swaminathan <easwars@google.com>
Co-authored-by: Arjan Singh Bal <46515553+arjan-bal@users.noreply.github.com>
Co-authored-by: Purnesh Dixit <purneshdixit@google.com>
Co-authored-by: Doug Fawley <dfawley@google.com>
dimpavloff pushed a commit to dimpavloff/grpc-go that referenced this pull request Aug 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: xDS Includes everything xDS related, including LB policies used with xDS. Type: Bug

3 participants