Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

container: Rework API and model around "base commit" and "merge commit" #147

Merged
merged 4 commits into from
Nov 4, 2021

Conversation

cgwalters
Copy link
Member

containers: Expose a state struct with base commit and layering state

This is actually quite analogous to what rpm-ostree does internally;
a lot of the internals there distinguish "base" versus "layered"
commits, and this is very similar.

Here, when we import a non-layered image, we can mostly
ignore the merge commit since all it has is the image manifest.
The base image layer ref is the encapsulated ostree commit with
all the metadata injected by (rpm-)ostree in the non-layered case.

Add an API which exposes this as a struct, and also return it
from the importer's AlreadyPresent case.


container: Change import result case to contain state struct

Notably, this also stops exposing the ostree ref for the merge commit,
which I think is a good idea in general since it should be thought
of more as an implementation detail.

In other words, this module speaks container image references
and ostree commits.


container/deploy: Use base commit if we're not layered

If we're not doing a layered image, then use the base commit
for the deployment.

Closes: #143


container/deploy: Also write ref with target if provided

With this new emphasis on "dual commit objects" for the container
deployment, the higher level code queries via container image references
and we don't expose the ostree ref (since there is no longer a single
one).

This makes it critical to write the internal ref matching the
target container image, because it now needs to match the origin.


This is actually quite analogous to what rpm-ostree does internally;
a lot of the internals there distinguish "base" versus "layered"
commits, and this is very similar.

Here, when we import a non-layered image, we can mostly
ignore the merge commit since all it has is the image manifest.
The base image layer ref *is* the encapsulated ostree commit with
all the metadata injected by (rpm-)ostree in the non-layered case.

Add an API which exposes this as a struct, and also return it
from the importer's `AlreadyPresent` case.
Notably, this also stops exposing the ostree ref for the merge commit,
which I think is a good idea in general since it should be thought
of more as an implementation detail.

In other words, this module speaks container image references
and ostree commits.
If we're not doing a layered image, then use the base commit
for the deployment.

Closes: ostreedev#143
With this new emphasis on "dual commit objects" for the container
deployment, the higher level code queries via container image references
and we don't expose the ostree ref (since there is no longer a single
one).

This makes it critical to write the internal ref matching the
target container image, because it now needs to match the origin.
fn query_image_impl(
repo: &ostree::Repo,
imgref: &OstreeImageReference,
) -> Result<Option<(ImageManifest, LayeredImageState)>> {
Copy link
Member Author

Choose a reason for hiding this comment

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

I thought about exposing the parsed manifest in LayeredImageState too, but it can come later.

@cgwalters
Copy link
Member Author

I've updated coreos/rpm-ostree#3139 to use this, and coreos/coreos-assembler#2523 is also updated and I've tested them all together.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

derivation: Support importing commit metadata, or original commit
2 participants