Skip to content

Enable snapshotter to make snapshots without pulling the contents - #3846

Closed
ktock wants to merge 4 commits into
containerd:masterfrom
ktock:filter-by-snapshotter
Closed

ktock wants to merge 4 commits into
containerd:masterfrom
ktock:filter-by-snapshotter

Conversation

@ktock

@ktock ktock commented Nov 24, 2019

Copy link
Copy Markdown
Member

This commit allows snapshotter to prepare snapshots as well as to prevent the
client from downloading the layer's contents. This hopefully enables to reduce
time for pulling the image. The client passes basic information of the image
layer(ref, digest) to the snapshotter as labels and the snapsohtter can use or
simply ignore it.

This commit also includes changes on ctr command to make using this
functionality easier.

This commit depends on PR #3793 because the implementation uses the target snapshot reference functionality. So this is a little bit early, but I raised this PR also for discussion based on the concrete implementation.

This functionality enables remote snapshots(discussed on the issue #3731) and you can test it with current remote snapshotter implementation on:

The step of the demo:

@theopenlab-ci

theopenlab-ci Bot commented Nov 24, 2019

Copy link
Copy Markdown

Build succeeded.

This commit allows snapshotter to prepare snapshots as well as to prevent the
client from downloading the layer's contents. This hopefully enables to reduce
time for pulling the image. The client passes basic information of the image
layer(ref, digest) to the snapshotter as labels and the snapsohtter can use or
simply ignore it.

This commit also includes changes on ctr command to make using this
functionality easier.

Signed-off-by: Kohei Tokunaga <[email protected]>
@ktock
ktock force-pushed the filter-by-snapshotter branch from 0c521f8 to 27deca8 Compare November 24, 2019 10:26
@theopenlab-ci

theopenlab-ci Bot commented Nov 24, 2019

Copy link
Copy Markdown

Build succeeded.

@codecov-io

codecov-io commented Nov 24, 2019 •

Copy link
Copy Markdown

Codecov Report

Merging #3846 into master will increase coverage by 0.1%.
The diff coverage is 60.46%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #3846     +/-   ##
=========================================
+ Coverage   42.27%   42.37%   +0.1%     
=========================================
  Files         130      131      +1     
  Lines       14577    14663     +86     
=========================================
+ Hits         6162     6214     +52     
- Misses       7501     7533     +32     
- Partials      914      916      +2
Flag Coverage Δ
#linux 45.81% <61.53%> (+0.08%) ⬆️
#windows 37.44% <60.46%> (+0.16%) ⬆️
Impacted Files Coverage Δ
snapshots/handler/handler.go 60.46% <60.46%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 383f4a7...df0171f. Read the comment docs.

@ktock

ktock commented Nov 24, 2019

Copy link
Copy Markdown
Member Author

@dmcgowan Thank you very much for the discussion on the mini-summit@kubecon! This PR is related to the discussion and your #3793, could you look at this?

Comment thread snapshots/handler/handler.go Resolved
Comment thread snapshots/handler/handler_test.go Resolved
Signed-off-by: Kohei Tokunaga <[email protected]>
Comment thread snapshots/handler/handler.go Resolved
@theopenlab-ci

theopenlab-ci Bot commented Nov 25, 2019

Copy link
Copy Markdown

Build succeeded.

Signed-off-by: Kohei Tokunaga <[email protected]>
@theopenlab-ci

theopenlab-ci Bot commented Nov 25, 2019

Copy link
Copy Markdown

Build succeeded.

@ktock
ktock requested a review from AkihiroSuda November 25, 2019 09:00
Comment thread snapshots/handler/handler.go Resolved
}
}

func isPullSkippable(ctx context.Context, sn snapshots.Snapshotter, ref string) func(ocispec.Descriptor, []digest.Digest) bool {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Out of scope thinking: containerd provides runtime function and there were two copies of image data: content and snapshotter. For running containers without building function, content data seems duplicate. We can remove the content data after unpack and the isPullSkippable can avoid next round pulling. For example, image A is based on image B. We download image B first and remove the layers from image B. And then when we pulling image A, we can only pull extra layers from A.

Based on your commits, no matter what kind of snapshot is, remote or local snapshoter, if backend snapshotter follow the #3793 design, we can remove duplicate content data.

Comment thread snapshots/handler/handler.go Resolved
Signed-off-by: Kohei Tokunaga <[email protected]>
@theopenlab-ci

theopenlab-ci Bot commented Nov 26, 2019

Copy link
Copy Markdown

Build succeeded.

@fuweid fuweid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

should be merged after #3793

@AkihiroSuda

Copy link
Copy Markdown
Member

#3793 is merged

@AkihiroSuda
AkihiroSuda requested a review from dmcgowan November 26, 2019 04:57
@siscia

siscia commented Nov 26, 2019

Copy link
Copy Markdown

This should completely address #3731 right?

@ktock

ktock commented Nov 26, 2019

Copy link
Copy Markdown
Member Author

@siscia Yes, this PR is for #3731 and current remote snapshotter implementation is https://github.com/ktock/remote-snapshotter .
But this PR implementation is a little bit more general because we can leverage this functionality also for other kinds of optimization e.g. discussed in #3846 (comment)

@siscia

siscia commented Nov 26, 2019

Copy link
Copy Markdown

Many thanks!

I want to take another round of implementation to make this remote snapshotter work on CVMFS, it won't be immediate because I see a lot of changes from my last attempt but it seems like all the pieces are in place. Hopefully I will report a success! :)

@dmcgowan

Copy link
Copy Markdown
Member

@ktock thanks for opening this!

I am currently working on an unpacker refactor which may allow this to be even easier. I will update more next week.

@siscia

siscia commented Nov 27, 2019 •

Copy link
Copy Markdown

Will the interfacce stay the same or it will be a completely new interface?

In other words, does it make sense that I work toward a cvmfs snapshotter or it will be a wasted effort?

@dmcgowan

Copy link
Copy Markdown
Member

@siscia just refactoring some of the client side unpack code, the snapshotter interface will not be changing. Let me know if you have any issues with implementing the latest snapshotter updates related to managing the ref label.

@siscia

siscia commented Nov 28, 2019

Copy link
Copy Markdown

Based on the code from @ktock I wrote a small PR that should enable to work also on /cvmfs

containerd/stargz-snapshotter#4

It is still a work in progress with hardcoded path, but it should be the way forward IMHO.

It still doesn't work as I expected, giving error: "Too many levels of symbolic links" which is a quite standard error when playing with this things...

@siscia

siscia commented Nov 29, 2019

Copy link
Copy Markdown

Let me report that the remote-snapshotter seems to work also for our use case.
The error I reported above was due to autofs and it was easily fixed using the :shared flag in the volume that bindmount cvmfs inside the container. And this should be necessary only because I was using docker-compose.

The PR I provided is not yet in shape to be merged, but honestly we would need a little bit of discussion on our side to understand what is best. Anyhow the PR is trivial and does not even need to be inside the repository in my understanding.

@ktock

ktock commented Dec 1, 2019

Copy link
Copy Markdown
Member Author

Big thanks for your testing remote snapshotter and the API!

@ktock

ktock commented Dec 9, 2019 •

Copy link
Copy Markdown
Member Author

I'm thinking to fix this patch leveraging #3870 as mentioned here. The most part will remain unchanged but be a bit simpler. The (rough) patch PoC is here and you can test it on this remote snapshotter branch.

@dmcgowan

dmcgowan commented Dec 9, 2019

Copy link
Copy Markdown
Member

@ktock is the main thing that is missing from the other PR the ability to set the extra labels on prepare? I was wondering if we can define a way to propagate some annotations as labels, that would allow intercepting handlers to inject information using the normal handler approach

@ktock

ktock commented Dec 10, 2019

Copy link
Copy Markdown
Member Author

@dmcgowan Yes. Do you have any idea about the definition of some annotations? I first thought about using containerd's local content store as a propagation media(using content labels which are currently disabled by default). Is it an acceptable design? If so, I'm willing to post another PR. Or, do you have other ideas?

@ktock

ktock commented Dec 10, 2019 •

Copy link
Copy Markdown
Member Author

Or, if we allow users to provide a handler which will be wrapped by unpackWrapper, we can add extra ocispec.Descriptor.Annotations in the handler, which can be easily passed to the backend snapshotter.
(so unpackWrapper(USER_WRAPPER(h)) not USER_WRAPPER(unpackWrapper(h)) in the code snippet below)

containerd/pull.go

Lines 80 to 85 in 30d92ef

pullCtx.HandlerWrapper = func(h images.Handler) images.Handler {
if wrapper == nil {
return unpackWrapper(h)
}
return wrapper(unpackWrapper(h))
}

@ktock

ktock commented Dec 10, 2019

Copy link
Copy Markdown
Member Author

@dmcgowan Based on the discussion above I rewrote the PoC of the patch. Then this became very simpler! This is great! You can test it on this remote snapshotter branch. If it's an acceptable design, I'll update this PR.

@ktock

ktock commented Dec 23, 2019

Copy link
Copy Markdown
Member Author

I posted new PR #3911 leveraging #3870. Could you review it?

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.

6 participants