Repository navigation
More work on ostree - #338
Conversation
f8a8353 to
09a9174
Compare
| layers: vec![], | ||
| value: None, | ||
| n_bytes: 0, | ||
| partial: Vec::new(), |
There was a problem hiding this comment.
I suspect https://docs.rs/bytes/latest/bytes/struct.BytesMut.html would make this code cleaner
There was a problem hiding this comment.
Not sure how you meant it to be used.
There was a problem hiding this comment.
A BytesMut is a special cased more powerful version of Vec<u8> basically that is designed specifically for "buffer" use cases, but anyways not blocking
FsVerityHasher::add_block() requires block-aligned input (exactly BLOCK_SIZE bytes, except for the final block). Both ensure_object_from_reader() and compute_verity_digest() fed it variable-sized chunks directly from BufReader::fill_buf(), which can return less than a full block at any time. This caused incorrect Merkle tree computation, producing different fs-verity digests for the same file content depending on how the reader chunked the data. Fix by adding FsVerityHasher::write() which accepts arbitrary-sized input and handles block buffering internally. Any partial block is flushed when digest() is called. Both callers now use write() instead of add_block(). Assisted-by: Claude Code (Opus 4.6) Signed-off-by: Alexander Larsson <[email protected]>
Ostree canonicalizes symlinks to size 0, not the size of the symlink. Assisted-by: Claude Code (Opus 4.6) Signed-off-by: Alexander Larsson <[email protected]>
We're gonna use some of the these in the public API, and these are anyway very stable formats. Signed-off-by: Alexander Larsson <[email protected]>
Various cleanups to the pull CLI operation: * We now use a shared progress reported, no eprint! * There is only one pull(), and it takes either a LocalRepo or a RemoteRepo * Pull options are passed via an extensible options struct Signed-off-by: Alexander Larsson <[email protected]>
This downloads and caches ostree summaries and flatpak-style subsummaries and uses them to resolve refs. Summaries are cached by ETAG or last modified, while subsummaries are cached by the checksum (which is in the index). Signed-off-by: Alexander Larsson <[email protected]>
Signed-off-by: Alexander Larsson <[email protected]>
Add support for applying ostree static deltas to the composefs repository via a new `cfsctl ostree apply-delta` CLI command. The implementation includes: - Custom GVariant framing parser for the delta superblock that avoids loading the entire file into memory (important for large inline deltas). Only the offset table and key strings are cached; inline part payloads are read on demand via pread. - Delta part executor supporting all 7 ostree opcodes: OPEN_SPLICE_AND_CLOSE, OPEN, WRITE, SET_READ_SOURCE, UNSET_READ_SOURCE, CLOSE, and BSPATCH. - Base commit object inheritance: walks the new commit's DAG and copies unchanged objects from the base commit's splitstream, since composefs-rs requires each commit splitstream to be self-contained. - Proper symlink handling (size includes NUL terminator, content not duplicated in the file header). Tested with a real ostree delta (gedit flatpak update) and verified that the resulting commit splitstream and EROFS image are byte-identical to a direct pull of the same commit. Assisted-by: Claude Code (Opus 4.6) Signed-off-by: Alexander Larsson <[email protected]>
When pulling from a remote ostree repository, check for available
static deltas before falling back to object-by-object fetching.
This is significantly faster for large commits.
Delta discovery checks two sources:
- The summary metadata's `ostree.static-deltas` key
- Per-commit delta indexes at `delta-indexes/{b64}.index`
When a usable delta is found (scratch or differential from a locally
available commit), the superblock and parts are fetched from the
remote. Parts are pipelined: the next part is fetched while the
current one is decompressed and applied via spawn_blocking.
Fallback objects (large files not included in delta parts) are
fetched using the existing fetch_file/fetch_object methods.
Also adds `PullStats::delta_parts_applied` to track delta usage,
and a `print_pull_stats` helper in the CLI that shows "via N delta
parts" when deltas were used.
Assisted-by: Claude Code (Opus 4.6)
Signed-off-by: Alexander Larsson <[email protected]>
Add three new tests: - test_ostree_pull_remote_scratch_delta: generates a from-scratch delta, serves over HTTP, pulls via delta, verifies image matches a direct local pull - test_ostree_pull_remote_diff_delta: generates a differential delta between two commits, pulls the base first, then the target via delta, verifies image matches - test_ostree_apply_delta_offline: generates an inline delta file, applies it via apply_delta_offline, verifies image matches Also refactors the existing test_ostree_pull_remote_archive to use a shared HttpServer helper (RAII cleanup via Drop). Assisted-by: Claude Code (Opus 4.6) Signed-off-by: Alexander Larsson <[email protected]>
09a9174 to
e606741
Compare
| #[cfg(any(feature = "oci", feature = "ostree"))] | ||
| use comfy_table::{Table, presets::UTF8_FULL}; | ||
| #[cfg(any(feature = "oci", feature = "http"))] | ||
| #[cfg(any(feature = "oci", feature = "http", feature = "ostree"))] |
There was a problem hiding this comment.
I think we can consolidate to a single #[cfg(content_fetching)] or so
| let mut ss = repo.create_stream(OSTREE_SUMMARY_CONTENT_TYPE)?; | ||
| ss.write_inline(header.as_bytes()); | ||
| ss.write_inline(etag_bytes); | ||
| ss.write_inline(lm_bytes); | ||
| ss.write_inline(summary_data); | ||
| repo.write_stream(ss, stream_id, None)?; |
There was a problem hiding this comment.
Nonblocking but just thinking: I'd like to make it feel nice again to store externally defined content without touching composefs core. I could imagine for example this use case is basically "store summary as OCI artifact" for example.
(Of course we could make that even more formal outside of this project)
It is basically arguing for composefs-ostree to depend on composefs-oci in a way, or at least parts of it.
There was a problem hiding this comment.
In this case (ostree) we need the data file (the summary) in the repo for internal use, but is there really any particular reason for a user facing store arbitrary single file blobs in the composefs repo? You're unlikely to put it into a composefs image or otherwise get dedup from this?
There was a problem hiding this comment.
Like, I imagine storing random directories of content in the repo is useful, like builds or what have you, but single file artifacts? What is the point?
|
|
||
| [dependencies] | ||
| anyhow = { version = "1.0.87", default-features = false } | ||
| bsdiff = { version = "0.2.1", default-features = false } |
There was a problem hiding this comment.
Have you looked that this is equivalent to the C code vendored in libostree? I suspect There Be 🐉
There was a problem hiding this comment.
I would think that if bsdiff apply produced a different result thatn the C code we would detect this as it would produce a different checksum for the new ostree object. However, I see we're not actually validating the produced checksums in the delta apply case, will fix that.
There was a problem hiding this comment.
(added the checksum check)
| /// | ||
| /// `base` is needed to resolve `SET_READ_SOURCE` opcodes that reference | ||
| /// objects from the previous commit. | ||
| pub(crate) fn execute_delta_part<ObjectID: FsVerityHashValue>( |
There was a problem hiding this comment.
Likely worth wiring up to the fuzzing infra we have
|
I'll merge this and do later followups separately. |
|
I resolved all comments fixed in #340 |
This adds some fixes and cleanups to the ostree support, adds a list-refs command, and then adds support for ostree summaries and static deltas.
Also, there is a fix to FsVerityHasher that may be important to non-ostree users as well.