Repository navigation
Defer layer download until unpack - #3870
Conversation
|
Build succeeded.
|
There was a problem hiding this comment.
Can we stat from top layer to bot layer, and break once a snapshot is found?
That is an optimization, and make it possible to support squashed remote snapshots. :)
There was a problem hiding this comment.
That did cross my mind, you make things so much harder
I'll look at that tomorrow
There was a problem hiding this comment.
@Random-Liu would merging it like this today break any snapshot implementations? As we discussed yesterday, figuring out how to handle the parentage for squashing is kind of tricky. For example we would need to ensure that while referencing a chain id, we aren't enforcing the parent. We currently don't enforce this on the client but the metadata store is.
There was a problem hiding this comment.
@Random-Liu @dmcgowan Even without that optimization, we can support squashed remote snapshots using a digest of a manifest (discussed with CernVM-FS people in containerd/stargz-snapshotter#7 ). We will be able to pass these digests to remote snapshotters by PR #3846 (comment) .
45191f9 to
b46e542
Compare
|
Build succeeded.
|
There was a problem hiding this comment.
Can we pass the image layer's basic information?
- Reference name of the image which the layer belongs to
- Digest(not ChainID, the one written in the OCI manifest) of the layer
CRFS needs them to get the layer URL.
CVMFS also seems to use the digest to get the path on the filesystem.
There was a problem hiding this comment.
I think we can add an option to do it, it doesn't make sense to do by default as this is very particular to one possible backend implementation. Generally speaking this information does not identify the snapshot and for any given snapshot it could end up having multiple values. Either way, out of scope for this PR.
There was a problem hiding this comment.
So for some of these type of implementations, I would favor such a snapshot actually making use of the content store interface for accessing the data. We have already defined a label format there for referencing the source. Likewise referring to a piece of content from a snapshot is an acceptable pattern, although in this case the reference would need to be passed down to the backend.
There was a problem hiding this comment.
@dmcgowan Thank you for your idea!
So we seem to need another patch for storing data X(might be chainID string?) which is label by distribution source information(containerd.io/distribution.source) to the content store.
There's room for consideration about what should X be, but I think the X being chainID string(+some dedicated prefix) is good because snapshotter can easily refer it without any additional labels through Prepare.
b46e542 to
65d875e
Compare
|
Build succeeded.
|
There was a problem hiding this comment.
OMG! You just committed a sin in Go I didn't even know was possible.
There was a problem hiding this comment.
lol, there was a goto in the first version but that just felt too wrong. I am not a huge fan of this pattern, but the refactored version was harder to follow.
|
@dmcgowan Recently I've attempted a hacky integration of this patch with remote snapshotter implementation and it seems to work well!(reproduction steps here) Patches are still needed on client side for kind of pre-preparing remote snapshots. (Currently, for easier implementation, I've taken such approach instead of using the content store for image information propagation) |
Moves the content fetching into the unpack process and defers the download until the snapshot needs it and is ready to apply. As soon as a layer is reached which requires fetching, all remaining layers are fetched. Signed-off-by: Derek McGowan <[email protected]>
65d875e to
30d92ef
Compare
|
Build succeeded.
|
Codecov Report
@@ Coverage Diff @@
## master #3870 +/- ##
=======================================
Coverage 42.34% 42.34%
=======================================
Files 130 130
Lines 14683 14683
=======================================
Hits 6217 6217
Misses 7540 7540
Partials 926 926
Continue to review full report at Codecov.
|
| func uniquePart() string { | ||
| t := time.Now() | ||
| var b [3]byte | ||
| // Ignore read failures, just decreases uniqueness |
There was a problem hiding this comment.
If read fail, can we add t.Second() as well as t.Nanosecond()?
| if states[i].downloaded { | ||
| continue | ||
|
|
||
| labelOpt := snapshots.WithLabels(map[string]string{ |
There was a problem hiding this comment.
Could we merge with UnpackConfig.SnapshotOpts ? I think the label for parent snapshotter is still useful, not just for the snapshotter named by RootFS ID.
There was a problem hiding this comment.
Not limited for this PR. It is proposal and can be handled by following PR. :)
AkihiroSuda
left a comment
There was a problem hiding this comment.
LGTM
nits can be worked out later. Let's move this forward.
ktock
left a comment
There was a problem hiding this comment.
LGTM as mentioned in #3870 (comment) .
Thank you very much for opening this!
Moves the content fetching into the unpack process and defers the download until the snapshot needs it and is ready to apply. As soon as a layer is reached which requires fetching, all remaining layers are fetched.
This should allow supporting the remote snapshotters through the already exists error. This could also support cross namespace snapshot sharing if the snapshotter allows it.
I am working on an update to ctr to use the updated code (since simultaneous unpack), I am going to keep that separate since it is not a trivial change. I needed that to manually test this though, it can also be tested through CRI.