Skip to content

erofs-differ: support EROFS native image layers #11733

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

Merged
merged 1 commit into from
Apr 24, 2025

Conversation

hsiangkao
Copy link
Member

@hsiangkao hsiangkao commented Apr 22, 2025

@hsiangkao
Copy link
Member Author

hsiangkao commented Apr 22, 2025

@k8s-ci-robot
Copy link

@hsiangkao: GitHub didn't allow me to request PR reviews from the following users: rchincha.

Note that only containerd members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/cc @dmcgowan @fuweid @AkihiroSuda @djdongjin @rchincha

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@hsiangkao
Copy link
Member Author

Note that it still needs some decision. Therefore, I don't touch core/images/mediatypes.go for now since I'm not sure what the proper media type is.

@mxpv
Copy link
Member

mxpv commented Apr 22, 2025

@hsiangkao can you pls rebase the PR against main to pick CI fixes?

@dmcgowan
Copy link
Member

I think we can skip the configuration for this as using a new media type would already be optional and previously unhandled. Whatever ever format we support here we would need to support "forever", but I think that is reasonable here

@dmcgowan dmcgowan added this to the 2.1 milestone Apr 22, 2025
@dmcgowan dmcgowan moved this from Needs Triage to Needs Update in Pull Request Review Apr 22, 2025
@rchincha
Copy link

@dmcgowan
Copy link
Member

@rchincha this aligns with what is proposed there. Although I would also agree that OCI should not define a new media type here since there is nothing OCI specific about the format. With the tar layers, there are entries with special meaning that warranted a more specific media type.

We need to update image.IsLayerType to look for more than just a application/vnd.oci.image.layer. prefix. I think we could start by making this more configurable in the unpacker. Otherwise the vnd.erofs (or whatever) won't work in containerd with this change, only application/vnd.oci.image.layer.erofs would.

@rchincha
Copy link

I think we could start by making this more configurable in the unpacker.

This would be ideal for future extensibility. You would still need the unpacker for a given/configured media-type.
erofs is one. I am also recommending squashfs mainly because of support on other platforms. There is no IANA media-type for it though - yes, it is that old.

opencontainers/image-spec#1191 (comment)

Can adjust stacker to produce layers with the updated media-type (@hsiangkao had a comment about it as well)

@hsiangkao
Copy link
Member Author

hsiangkao commented Apr 22, 2025

@rchincha this aligns with what is proposed there. Although I would also agree that OCI should not define a new media type here since there is nothing OCI specific about the format. With the tar layers, there are entries with special meaning that warranted a more specific media type.

We need to update image.IsLayerType to look for more than just a application/vnd.oci.image.layer. prefix. I think we could start by making this more configurable in the unpacker. Otherwise the vnd.erofs (or whatever) won't work in containerd with this change, only application/vnd.oci.image.layer.erofs would.

@dmcgowan I wonder if vnd.erofs is too generic as a container image layer (rather than a random artifact with erofs content), so I think maybe erofs differ will accept two forms of media types:
application/xxxxx.image.layer.erofs (for stacker or later potential OCI extension)
or
application/vnd.erofs.image.layer (as the IANA "vnd.erofs" subtype)

and adjust image.IsLayerType to find if .image.layer exists (rather than just prefixed with "application/vnd.oci.image.layer").

Does that seem more reasonable? Cc @rchincha

@hsiangkao
Copy link
Member Author

hsiangkao commented Apr 22, 2025

if we check if .image.layer infixes exist instead, we don't need customized configuration (maybe inflexiable) either.

@hsiangkao
Copy link
Member Author

hsiangkao commented Apr 22, 2025

@hsiangkao can you pls rebase the PR against main to pick CI fixes?

ok, rebased.

@hsiangkao
Copy link
Member Author

I think we can skip the configuration for this as using a new media type would already be optional and previously unhandled. Whatever ever format we support here we would need to support "forever", but I think that is reasonable here

Yeah, I'm fine with that and dropped.

@dmcgowan
Copy link
Member

Note that it still needs some decision. Therefore, I don't touch core/images/mediatypes.go for now since I'm not sure what the proper media type is.

I think its best to avoid touching this file. It is easy to backport support for media types but it is hard to deprecate them once they are in. I would avoid listing out the whole media types and maybe stick with just checking for .erofs. I think you can keep the previous media type checking and the config removal looks good.

We will need to continue to address new media types, I don't want that discussion to hold this up so we can continue experimenting.

@dmcgowan
Copy link
Member

Also opened #11744 to unblock experimentation for new functionality

@hsiangkao hsiangkao force-pushed the erofs-layers branch 2 times, most recently from 3eab2ca to 1eef0f8 Compare April 23, 2025 13:05
@@ -245,6 +268,20 @@ func (s erofsDiff) Apply(ctx context.Context, desc ocispec.Descriptor, mounts []
}
defer ra.Close()

layerBlobPath := path.Join(layer, "layer.erofs")
if native {
// TODO: prefer to use hardlink as an optimization here
Copy link
Member

Choose a reason for hiding this comment

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

io.Copy in this case will usually do a copy_file_range which is better in this when reflinking is supported. We can also optimize this for the mac case to clone. I think we can remove this comment

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, but it's only applied to fses which supports reflink... ext4 is a primary fs which is hard to support reflink anyway.

Copy link
Member Author

@hsiangkao hsiangkao Apr 23, 2025

Choose a reason for hiding this comment

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

The comment is removed.

if err != nil {
return emptyDesc, err
}
_, err = io.Copy(f, content.NewReader(ra))
Copy link
Member

Choose a reason for hiding this comment

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

f should be closed unconditionally after this call

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed.

@rchincha
Copy link

@dmcgowan I wonder if vnd.erofs is too generic as a container image layer (rather than a random artifact with erofs content), so I think maybe erofs differ will accept two forms of media types: application/xxxxx.image.layer.erofs (for stacker or later potential OCI extension) or application/vnd.erofs.image.layer (as the IANA "vnd.erofs" subtype)

and adjust image.IsLayerType to find if .image.layer exists (rather than just prefixed with "application/vnd.oci.image.layer").

Does that seem more reasonable? Cc @rchincha

Naming quagmire ... has to be situated under some vendor tree, but which one!
Also, why I was proposing it under vnd.oci.
Important but we can revisit or discuss separately.

Would prioritize getting containerd to launch containers with these images/layers first.

If the layer media type is expected as an EROFS native layer (ending
with `.erofs`), copy the content as the layer blob.

Signed-off-by: Gao Xiang <[email protected]>
@github-project-automation github-project-automation bot moved this from Needs Update to Review In Progress in Pull Request Review Apr 23, 2025
@mxpv mxpv added this pull request to the merge queue Apr 23, 2025
Merged via the queue into containerd:main with commit d983c18 Apr 24, 2025
58 checks passed
@github-project-automation github-project-automation bot moved this from Review In Progress to Done in Pull Request Review Apr 24, 2025
@hsiangkao hsiangkao deleted the erofs-layers branch April 27, 2025 05:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants