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

feat(erofs): initial commit for erofs support #626

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

rchincha
Copy link
Contributor

Fixes opencontainers/image-spec#1190

What type of PR is this?

Which issue does this PR fix:

What does this PR do / Why do we need it:

If an issue # is not available please add repro steps and logs showing the issue:

Testing done on this change:

Automation added to e2e:

Will this break upgrades or downgrades?

Does this PR introduce any user-facing change?:


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@hsiangkao
Copy link

hsiangkao commented Jun 14, 2024

Hi @rchincha, I'm currently working on incremental builds and I plan to release erofs-utils v1.8 this month (with multi-threaded mkfs, incremental builds, Intel QPL, etc.), but anyway, I'd suggest use cgo for initial EROFS support (with formal liberofs APIs exported) for now (or even binary integration as the very first step) since this go implemention seems somewhat incomplete (and maybe even broken.. I don't have enough time to look into that since other prioritied stuffs are on hands..)

@rchincha
Copy link
Contributor Author

@hsiangkao I suspect that cgo path may be what ends up happening. Currently, just prototyping quickly to understand the interfaces and scope of changes/work.

@rchincha rchincha force-pushed the erofs branch 3 times, most recently from c700aaa to 762bfcb Compare August 29, 2024 22:39
@hsiangkao
Copy link

hsiangkao commented Sep 18, 2024

One thing I might need to mention here is that erofs supports external blobs or chunks since Linux 5.16 compared to Squashfs because Dragonfly Nydus once asked this feature to deduplicate data in chunks among different container images.

I'm not sure if it's worthwhile to highlight this, you could just make a tiny metadata with external blobs (which can be used for multiple images) for reference.
Currently only Nydus has userspace tools to generate chunk blobs, if that is interested in other use cases, I could seek more time to implement this in mkfs.erofs too.

@rchincha
Copy link
Contributor Author

$ cat stacker.yaml

build:
  from:
    type: docker
    url: docker://public.ecr.aws/docker/library/busybox:1.37-glibc
 $ /tmp/stacker  build -layer-type erofs
Creating new OCI Layout at "/data/hdd/rchincha/tmp/lxc/oci"
preparing image build...
imported file hashes (after substitutions):
loading docker://public.ecr.aws/docker/library/busybox:1.37-glibc
Copying blob a46fbb00284b done
Copying config 27a71e19c9 done
Writing manifest to image destination
Storing signatures
mkfs.erofs 1.4                                                                                                                                                                    c_version:           [     1.4]
        c_dbg_lvl:           [       2]
        c_dry_run:           [       0]
filesystem build built successfully

@rchincha
Copy link
Contributor Author

@hsiangkao an update. Now have a stacker (this PR) that can build OCI images with erofs+dm-verity layers - no change to the overall workflow.

@rchincha rchincha force-pushed the erofs branch 2 times, most recently from 31b8397 to ea8d893 Compare November 18, 2024 21:29
Copy link

codecov bot commented Nov 18, 2024

Codecov Report

Attention: Patch coverage is 8.10811% with 34 lines in your changes missing coverage. Please review.

Project coverage is 6.65%. Comparing base (ad9a694) to head (ba91142).

Files with missing lines Patch % Lines
pkg/types/layer_type.go 0.00% 20 Missing ⚠️
pkg/overlay/pack.go 0.00% 6 Missing ⚠️
cmd/stacker/internal_go.go 0.00% 4 Missing ⚠️
cmd/stacker/validate.go 0.00% 2 Missing ⚠️
cmd/stacker/build.go 75.00% 1 Missing ⚠️
cmd/stacker/publish.go 0.00% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (ad9a694) and HEAD (ba91142). Click for more details.

HEAD has 43 uploads less than BASE
Flag BASE (ad9a694) HEAD (ba91142)
44 1
Additional details and impacted files
@@            Coverage Diff            @@
##             main    #626      +/-   ##
=========================================
- Coverage   13.08%   6.65%   -6.43%     
=========================================
  Files          35      57      +22     
  Lines        5084    6457    +1373     
=========================================
- Hits          665     430     -235     
- Misses       4309    5964    +1655     
+ Partials      110      63      -47     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

atomfs has added support for additional filesystem types such as erofs.

Signed-off-by: Ramkumar Chinchani <[email protected]>
@rchincha rchincha force-pushed the erofs branch 4 times, most recently from 460e2de to 77e6c38 Compare November 20, 2024 07:57
@rchincha
Copy link
Contributor Author

@hsiangkao

Is there an equivalent of "unsquashfs" in erofs-utils?

https://manpages.debian.org/testing/squashfs-tools/unsquashfs.1.en.html

SYNOPSIS

unsquashfs [OPTIONS] FILESYSTEM [files to extract or exclude (with -excludes) or cat (with -cat )]

@hsiangkao
Copy link

hsiangkao commented Nov 22, 2024

Hi!

@hsiangkao

Is there an equivalent of "unsquashfs" in erofs-utils?

https://manpages.debian.org/testing/squashfs-tools/unsquashfs.1.en.html

SYNOPSIS

unsquashfs [OPTIONS] FILESYSTEM [files to extract or exclude (with -excludes) or cat (with -cat )]

fsck.erofs --extract=<dir> FILESYSTEM to extract the whole filesystem...

Currently, there is no exclude way but it can be added later.

Signed-off-by: Ramkumar Chinchani <[email protected]>
@@ -43,6 +43,7 @@ installdeps_ubuntu() {
squashfs-tools
squashfuse
libarchive-tools
erofs-utils erofsfuse
Copy link
Contributor

Choose a reason for hiding this comment

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

one per line

fallthrough
case squashfs.GenerateSquashfsMediaType(squashfs.ZstdCompression):
return NewLayerType("squashfs", verity.VerityMetadataMissing)
case squashfs.GenerateSquashfsMediaType(squashfs.GzipCompression):
Copy link
Contributor

Choose a reason for hiding this comment

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

We already had a case for Squash + Gzip -- was this supposed to be zstd?

Comment on lines +87 to +89
case erofs.GenerateErofsMediaType(erofs.LZ4HCCompression):
return NewLayerType("erofs", verity.VerityMetadataMissing)
case erofs.GenerateErofsMediaType(erofs.LZ4HCCompression):
Copy link
Contributor

Choose a reason for hiding this comment

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

These are the same case right? LZ4H , fallthrough?

Comment on lines +57 to +59
manifest=$(cat oci/index.json | jq -r .manifests[0].digest | cut -f2 -d:)
last_layer_num=$(($(cat oci/blobs/sha256/$manifest | jq -r '.layers | length')-1))
last_layer_hash=$(cat oci/blobs/sha256/$manifest | jq -r .layers[$last_layer].digest | cut -f2 -d:)
Copy link
Contributor

Choose a reason for hiding this comment

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

just a general comment, prolly worth an issue, but we can avoid the cat | jq and just jq xxx < file

return
fi
if [ -z "$SUDO_UID" ]; then
echo "PRIVILEGE_LEVEL=$PRIVILEGE_LEVEL but empty SUDO_USER"
Copy link
Contributor

Choose a reason for hiding this comment

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

SUDO_USER or SUDO_UID ? both are present, but your error prints a different ENV value than what is checked.

Suggested change
echo "PRIVILEGE_LEVEL=$PRIVILEGE_LEVEL but empty SUDO_USER"
echo "PRIVILEGE_LEVEL=$PRIVILEGE_LEVEL but empty SUDO_UID"

if [ "$PRIVILEGE_LEVEL" = "priv" ]; then
return
fi
if [ -z "$SUDO_UID" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if [ -z "$SUDO_UID" ]; then
if [ -z "$SUDO_USER" ]; then

which one? SUDO_UID or SUDO_USER?

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.

performance: what can image-spec do to improve handling of large images?
4 participants