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

cache: Fix walkBlob to call callback only for unlazied contents #5595

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

ktock
Copy link
Collaborator

@ktock ktock commented Dec 13, 2024

Testing c00304f as a following-up patch for #5560 (comment) This PR contains patches from #5560 so this should be rebased after that PR is merged. Or, this should be cherry-picked to that PR. Note that this PR doesn't contain the commit 07cf45e in that PR to check if the patch in this PR fixes the issue.

walkBlob walks compression variants in the content store with calling a callback for the found content. The current implementation doesn't check the existence of the specified content and this resulted in a test failure described in #5560 (comment) . This commit fixes this issue.

sipsma and others added 7 commits December 5, 2024 16:00
There were two lines that checked if err != nil and return nil error.
This seems likely to be a typo, especially since there is support for
ignoring errors during cache export but on a completely different level
of abstraction (in llbsolver).

There were bugs causing errors during cache export (fixed in subsequent
commits) which ended up getting silently dropped and causing cache
exports to be missing mysteriously. Now errors are returned and only
ignored if cache export errors are configured to be ignored.

Signed-off-by: Erik Sipsma <[email protected]>
Before this change, lazy blobs were handled during cache export by
providing descHandlers from the ref being exported in llbsolver.

However, this didn't handle some max cache export cases that involve use
of read-write mounts. Specifically, if you exported cache for a ref from
a read-write mount in an ExecOp, the ref's descHandlers didn't include
handlers for any refs from the the rootfs of the ExecOp.

If any of those refs for the rootfs involved lazy blobs, any error would
get hit during cache export about lazy blobs. It's possible for the
rootfs to have lazy blobs in a few different ways, but the one tested in
the integ test added here involves two images with layers that get
deduped by chainID (i.e. uncompress to the same layer but have different
compressions). Image layer refs that find an existing ref w/ same
chainID will get a snapshot for free but stay lazy in terms of their
blobs, thus making it possible for an exec to run on top of them while
still considered lazy.

The fix here puts the CacheOptGetter logic in the cache export code
directly so that it can use the solver's information on dependencies to
find all possible descHandlers, including those for the rootfs in the
read-write mount case.

Signed-off-by: Erik Sipsma <[email protected]>
Before this change, if a cache mount had base layers from a ref and
those layers were lazy, you could hit missing blob errors when trying to
reload an existing mutable ref for the cache mount.

It's possible to have lazy refs in the base layers when blobs get
deduped by chainID.

The fix is just to handle the lazy blob error and reload with
descHandlers set.

Signed-off-by: Erik Sipsma <[email protected]>
For lazy remote cache cases, we figure out the descriptor handlers to
use during loading of cache rather than during a CacheMap operation.

In order to make those descHandlers available as CacheOpts we need to
plumb them through to the shared op and allow withAncestorCacheOpts to
check those in addition to the CacheOpts from CacheMaps.

This allows loading of lazy refs during cache export when there are refs
resolved with cache imports.

Signed-off-by: Erik Sipsma <[email protected]>
@ktock ktock changed the title cache: Fix walkBlbo to call callback only for unlazied contents cache: Fix walkBlob to call callback only for unlazied contents Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants