Repository navigation
Conversation
ostree_repo_pull_with_options() and ostree_repo_remote_fetch_summary_with_options() looked the option up with GVariant type "b", but it is documented as "u" and the CLI passes it as "u". The lookup never matched, so the option was silently ignored and every pull ran with the default of 8 requests. Read it as "u". Now that it takes effect, a value of 0 would never start a request; treat it as the default and say so in the docs. The curl fetcher also caps total connections at 8. Servers that only speak HTTP/1.1 get their concurrency from parallel connections, so let that cap follow the request limit, never going below 8. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
initiate_next_curl_request() appends If-None-Match, If-Modified-Since and the extra headers to req->req_headers on every attempt but never empties the list, so a request that moves on to the next mirror sends each of them again, once more per earlier attempt. Free the list before building it again. The previous easy handle still points at it through CURLOPT_HTTPHEADER, so clean that up first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In preparation for s3:// support living in a file of its own, move struct OstreeFetcher and FetcherRequest into ostree-fetcher-curl-private.h, along with the request helpers that code needs: creating a request and its task, completing it, getting its tmpfile, and starting its next attempt (initiate_next_curl_request(), now _ostree_fetcher_request_initiate()). No functional change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Parse remote URLs of the form
s3://bucket/prefix?region=...&profile=...&endpoint=...
and build the URL to request for a path below them: virtual-hosted
style on AWS (path style for bucket names that can't be hostnames),
path style on an ?endpoint= server, with keys percent-encoded the way
SigV4 canonicalizes them. Unknown parameters, a %2F in the prefix and
region names unsafe to put in a hostname are rejected rather than
guessed at.
Also add parsing of S3's XML error documents and the rule for when
cached credentials may still be used.
This is built only with the new configure option --with-aws, which
requires --with-curl and aws-c-auth 0.9.1 or later; the following
commits use both. aws-c-auth ships no pkg-config file, so it is probed
for directly, and AWS_CFLAGS and AWS_LIBS override the defaults.
Nothing uses the new code yet.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve credentials from the same sources as the AWS CLI, in this order: the environment, an SSO session, the shared config and credentials files (including assume-role and credential_process), web identity, then ECS and EC2 instance metadata. aws-c-auth's default chain has no SSO, so the chain is built here, behind a cache that refreshes credentials before they expire. Resolve the signing region from ?region=, then AWS_REGION or AWS_DEFAULT_REGION, then the profile, then instance metadata. Sign GET requests with aws-c-auth's SigV4 signer. Signing is synchronous once credentials are in hand, so the transport stays with curl: requests are signed and then sent like any other. The tests check signatures, including a non-default port and an IPv6 endpoint, against independently computed ones. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A remote URL of the form s3://bucket/prefix now pulls from a private S3 bucket holding an archive-mode repository, using whatever AWS credentials the host has. Each attempt is signed with SigV4 and sent through the curl fetcher as usual, so remote options such as proxy and tls-ca-path still apply. The s3:// code lives in ostree-fetcher-curl-s3.c and hooks into the curl fetcher at a few points. - Requests wait while credentials are fetched, and are then signed and sent. Credentials are shared by every request for the same profile and region. - An expired token is dropped and fetched again, and the request retried once. - S3 error documents are parsed so that failures say what went wrong: the S3 error code and message, and for a bucket in another region, which ?region= to use. A 404 is still "not found" (NoSuchKey and NoSuchBucket are told apart in the message), and a 403 is a hard error rather than "not found". - Redirects are not followed for s3://: curl forwards custom headers to the new host, which would hand it the signature and session token. - s3:// URLs are validated when a remote is used, so a typo in a parameter fails at once. - A metalink can only name http(s) URLs. Its protocol= attribute is a label, so a metalink could otherwise send the client to file:// or to an s3:// URL whose requests would be signed with the host's credentials. Without --with-aws, s3:// URLs are rejected with a clear error. tests/test-pull-s3.sh pulls from a local MinIO with static and temporary credentials, including static deltas, and checks the error cases. docs/s3-remotes.md covers building, URL syntax, credentials, security and limitations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A delta part is applied as soon as it has downloaded, and is held decompressed in memory while it is applied. So the number applied at once is bounded only by the number downloading at once, today _OSTREE_MAX_OUTSTANDING_DELTAPART_REQUESTS (2). Queue downloaded parts, as open files, and apply at most two at a time, so that a later commit can let more parts download without using more memory. Queued parts count against the download limit, so downloads only run so far ahead of applying. No change in behaviour while both limits are 2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
S3 serves HTTP/1.1 only and every object costs a full round trip, so throughput comes from having many requests in flight rather than from multiplexing. When content comes from s3://: - default to 128 requests at once rather than 8; an explicit max-outstanding-fetcher-requests still wins; - let up to 16 delta parts download at once rather than 2 (at most two are still applied at a time), never more than the request limit. Also don't set CURLOPT_PIPEWAIT for s3:// requests. It makes curl wait to see whether a connection can be shared, and with HTTP/1.1 that means every request queues behind one connection instead of opening more. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
One connection to S3 is often far slower than the link as a whole (about 1.5 MiB/s per connection, measured to GovCloud), so a single large object, such as a static delta part, holds up the end of a pull. Ask for the first 4 MiB of each object fetched to a file. If the Content-Range shows there is more, start one request per remaining 4 MiB part, each writing straight into the same tmpfile at its offset, and complete the object once its own transfer and every part have. The result must be as trustworthy as a whole-object fetch, because mirroring with --http-trusted links fetched files into the repo without checksumming them: - every ranged response, the first included, must be a 206 whose Content-Range names exactly the bytes asked for, with a body of exactly that length; an empty 206 is rejected too; - parts are only fetched separately when the first response carries a strong ETag, which every part must then match through If-Match, so an object replaced mid-download is never assembled from two versions; otherwise the object is fetched whole; - the finished file's size is checked against the object's size. When any part of an object fails, the object fails at once and its other parts are cancelled, whether downloading, waiting for credentials or about to start: the pull only counts the object, so a part must never outlive it. A request records that it has been returned, since g_task_get_completed() stays FALSE until the callback has run, and that is deferred once the cancellable is cancelled. The fetcher holds a reference to itself across curl's callbacks, so completing a request can never finalize it from inside one. The ranged-fetch state is a struct per side, the object (S3Ranges) and each part (S3Part), with a state enum for the object's attempt. tests/test-pull-s3-faults.sh pulls from a deliberately misbehaving server (failed, short, ignored, garbled and mislabelled ranges, missing or weak ETags, an object changing mid-download, empty and dropped first ranges) and checks that every failure leaves no partial object, leaves the commit marked partial and recovers on the next pull. It also runs several failing and several cancelled pulls in one process, under valgrind when available, with GLib criticals fatal. Together with the higher request limits, measured from a workstation to GovCloud against 32 requests at once, 2 delta parts at a time and whole-object fetches: an 88,000-object pull went from 280 s to 100 s and a 642 MiB static delta from about 130 s to 33 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The real AWS credential sources (SSO, assume-role, web identity, instance metadata) and the performance criteria can't be tested in CI. Add manual-tests/s3-check.sh: its pull mode pulls a ref and runs fsck, to be run once per credential source, and its bench mode compares s3:// with HTTPS from the same region and checks the request-limit gain. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
I'm not very excited about this for a few reasons. First, most of the investment from my side is now in https://github.com/bootc-dev/bootc/ and the OCI ecosystem has a lot of this covered very well. Typically registries are already abstractions around object stores, so we avoid hardcoding one specific IaaS vendor format (although of course the s3 protocol is pretty widely reimplemented/proxied). Second, it's a lot of new security sensitive code in C. There's some flatpak OCI support which we could in theory pull down here for host use cases too? |
Using the OCI registry layer on-top of ostree as a distribution mechanism introduces a complexity and an extra layer of abstraction that really reduces some of the value add of ostree as a library has for me right now. I completely understand that bootc is the driving consumer of this library as far as the maintainers here are concerned. The argument against an AWS specific s3 fetcher feels strong, if the implementation was vendor agnostic (but still allowed for some kind of credential usage) would that be enough of change to make this PR a consideration? I can understand if not, but I would be happy to meet in the middle if it was.
Yes, this does feel like a large concern here, although it does feel tractable (probably only around a thousand lines of critical path code, most of the real security concerns are likely within the aws c library, which feels trustworthy).
I guess I am not really familiar with this, but as soon as OCI is involved it would seem to me that the simple model of hosting an archive mode ostree repo in some network accessible location would no longer apply, which is a bummer to me. I appreciate the simplicity of host devices only needing to have access to the If you think this is too far outside the scope of this project (take a look at my question above), then feel free to close this PR with your reasoning, I don't want to pollute the open PRs this project. |
|
I wonder how tractable it'd be to make this a "plugin" like a shared library we support loading via That could allow the plugin to live in its own repository with its own version schemes etc. I think we could likely bypass a lot of gnarly details by having how we talk to this "plugin" happen by passing e.g. JSON messages over a pipe instead of synchronous calls via a strictly defined C API/ABI (maybe even varlink, though that comes with somewhat more baggage, but it's tractable). I know the age of agentic AI makes it easy to generate this kind of code, but maintaining still has a large cost and especially for a project as widely deployed as this one, we'd still have to fix any CVEs in this code and that'd require churn for everyone not actually using it. |
|
Yep, I totally get that last point, hence my disclaimers in the PR. Was a long shot, but I figured it was worth publishing here to see if it aligned with project goals. A plugin system would be nice, but I can say from the iteration I did on this PR that the current curl pipeline for fetch wasn't particularly well suited to s3 (which for example only supports HTTP 1.1, and so much higher numbers of concurrent connections are required to saturate bandwidth, etc.). It's not exactly clear to be where the surface area of the api should exists. At the highest level, I imagine the plugin api could be as simple as: Then local filesystem, generic http target, s3 with AWS creds, generic object storage, etc. could all be supported. I'm not sure what this would look like in terms of code size, but I can't imagine it would be much, if at all, simpler then this PR, so scope would still end up quite large. What you suggested, where only url signing is handed off to a plugin, might have considerably smaller scope, but as mentioned before gives less flexibility for the plugin to improve throughout by parallelizing efficiently, and might be over constrained for some possible fetching schemes (i.e. fetching through an api which cannot produce curl compatible uris). Obviously ensuring plugins correctly fetch would be a real footgun/security consideration for an approach which entirely hands off the fetch responsibility. I appreciate you taking the time to think about how supporting this use case might be possible in a way which aligns with upstream goals. |
|
@cgwalters I wonder if you could take a look at some of the individual commits in this larger Patch, and let me know if the fixes/improvements in them might make sense to upstream. They should be fairly self contained, and in particular the first few commits feel like meaninful fixes. |
Important
This series of patches represents an almost entirely LLM written attempt at introducing the ability to use s3 buckets as native remote sources.
I am putting this PR up to see if there is interest in such a feature, and to allow other people who find this feature valuable to have a place to discuss. I have full understanding that this is a large amount of code and maintenance burden being introduced to this project in support of a feature which does not appear to be an explicit upstream goal.
If there is interest, I am happy to work with maintainers on the code to get it into a merge-able state.
Add native
s3://remotes: pull from a private S3 bucket that holds an archive-mode repository, using whatever AWS credentials the host has.Design
credential_process), web identity, then ECS and EC2 instance metadata. It also signs each request with SigV4.proxyandtls-ca-pathkeep working.ostree-fetcher-curl-s3.cand hooks into the curl fetcher at a few points. Without--with-aws,s3://URLs are rejected with a clear error.?region=,?profile=and?endpoint=(for S3-compatible servers). Unknown parameters are rejected.?region=to use. A 404 stays "not found"; a 403 is a hard error.s3://remotes default to 128 requests in flight and up to 16 delta parts downloading at once, while at most 2 delta parts are applied at a time. Objects over 4 MiB are fetched as parallel 4 MiB ranges.If-Match. Every ranged response is checked against the bytes requested, and any failure fails the whole object. This keeps--http-trustedmirroring, which links fetched files without checksumming them, as safe as fetching each object whole.Measured from a workstation to AWS GovCloud: an 88,000-object pull takes 100 s, compared with 280 s at 32 requests in flight fetching whole objects. A 642 MiB static delta takes 33 s instead of about 130 s.
Commits
Commits 1 and 2 fix existing bugs and stand alone:
max-outstanding-fetcher-requestswas looked up with the wrong GVariant type, so it was silently ignored.Commit 3 is a refactor with no functional change.
Building
Configure with
--with-curl --with-aws(off by default). This needs aws-c-auth 0.9.1 or later, which ships no pkg-config file; setAWS_CFLAGSandAWS_LIBSif it isn't on the default search path. The AWS libraries are added toLibs.privateinostree-1.pcfor static linking.The scheme is documented in
ostree.repo-config(5), anddocs/s3-remotes.mdis a user guide.Testing
tests/test-fetcher-s3: URL parsing and encoding, S3 error parsing, region and credential resolution, and signatures checked against independently computed SigV4 signatures.tests/test-pull-s3.sh: pulls from a local MinIO with static and temporary credentials, static deltas, ranged objects and error cases.tests/test-pull-s3-faults.sh: pulls from a deliberately misbehaving server, covering failed, short, ignored, garbled and mislabelled ranges, missing or weak ETags, an object changing mid-download, and empty or dropped first ranges. Every failure must leave no partial object, keep the commit marked partial and recover on the next pull. It also runs several failing and cancelled pulls in one process, under valgrind when available.tests/test-pull-metalink.sh: a new case checks that a metalink can't redirect the client to ans3://URL.manual-tests/s3-check.shcovers what CI can't: real AWS credential sources, and performance against HTTPS.None of the current CI jobs configure
--with-aws, so the S3 tests are skipped there; they need aws-c-auth and, for the pull tests, MinIO. A CI job could be added if this goes forward.Limitations
s3://entries.aws sso loginagain or usecredential_process.?region=avoids it.🤖 Generated with Claude Code