diff --git a/cache/remotecache/inline.go b/cache/remotecache/inline.go index 4c1633ecc..fafeafa74 100644 --- a/cache/remotecache/inline.go +++ b/cache/remotecache/inline.go @@ -149,14 +149,17 @@ func preprocessLayers(img image, m ocispecs.Manifest) ([]ocispecs.Descriptor, er return nil, err } - numLayers := len(m.Layers) - if len(createdDates) != numLayers { + n := len(m.Layers) + + if len(createdDates) != n { return nil, errors.New("unexpected creation dates length") } - if len(createdMsg) != numLayers { + + if len(createdMsg) != n { return nil, errors.New("unexpected creation messages length") } - if len(img.Rootfs.DiffIDs) != numLayers { + + if len(img.Rootfs.DiffIDs) != n { return nil, errors.New("unexpected rootfs diff IDs") } diff --git a/solver/llbsolver/bridge.go b/solver/llbsolver/bridge.go index 8eca07cd1..e445c9539 100644 --- a/solver/llbsolver/bridge.go +++ b/solver/llbsolver/bridge.go @@ -96,10 +96,7 @@ func (b *llbBridge) loadResult(ctx context.Context, def *pb.Definition, cacheImp polEngine = sourcepolicy.NewEngine(pol) } - err = b.processImports(ctx, cacheImports, w) - if err != nil { - return nil, err - } + b.processImports(ctx, cacheImports, w) dpc := &detectPrunedCacheID{} @@ -127,7 +124,7 @@ func (b *llbBridge) loadResult(ctx context.Context, def *pb.Definition, cacheImp return res, nil } -func (b *llbBridge) processImports(ctx context.Context, cacheImports []gw.CacheOptionsEntry, w worker.Worker) error { +func (b *llbBridge) processImports(ctx context.Context, cacheImports []gw.CacheOptionsEntry, w worker.Worker) { var importRefs []string // Earthly custom inline cache handling. Other cache import types are ignored. @@ -150,15 +147,15 @@ func (b *llbBridge) processImports(ctx context.Context, cacheImports []gw.CacheO b.importMu.Unlock() remotes := map[digest.Digest]*solver.Remote{} + name := fmt.Sprintf("importing cache manifest from %s", importRef) - err := inBuilderContext(ctx, b.builder, "importing cache manifest from "+importRef, "", func(ctx context.Context, g session.Group) error { + err := inBuilderContext(ctx, b.builder, name, "", func(ctx context.Context, g session.Group) error { var err error remotes, err = registry.EarthlyInlineCacheRemotes(ctx, b.sm, w, b.registryHosts, g, cacheImport.Attrs) return err }) if err != nil { - close(done) - return err + bklog.G(ctx).Warnf("failed to import cache manifest from %s", importRef) } if len(remotes) > 0 { @@ -176,8 +173,6 @@ func (b *llbBridge) processImports(ctx context.Context, cacheImports []gw.CacheO b.importMu.Unlock() <-done } - - return nil } // getExporter is earthly specific code which extracts the configured exporter