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

Allow doing start-end RANGE requests against blobs #163

Merged
merged 1 commit into from
Oct 4, 2024

Conversation

thundergolfer
Copy link
Contributor

Addresses #162

Copy link
Contributor

@flavio flavio left a comment

Choose a reason for hiding this comment

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

Seems fine, can you address the build failure?

Moreover, is there some way we can test this feature inside of our CI?

@thundergolfer
Copy link
Contributor Author

Oh damn sorry I thought this was compiling because I was pointing at my fork but I had a cached main 😖

@thundergolfer thundergolfer force-pushed the main branch 2 times, most recently from 4383888 to 0fc29b2 Compare September 10, 2024 16:09
Signed-off-by: Jonathon Belotti <jonathon@modal.com>
@thundergolfer
Copy link
Contributor Author

@flavio I updated the implementation and added a test. During reimplementation I switch to using pull_blob_stream_partial and ran into an issue where VerifyingStream doesn't work when you get a partial response back (the digests will never match).

I'm not sure how this was working before? Let me know what you think :)

StatusCode::PARTIAL_CONTENT => Ok(BlobResponse::Partial(stream_from_response(
response, &layer,
response, &layer, false,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the offset was ever non-zero this method should already have been failing on stream verification? I checked registry spec and couldn't see anything about returned specialized digests for partial reads.

Copy link
Contributor

Choose a reason for hiding this comment

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

It makes sense that partial pulls can't be validated, so we should probably document the pull_blob_stream_partial that partial pulls by nature cannot be validated and as such should be validated by the caller when complete

Copy link
Contributor

@thomastaylor312 thomastaylor312 Oct 4, 2024

Choose a reason for hiding this comment

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

Actually, now that I'm looking at this more, we might need to return the header digest to validate against to the caller on a partial request (probably as a new data member of SizedStream), otherwise they won't have access to that information (though they do have access to the layer digest). If there is a better way to do this that other clients use, that would work as well!

Copy link
Contributor

Choose a reason for hiding this comment

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

@thundergolfer If you'd like/are willing to do this, that would be great! If not, let me know and I'll switch this to an approval and I'll change it after merge since it is a preexisting edge case we didn't account for originally

Copy link
Contributor Author

@thundergolfer thundergolfer Oct 4, 2024

Choose a reason for hiding this comment

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

Hey @thomastaylor312, I've switched focus off the related project at work so I'll be unlikely to get to it soon.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok sounds good. I'll merge this as is and fix up. Thanks for adding this!

@flavio
Copy link
Contributor

flavio commented Sep 23, 2024

@thundergolfer thanks for having introduced the test case.

@thomastaylor312 can you take a quick look too?

@thundergolfer
Copy link
Contributor Author

Nice, thanks. Let me know if you need anything else before merge 👌

StatusCode::PARTIAL_CONTENT => Ok(BlobResponse::Partial(stream_from_response(
response, &layer,
response, &layer, false,
Copy link
Contributor

Choose a reason for hiding this comment

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

It makes sense that partial pulls can't be validated, so we should probably document the pull_blob_stream_partial that partial pulls by nature cannot be validated and as such should be validated by the caller when complete

@thomastaylor312
Copy link
Contributor

Sorry forgot to add context when I hit the submit button. This all looks good to me. One minor point around adding some clarification to the docs for a function around the security implications

@thomastaylor312 thomastaylor312 merged commit 95630d0 into oras-project:main Oct 4, 2024
5 checks passed
thomastaylor312 added a commit to thomastaylor312/oci-distribution that referenced this pull request Oct 4, 2024
In oras-project#163 it was pointed out that we can't use validating streams for
partial responses, which makes complete sense. Because of this, we need
to pass back the digest header for use in validation once a partial
download is complete

Signed-off-by: Taylor Thomas <taylor@cosmonic.com>
flavio added a commit to flavio/rust-oci-client that referenced this pull request Oct 7, 2024
== What's Changed
* client: add support to set https_proxy/no_proxy for client by @Xynnn007 in oras-project#160
* chore(deps): Update testcontainers requirement from 0.20 to 0.22 by @dependabot in oras-project#161
* Docs.rs badge, update crate name. by @bddap in oras-project#166
* chore(deps): Bump actions/checkout from 4.1.7 to 4.2.0 by @dependabot in oras-project#170
* chore(deps): Update testcontainers requirement from 0.22 to 0.23 by @dependabot in oras-project#169
* chore(deps): Update rstest requirement from 0.22.0 to 0.23.0 by @dependabot in oras-project#168
* Allow doing start-end RANGE requests against blobs by @thundergolfer in oras-project#163
* fix(client): Return the digest header for partial responses by @thomastaylor312 in oras-project#171
* remove reference by @flavio in oras-project#164

== New Contributors
* @bddap made their first contribution in oras-project#166
* @thundergolfer made their first contribution in oras-project#163

**Full Changelog**: oras-project/rust-oci-client@v0.12.1...v0.13.0

Signed-off-by: Flavio Castelli <fcastelli@suse.com>
@flavio flavio mentioned this pull request Oct 7, 2024
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