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

Include response chunking info in nonce #3

Merged
merged 4 commits into from
Oct 2, 2024
Merged

Include response chunking info in nonce #3

merged 4 commits into from
Oct 2, 2024

Conversation

PapaCharlie
Copy link
Member

If a given delta response contains too many resources, the server will break it up into multiple responses. However, this means the client does not know whether it received all the resources for its subscription. This is especially relevant for wildcard subscriptions, for which the client does not know the resources ahead of time and therefore cannot wait for them explicitly. By returning additional metadata in the nonce (there is no field for this in the delta discovery response, though I'm hoping that will change cncf/xds#99), the client can know if the server chunked the response, and react accordingly.

If a given delta response contains too many resources, the server will break it
up into multiple responses. However, this means the client does not know whether
it received all the resources for its subscription. This is especially relevant
for wildcard subscriptions, for which the client does not know the resources
ahead of time and therefore cannot wait for them explicitly. By returning
additional metadata in the nonce (there is no field for this in the delta
discovery response, though I'm hoping that will change
cncf/xds#99), the client can know if the server
chunked the response, and react accordingly.
Comment on lines +23 to +25
// NewNonce creates a new unique nonce based on the current UNIX time in nanos, always returning a
// string of [NonceLength].
func NewNonce(remainingChunks int) string {

Choose a reason for hiding this comment

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

a smart yet big change to the nonce. To make sure it's backward compatible, I checked Rest.li xds client is not using the nonce in any way currently. May want to let Xin and Yan know to make sure Envoy is not using it too.

Copy link
Member Author

Choose a reason for hiding this comment

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

No one is, it's not supposed to be used for anything other than ACKs/NACKs, it's not meant to be interpreted more than that. Envoy doesn't use it at all for sure.

@@ -92,7 +92,7 @@ type deltaSender struct {
queuedUpdates []queuedResourceUpdate
// The minimum size an encoded chunk will serialize to, in bytes. Used to check whether a given
// update can _ever_ be sent, and as the initial size of a chunk. Note that this value only depends
// on utils.NonceLength and the length of typeURL.
// on utils.MaxNonceLength and the length of typeURL.

Choose a reason for hiding this comment

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

there seems to be no MaxNonceLength?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops

Copy link

@ZoabKapoor ZoabKapoor left a comment

Choose a reason for hiding this comment

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

This is awesome! It overall looks good but I wanted to call out one potential edge case of the ParseRemainingChunksFromNonce function (see the inline comment)

ads/ads.go Outdated
// max gRPC message size of 4MB. A nonce from Diderot always starts with the 64-bit nanosecond
// timestamp of when the response was generated on the server. Then the number of remaining chunks as
// a 32-bit integer. The sequence of integers is binary encoded with [binary.BigEndian] then hex
// encoded. If the given nonce does not match the expected format, this function simply returns 0, as

Choose a reason for hiding this comment

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

Should this return -1 instead of 0 or some other special value if the nonce didn't match the expected format? It could also return remainingChunks, err if that would be more idiomatic

Otherwise, someone using ParseRemainingChunksFromNonce would be unable to distinguish "this is the last chunk in the response" from "the nonce didn't match the format so we don't know how many chunks remain in the response", right?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's kind of the point actually. By default, the behavior in xDS is to not wait for chunks, since that notion doesn't really exist. Ultimately, if the nonce doesn't have the right format, then the only valid behavior is not to wait, that's why it just returns 0. There's literally nothing a caller of this function could do.

Copy link
Member Author

Choose a reason for hiding this comment

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

Zoab brought up a good point offline which is that returning an error at least signals to callers that the nonce wasn't in the right format, and even though they can't do anything about it, they can still log a warning.

@PapaCharlie PapaCharlie enabled auto-merge (squash) October 2, 2024 22:36
@PapaCharlie PapaCharlie merged commit a4a1d81 into master Oct 2, 2024
2 checks passed
@PapaCharlie PapaCharlie deleted the pc/chunk branch October 2, 2024 23:09
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