Skip to content

Commit 3b0bb5a

Browse files
tonistiigicrazy-max
authored andcommitted
remotecache: skip result on not-found error
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
1 parent 36daaa5 commit 3b0bb5a

File tree

4 files changed

+31
-23
lines changed

4 files changed

+31
-23
lines changed

cache/remotecache/azblob/importer.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container"
1212
"github.com/containerd/containerd/v2/core/content"
1313
"github.com/containerd/containerd/v2/pkg/labels"
14+
cerrdefs "github.com/containerd/errdefs"
1415
"github.com/moby/buildkit/cache/remotecache"
1516
v1 "github.com/moby/buildkit/cache/remotecache/v1"
1617
"github.com/moby/buildkit/session"
@@ -214,7 +215,7 @@ type ciProvider struct {
214215

215216
func (p *ciProvider) Info(ctx context.Context, dgst digest.Digest) (content.Info, error) {
216217
if dgst != p.desc.Digest {
217-
return content.Info{}, errors.Errorf("content not found %s", dgst)
218+
return content.Info{}, errors.Wrapf(cerrdefs.ErrNotFound, "blob %s", dgst)
218219
}
219220

220221
if p.checked {
@@ -234,7 +235,7 @@ func (p *ciProvider) Info(ctx context.Context, dgst digest.Digest) (content.Info
234235
}
235236

236237
if !exists {
237-
return content.Info{}, errors.Errorf("blob %s not found", dgst)
238+
return content.Info{}, errors.Wrapf(cerrdefs.ErrNotFound, "blob %s", dgst)
238239
}
239240

240241
p.checked = true

cache/remotecache/gha/gha.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414

1515
"github.com/containerd/containerd/v2/core/content"
1616
"github.com/containerd/containerd/v2/pkg/labels"
17+
cerrdefs "github.com/containerd/errdefs"
1718
"github.com/moby/buildkit/cache/remotecache"
1819
v1 "github.com/moby/buildkit/cache/remotecache/v1"
1920
"github.com/moby/buildkit/session"
@@ -440,7 +441,7 @@ type ciProvider struct {
440441

441442
func (p *ciProvider) Info(ctx context.Context, dgst digest.Digest) (content.Info, error) {
442443
if dgst != p.desc.Digest {
443-
return content.Info{}, errors.Errorf("content not found %s", dgst)
444+
return content.Info{}, errors.Wrapf(cerrdefs.ErrNotFound, "blob %s", dgst)
444445
}
445446

446447
if _, err := p.loadEntry(ctx, p.desc); err != nil {
@@ -465,7 +466,7 @@ func (p *ciProvider) loadEntry(ctx context.Context, desc ocispecs.Descriptor) (*
465466
return nil, err
466467
}
467468
if ce == nil {
468-
return nil, errors.Errorf("blob %s not found", desc.Digest)
469+
return nil, errors.Wrapf(cerrdefs.ErrNotFound, "blob %s", desc.Digest)
469470
}
470471
if p.entries == nil {
471472
p.entries = make(map[digest.Digest]*actionscache.Entry)

cache/remotecache/v1/chains.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
"github.com/cespare/xxhash/v2"
1212
"github.com/containerd/containerd/v2/core/content"
13+
cerrdefs "github.com/containerd/errdefs"
1314
"github.com/moby/buildkit/session"
1415
"github.com/moby/buildkit/solver"
1516
digest "github.com/opencontainers/go-digest"
@@ -246,7 +247,7 @@ func (p DescriptorProviderPair) Info(ctx context.Context, dgst digest.Digest) (c
246247
return p.InfoProvider.Info(ctx, dgst)
247248
}
248249
if dgst != p.Descriptor.Digest {
249-
return content.Info{}, errors.Errorf("content not found %s", dgst)
250+
return content.Info{}, errors.Wrapf(cerrdefs.ErrNotFound, "blob %s", dgst)
250251
}
251252
return content.Info{
252253
Digest: p.Descriptor.Digest,

solver/exporter.go

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"errors"
66
"slices"
77

8+
cerrdefs "github.com/containerd/errdefs"
89
digest "github.com/opencontainers/go-digest"
910
)
1011

@@ -189,24 +190,28 @@ func (e *exporter) ExportTo(ctx context.Context, t CacheExporterTarget, opt Cach
189190
if (remote == nil || opt.CompressionOpt != nil) && opt.Mode != CacheExportModeRemoteOnly {
190191
res, err := cm.results.Load(ctx, res)
191192
if err != nil {
192-
return nil, err
193-
}
194-
remotes, err := opt.ResolveRemotes(ctx, res)
195-
if err != nil {
196-
return nil, err
197-
}
198-
res.Release(context.TODO())
199-
if remote == nil && len(remotes) > 0 {
200-
remote, remotes = remotes[0], remotes[1:] // pop the first element
201-
}
202-
if opt.CompressionOpt != nil {
203-
for _, r := range remotes { // record all remaining remotes as well
204-
results = append(results, CacheExportResult{
205-
CreatedAt: v.CreatedAt,
206-
Result: r,
207-
EdgeVertex: k.vtx,
208-
EdgeIndex: k.output,
209-
})
193+
if !errors.Is(err, cerrdefs.ErrNotFound) {
194+
return nil, err
195+
}
196+
remote = nil
197+
} else {
198+
remotes, err := opt.ResolveRemotes(ctx, res)
199+
if err != nil {
200+
return nil, err
201+
}
202+
res.Release(context.TODO())
203+
if remote == nil && len(remotes) > 0 {
204+
remote, remotes = remotes[0], remotes[1:] // pop the first element
205+
}
206+
if opt.CompressionOpt != nil {
207+
for _, r := range remotes { // record all remaining remotes as well
208+
results = append(results, CacheExportResult{
209+
CreatedAt: v.CreatedAt,
210+
Result: r,
211+
EdgeVertex: k.vtx,
212+
EdgeIndex: k.output,
213+
})
214+
}
210215
}
211216
}
212217
}

0 commit comments

Comments
 (0)