-
Notifications
You must be signed in to change notification settings - Fork 4.6k
xdsclient: relay marshalled bytes of complete resource proto to decoders #8422
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
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
🚀 New features to boost your workflow:
|
| 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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
…erialized proto bytes
There was a problem hiding this 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!
| 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()) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
* 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>
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 breakMintCollectionresource 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