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

Handle OCI-Chunk-Max-Length header field in blob pushes #4144

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gabivlj
Copy link

@gabivlj gabivlj commented Oct 30, 2023

This header comes from the proposal of adding a way for registries to limit chunk sizes from the client.

The implementation is simple enough; we're just adding a io.LimitReader and don't let it read more than the bytes that were specified by the registry.

Implements this:
opencontainers/distribution-spec#485

What do folks here think about this?

This has been tested manually on the moby repository and works with a registry that implements this header.

@wy65701436
Copy link
Collaborator

Thank you, @gabivlj. We may need to put this PR on hold as the upstream issue is still being discussed. Once your proposed solution is merged, we can start the review. Also, could you please add UT to verify the functionality of the header?

@wy65701436 wy65701436 added the dependencies Pull requests that update a dependency file label Oct 31, 2023
@gabivlj gabivlj force-pushed the dry-run-test branch 2 times, most recently from 66f6603 to e06cdf7 Compare October 31, 2023 11:34
@gabivlj
Copy link
Author

gabivlj commented Oct 31, 2023

Thanks for the suggestion @wy65701436! Added more tests now.

@milosgajdos
Copy link
Member

Please sign your commit @gabivlj

@gabivlj
Copy link
Author

gabivlj commented Oct 31, 2023

@milosgajdos Oh I thought I signed it. I added the footer

Signed-off-by: Gabi Villalonga <gvillalongasimon@cloudflare.com>

Isn't that enough? (EDIT: I guess I should've matched the entire name i have in user.name)

This header comes from the proposal of adding a way for registries to
limit chunk sizes from the client.

The implementation is simple enough; we're just adding a io.LimitReader
and don't let it read more than the bytes that were specified by the
registry.

Signed-off-by: Gabi Villalonga Simon <gvillalongasimon@cloudflare.com>
@milosgajdos
Copy link
Member

Thanks, @gabivlj, as @wy65701436 mentioned, we'll hold back on this until the OCI issue is resolved but I like where this is going.

@benbuzbee
Copy link

This would actually be useful for us - we want to put Cloudflare's CDN cache in front of our registry but this is a limitation we face today with large layer sizes.

It looks like the discussion from OCI has stalled, is there a world it can move forward with implementation anyway since a new extension header should be very backwards compatible? Maybe we can just rename the header, X-Experimental-Max-Length or some other pattern like this?

@milosgajdos
Copy link
Member

This would actually be useful for us - we want to put Cloudflare's CDN cache in front of our registry but this is a limitation we face today with large layer sizes.

I know quite a few companies front their registries with Cloudflare CDN. I am not sure how not having this option is preventing you from doing that. Though I think you'd need a storage driver middleware that works with CF 🤔

@gabivlj
Copy link
Author

gabivlj commented Nov 14, 2023

Yep! There is probably registries backed by Cloudflare's CDN; however if you try to push for example to a Cloudflare proxy with a layer that is bigger than 1GB, you will encounter failures.

I can repro by using a free cloudflared tunnel for example:

❯ docker run -d -p 5050:5000 --restart always registry:2
❯ cloudflared tunnel --url http://localhost:5050
❯ ... build big image and tag it as expenditure-icq-soundtrack-rick.trycloudflare.com/test:size ...
❯ docker push expenditure-icq-soundtrack-rick.trycloudflare.com/test:size
The push refers to repository [expenditure-icq-soundtrack-rick.trycloudflare.com/test]
1b363e3e008b: Pushing [==================================================>]  1.049GB
441715e61b4f: Pushing [==============>                                    ]   1.19GB/4.194GB
d2d3127fc3d3: Pushed 
error parsing HTTP 413 response body: invalid character '<' looking for beginning of value: "<html>\r\n<head><title>413 Request Entity Too Large</title></head>\r\n<body>\r\n<center><h1>413 Request Entity Too Large</h1></center>\r\n<hr><center>cloudflare</center>\r\n</body>\r\n</html>\r\n"

We can also repro by putting a Worker in front of another registry. If you try to upload through the worker it will also fail.

See more about the limits that can be encountered on the CDN:
https://developers.cloudflare.com/cache/concepts/default-cache-behavior/#upload-limits

And worker limits:
https://developers.cloudflare.com/workers/platform/limits/#request-limits

I think it would be nice for the registry to optionally define a chunk upload boundary like we're doing here to circumvent possible proxy upload size limitations.

@gabivlj
Copy link
Author

gabivlj commented Nov 28, 2023

Hi @milosgajdos, is there any way to circle back on this? Is there any interest on adding this? Is there any reviewer that we should call-in to have more feedback?

@milosgajdos
Copy link
Member

Hi @milosgajdos, is there any way to circle back on this? Is there any interest on adding this? Is there any reviewer that we should call-in to have more feedback?

There is interest from my side 💯 but I still think we should power through to get this into distribution-spec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants