-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix cache export error handling #6261
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
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 |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ import ( | |
| "errors" | ||
| "slices" | ||
|
|
||
| cerrdefs "github.com/containerd/errdefs" | ||
| digest "github.com/opencontainers/go-digest" | ||
| ) | ||
|
|
||
|
|
@@ -189,24 +190,28 @@ func (e *exporter) ExportTo(ctx context.Context, t CacheExporterTarget, opt Cach | |
| if (remote == nil || opt.CompressionOpt != nil) && opt.Mode != CacheExportModeRemoteOnly { | ||
| res, err := cm.results.Load(ctx, res) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| remotes, err := opt.ResolveRemotes(ctx, res) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| res.Release(context.TODO()) | ||
| if remote == nil && len(remotes) > 0 { | ||
| remote, remotes = remotes[0], remotes[1:] // pop the first element | ||
| } | ||
| if opt.CompressionOpt != nil { | ||
| for _, r := range remotes { // record all remaining remotes as well | ||
| results = append(results, CacheExportResult{ | ||
| CreatedAt: v.CreatedAt, | ||
| Result: r, | ||
| EdgeVertex: k.vtx, | ||
| EdgeIndex: k.output, | ||
| }) | ||
| if !errors.Is(err, cerrdefs.ErrNotFound) { | ||
| return nil, err | ||
| } | ||
| remote = nil | ||
| } else { | ||
| remotes, err := opt.ResolveRemotes(ctx, res) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| res.Release(context.TODO()) | ||
| if remote == nil && len(remotes) > 0 { | ||
| remote, remotes = remotes[0], remotes[1:] // pop the first element | ||
| } | ||
| if opt.CompressionOpt != nil { | ||
| for _, r := range remotes { // record all remaining remotes as well | ||
| results = append(results, CacheExportResult{ | ||
| CreatedAt: v.CreatedAt, | ||
| Result: r, | ||
| EdgeVertex: k.vtx, | ||
| EdgeIndex: k.output, | ||
| }) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -232,7 +237,7 @@ func (e *exporter) ExportTo(ctx context.Context, t CacheExporterTarget, opt Cach | |
| for _, dep := range deps { | ||
| rec, err := dep.CacheKey.Exporter.ExportTo(ctx, t, opt) | ||
| if err != nil { | ||
| return nil, err | ||
| continue | ||
|
Comment on lines
239
to
+240
Member
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. Is there something to do with this error? (I see it's fully discarded); something to log, or collect in a multi-error (and have a single log or something)?
Member
Author
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. We could log them as warnings but v0.24 didn't log them as well, so as a regression fix I don't think this change is needed. |
||
| } | ||
| for _, r := range rec { | ||
| srcs[i] = append(srcs[i], CacheLink{Src: r, Selector: string(dep.Selector)}) | ||
|
|
@@ -244,7 +249,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(mainCtx, t, opt) | ||
| if err != nil { | ||
| return nil, nil | ||
| continue | ||
|
Comment on lines
251
to
+252
Member
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. Same for this one |
||
| } | ||
| for _, r := range recs { | ||
| srcs[de.index] = append(srcs[de.index], CacheLink{Src: r, Selector: de.cacheKey.Selector.String()}) | ||
|
|
@@ -261,6 +266,14 @@ func (e *exporter) ExportTo(ctx context.Context, t CacheExporterTarget, opt Cach | |
| } | ||
| } | ||
|
|
||
| // validate deps are present | ||
| for _, deps := range srcs { | ||
| if len(deps) == 0 { | ||
| res[e] = nil | ||
| return res[e], nil | ||
| } | ||
| } | ||
|
|
||
| if v != nil && len(deps) == 0 { | ||
| cm := v.cacheManager | ||
| key := cm.getID(v.key) | ||
|
|
||
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.
Looks like existing code, but there's a context available here; could this / should this be a
context.WithoutCancel(ctx)?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.
Yes, these could be updated. This is old code before
WithoutCancelwas a thing.