-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fix various lazy blob errors involving dedupe by chainID #5560
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,6 +117,13 @@ func (e *exporter) ExportTo(ctx context.Context, t CacheExporterTarget, opt Cach | |
return nil, err | ||
} | ||
|
||
if e.edge != nil { | ||
op, ok := e.edge.op.(*sharedOp) | ||
if ok && op != nil && op.st != nil { | ||
ctx = withAncestorCacheOpts(ctx, op.st) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to cache this per |
||
} | ||
} | ||
|
||
remotes, err := cm.results.LoadRemotes(ctx, res, opt.CompressionOpt, opt.Session) | ||
if err != nil { | ||
return nil, err | ||
|
@@ -172,7 +179,7 @@ func (e *exporter) ExportTo(ctx context.Context, t CacheExporterTarget, opt Cach | |
for _, dep := range deps { | ||
recs, err := dep.CacheKey.Exporter.ExportTo(ctx, t, opt) | ||
if err != nil { | ||
return nil, nil | ||
return nil, err | ||
} | ||
for _, r := range recs { | ||
srcs[i] = append(srcs[i], expr{r: r, selector: dep.Selector}) | ||
|
@@ -184,7 +191,7 @@ func (e *exporter) ExportTo(ctx context.Context, t CacheExporterTarget, opt Cach | |
for _, de := range e.edge.secondaryExporters { | ||
recs, err := de.cacheKey.CacheKey.Exporter.ExportTo(ctx, t, opt) | ||
if err != nil { | ||
return nil, nil | ||
return nil, err | ||
} | ||
for _, r := range recs { | ||
srcs[de.index] = append(srcs[de.index], expr{r: r, selector: de.cacheKey.Selector}) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ import ( | |
"github.com/moby/buildkit/util/grpcerrors" | ||
"github.com/moby/locker" | ||
"github.com/moby/sys/userns" | ||
digest "github.com/opencontainers/go-digest" | ||
"github.com/pkg/errors" | ||
"google.golang.org/grpc/codes" | ||
) | ||
|
@@ -123,7 +124,18 @@ func (g *cacheRefGetter) getRefCacheDirNoCache(ctx context.Context, key string, | |
} | ||
locked := false | ||
for _, si := range sis { | ||
if mRef, err := g.cm.GetMutable(ctx, si.ID()); err == nil { | ||
mRef, err := g.cm.GetMutable(ctx, si.ID()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Confused how this case is possible. Shouldn't making a mutable ref on top of lazy ref already unlazy it? What is the point of mutable ref it it is lazy? Afaics you can't "mutate" it if it is lazy. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See the relevant integ test case added here (it fails before the commits here). You can end up with cache refs that have lazy blobs but a valid working snapshot if they are deduped by chainID from another non-lazy ref. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I'm still confused. So lets say we have Are you saying I can call:
And all that would work fine. But after that I can't call.
and would get an error unless I put something special in the context? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I guess I kind of understand that logic. The That Still feels that something wrong in API design in here, but no specific ideas how to improve. |
||
var needsRemoteProviders cache.NeedsRemoteProviderError | ||
if errors.As(err, &needsRemoteProviders) && ref != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As calling |
||
descHandlers := cache.DescHandlers(make(map[digest.Digest]*cache.DescHandler)) | ||
for _, dgst := range needsRemoteProviders { | ||
if handler := ref.DescHandler(dgst); handler != nil { | ||
descHandlers[dgst] = handler | ||
} | ||
} | ||
mRef, err = g.cm.GetMutable(ctx, si.ID(), descHandlers) | ||
} | ||
if err == nil { | ||
bklog.G(ctx).Debugf("reusing ref for cache dir %q: %s", id, mRef.ID()) | ||
return mRef, nil | ||
} else if errors.Is(err, cache.ErrLocked) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking the source it seems
activeOp
interface is redundant and could be removed, removing the need for this cast.