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

Add a new container/store module #99

Merged
merged 2 commits into from
Oct 7, 2021

Conversation

cgwalters
Copy link
Member

@cgwalters cgwalters commented Sep 23, 2021

tests: Use --no-bindings for base commit

Since we're not meaning to fetch this via libostree, using
bindings inhibits native pulls for forthcoming container copy
work.


Add a new container/store module

The initial scope of this project was just "encapsulating" ostree
commits in containers.

However, when doing that a very, very natural question arises:
Why not support deriving from that base image container, and
have the tooling natively support importing it?

This initial prototype code implements that. Here, we still use
the tar::import path for the base image - we expect it to have
a pre-generated ostree commit.

This new container::store module processes layered images and
generates (client side) ostree commits from the tar layers.

There's a whole lot of new infrastructure we need around mapping
ostree refs to blobs and images, etc.


@cgwalters
Copy link
Member Author

This will close #12 once it has more tests and validation.

@cgwalters
Copy link
Member Author

Open design question: right now I'm trying to strongly differentiate non-layered (i.e. pure ostree encapsulation, ideally GPG signed) from layered (from e.g. Dockerfile style build). But, does that make sense? Should we have a --layered option, or should we just drop the distinction and automatically apply a layered container if we're pointed at one?

@cgwalters
Copy link
Member Author

cgwalters commented Sep 24, 2021

Rebased 🏄 - now depends on #102

And when I tried this in the real world, I hit error: Preparing /etc: Tree contains both /etc and /usr/etc precisely because containers/buildah#3523

[root@cosa-devsh ~]# ostree ls d799d4ce5c3184774d6e73767d9fbb2e26b9d11d8669b252a70d616d44a791c5 /etc
d00755 0 0      0 /etc
-00700 0 0      0 /etc/resolv.conf
[root@cosa-devsh ~]# 

So we need to teach our tar importer to drop that junk.

@cgwalters
Copy link
Member Author

OK upgrades don't work yet, we're not storing tags correctly.

@cgwalters
Copy link
Member Author

OK upgrades don't work yet, we're not storing tags correctly.

Fixed

@cgwalters cgwalters force-pushed the layered-import branch 8 times, most recently from aab643e to 40d6816 Compare October 4, 2021 17:30
@cgwalters
Copy link
Member Author

Trying to use this to deploy the initial container, we also need a copy API I think so we can schlep the already-downloaded container from the cosa side into the VM without re-pulling.

This also ties into #115

@cgwalters cgwalters force-pushed the layered-import branch 2 times, most recently from d60de71 to 4458215 Compare October 5, 2021 15:48
@cgwalters cgwalters marked this pull request as ready for review October 5, 2021 17:22
@cgwalters cgwalters changed the title WIP: Add a new container/store module Add a new container/store module Oct 5, 2021
@cgwalters
Copy link
Member Author

OK lifting draft on this. There's a huge amount of stuff left to do, but I think iterating on main will be better than having this sit in a PR.

Since we're not meaning to fetch this via libostree, using
bindings inhibits native pulls for forthcoming `container copy`
work.
The initial scope of this project was just "encapsulating" ostree
commits in containers.

However, when doing that a very, very natural question arises:
Why not support *deriving* from that base image container, and
have the tooling natively support importing it?

This initial prototype code implements that.  Here, we still use
the `tar::import` path for the base image - we expect it to have
a pre-generated ostree commit.

This new `container::store` module processes layered images and
generates (client side) ostree commits from the tar layers.

There's a whole lot of new infrastructure we need around mapping
ostree refs to blobs and images, etc.
Copy link
Member

@lucab lucab left a comment

Choose a reason for hiding this comment

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

LGTM, though I think @travier was going through reviewing this right now too, so could wait a bit before merging.

@@ -58,7 +58,7 @@ fn generate_test_repo(dir: &Utf8Path) -> Result<Utf8PathBuf> {
indoc! {"
cd {dir}
ostree --repo=repo init --mode=archive
ostree --repo=repo commit -b {testref} --bootable --add-metadata-string=version=42.0 --gpg-homedir={gpghome} --gpg-sign={keyid} \
Copy link
Member

@lucab lucab Oct 6, 2021

Choose a reason for hiding this comment

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

I do understand the problem behind this, but I'm a bit less sure about the nuances/ramifications of it.
Are ref-bindings going to be problematic in the general case when we try to unencapsulate/import arbitrary commits built from an existing pipeline we don't control (yocto/endless/etc)?

@@ -0,0 +1,383 @@
//! APIs for storing (layered) container images as OSTree commits
Copy link
Member

Choose a reason for hiding this comment

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

Just a general note that this module has a bunch of for loops where the inner body is already fully async, but the current await arrangement follows head-of-line blocking. Those should be easy places where to win some speedup through concurrency, it would be good to mark them with clear TODO or XXX comments.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, though as https://docs.rs/tokio/1/tokio/task/fn.spawn_blocking.html says we should probably use rayon inside loops.

I haven't investigated that.


/// Import a layered container image
pub async fn import(mut self, import: PreparedImport) -> Result<CompletedImport> {
// First download the base image (if necessary) - we need the SELinux policy
Copy link
Member

Choose a reason for hiding this comment

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

This seems like a reasonable constraint, at least as a start. I do hope we don't get any usecase going against this, in the future.

@cgwalters
Copy link
Member Author

I think @travier was going through reviewing this right now too, so could wait a bit before merging.

OK, though since this is all experimental, not critical path stuff we can always do post-merge fixups!

@cgwalters cgwalters merged commit cc98d32 into ostreedev:main Oct 7, 2021
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.

2 participants