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

fix: handle calling Contents on massive files #6772

Merged
merged 2 commits into from Mar 5, 2024

Conversation

jedevc
Copy link
Member

@jedevc jedevc commented Feb 28, 2024

Fixes #6743.

We have a message size limit enforced by the gRPC connection - however, we then go to host a HTTP server on that connection, and we weren't performing any restrictions on the size of the Writes.

To resolve this, for any Write that is larger than (an adjusted for headers) size limit, we split it into multiple Write calls which will split it into several BytesMessages by the grpchijack package.

Note: no such transformation is required for Reads, since go permits short-reads, but does not permit short-writes (so grpchijack can return under the requested number of bytes).

Arguably, this should be implemented upstream, however, it's tricky. Currently, the only upstream use of grpchijack is to host the session, which performs it's own message shortening procedures, which seems very fair - this patch just creates our own similar generic implementation for HTTP serving.

@jedevc jedevc requested a review from sipsma February 28, 2024 15:49
@jedevc jedevc added this to the v0.10.1 milestone Mar 4, 2024
Copy link
Contributor

@vito vito left a comment

Choose a reason for hiding this comment

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

lgtm - feels like there's significant overlap with our flushAfterNBytes helper, just mentioning in case there's a way to consolidate

We have a message size limit enforced by the gRPC connection - however,
we then go to host a HTTP server on that connection, and we weren't
performing any restrictions on the size of the `Write`s.

To resolve this, for any `Write` that is larger than (an adjusted for
headers) size limit, we split it into multiple `Write` calls which will
split it into several `BytesMessage`s by the `grpchijack` package.

Note: no such transformation is required for `Read`s, since go permits
short-reads, but does not permit short-writes (so `grpchijack` can
return under the requested number of bytes).

Arguably, this should be implemented upstream, however, it's tricky.
Currently, the only upstream use of `grpchijack` is to host the session,
which performs it's own message shortening procedures, which seems very
fair - this patch just creates our own similar generic implementation
for HTTP serving.

Signed-off-by: Justin Chadwell <me@jedevc.com>
Signed-off-by: Justin Chadwell <me@jedevc.com>
@jedevc jedevc force-pushed the fix-massive-file-contents branch from 961f4f8 to 6c8234e Compare March 5, 2024 09:39
@jedevc jedevc merged commit 18c8c42 into dagger:main Mar 5, 2024
41 of 43 checks passed
@jedevc jedevc deleted the fix-massive-file-contents branch March 5, 2024 10: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.

🐞 grpc: received message larger than max
3 participants