Skip to content

Commit

Permalink
Don't fail when remote doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejholly committed May 17, 2024
1 parent 6de99da commit b88c5bd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
11 changes: 7 additions & 4 deletions cache/remotecache/inline.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down
15 changes: 5 additions & 10 deletions solver/llbsolver/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}

Expand Down Expand Up @@ -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.
Expand All @@ -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 {
Expand All @@ -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
Expand Down

0 comments on commit b88c5bd

Please sign in to comment.