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

support nydus image topmost layer view #447

Merged
merged 2 commits into from
Apr 18, 2023

Conversation

changweige
Copy link
Member

@changweige changweige commented Apr 12, 2023

Without inline layer fs meta blob, we can still support the topmost View for nydus image. It is useful for Buildkit to use nydus image as the base image.

Next PR will implement View on any layer of the nydus image.

➜  ~ ctr snapshot view --mounts cccddd sha256:62b1c52c224c7907ca34194f2c7e819b8057251b6d69623ff3bf8a7c9393894a
[
    {
        "Type": "overlay",
        "Source": "overlay",
        "Target": "",
        "Options": [
            "lowerdir=/var/lib/containerd-nydus/snapshots/510/mnt:/var/lib/containerd-nydus/snapshots/536/fs"
        ]
    }
]

@sctb512
Copy link
Member

sctb512 commented Apr 13, 2023

Fantastic! This PR is useful for mounting a nydus image into a directory with ctr i mount.
I also recommend improving the Prepare API. Because the command with --rw (ctr i mount --rw IMAGE TARGET ) does not work now.
The ctr source code about it:

if context.Bool("rw") {
	mounts, err = s.Prepare(ctx, target, chainID)
} else {
	mounts, err = s.View(ctx, target, chainID)
}

Here is a comparison with stargz:

mkdir mkdir test.bootstrap.stargz
nerdctl --snapshotter stargz pull ghcr.io/stargz-containers/alpine:3.15.3-esgz
ctr --debug i mount --rw --snapshotter stargz ghcr.io/stargz-containers/alpine:3.15.3-esgz test.bootstrap.stargz
ls test.bootstrap.stargz

Output:

bin dev etc home lib media mnt opt proc root run sbin srv sys tmp usr var

Unfortunately this does not work for nydus:

mkdir test.bootstrap.nydus
nerdctl --snapshotter nydus pull sctb512/golang:nydusv6
ctr --debug i mount --rw --snapshotter nydus docker.io/sctb512/golang:nydusv6 test.bootstrap.nydus
ls test.bootstrap.nydus

Output: None

if isNydusMetaLayer(pInfo.Labels) {
// Nydusd might not be running. We should run nydusd to reflect the rootfs.
err = o.fs.WaitUntilReady(pID)
if err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

if err := o.fs.WaitUntilReady(pID); err != nil {

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

@changweige
Copy link
Member Author

o.fs.WaitUntilReady(pID)

Prepare is now implemented

@codecov-commenter
Copy link

codecov-commenter commented Apr 17, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (ab8c6fe) 37.15% compared to head (1db810a) 37.15%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #447   +/-   ##
=======================================
  Coverage   37.15%   37.15%           
=======================================
  Files          60       60           
  Lines        6909     6909           
=======================================
  Hits         2567     2567           
  Misses       4045     4045           
  Partials      297      297           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Without inline layer fs meta blob, we can still support the
topmost View for nydus image. It is useful for Buildkit to use
nydus image as the base image.

Signed-off-by: Changwei Ge <gechangwei@bytedance.com>
clients like ctr is using Prepare to generate a
active snapshot when mounting an image to host.
But containerd is only only writing contents to
the active snapshot.

Signed-off-by: Changwei Ge <gechangwei@bytedance.com>
@imeoer imeoer merged commit d4ccae0 into containerd:main Apr 18, 2023
@changweige changweige deleted the view-support-2 branch April 24, 2023 02:43
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.

None yet

4 participants