show progress when exporting inline cache
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>master
parent
a08d2ea19b
commit
6e82a4a89b
|
@ -192,6 +192,8 @@ func (s *Solver) Solve(ctx context.Context, id string, sessionID string, req fro
|
|||
if inp.Metadata == nil {
|
||||
inp.Metadata = make(map[string][]byte)
|
||||
}
|
||||
var cr solver.CachedResult
|
||||
var crMap = map[string]solver.CachedResult{}
|
||||
if res := res.Ref; res != nil {
|
||||
r, err := res.Result(ctx)
|
||||
if err != nil {
|
||||
|
@ -202,13 +204,7 @@ func (s *Solver) Solve(ctx context.Context, id string, sessionID string, req fro
|
|||
return nil, errors.Errorf("invalid reference: %T", r.Sys())
|
||||
}
|
||||
inp.Ref = workerRef.ImmutableRef
|
||||
dtic, err := inlineCache(ctx, exp.CacheExporter, r, e.Config().Compression, session.NewGroup(sessionID))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if dtic != nil {
|
||||
inp.Metadata[exptypes.ExporterInlineCache] = dtic
|
||||
}
|
||||
cr = r
|
||||
}
|
||||
if res.Refs != nil {
|
||||
m := make(map[string]cache.ImmutableRef, len(res.Refs))
|
||||
|
@ -225,16 +221,36 @@ func (s *Solver) Solve(ctx context.Context, id string, sessionID string, req fro
|
|||
return nil, errors.Errorf("invalid reference: %T", r.Sys())
|
||||
}
|
||||
m[k] = workerRef.ImmutableRef
|
||||
dtic, err := inlineCache(ctx, exp.CacheExporter, r, e.Config().Compression, session.NewGroup(sessionID))
|
||||
crMap[k] = r
|
||||
}
|
||||
}
|
||||
inp.Refs = m
|
||||
}
|
||||
if _, ok := asInlineCache(exp.CacheExporter); ok {
|
||||
if err := inBuilderContext(ctx, j, "preparing layers for inline cache", "", func(ctx context.Context, _ session.Group) error {
|
||||
if cr != nil {
|
||||
dtic, err := inlineCache(ctx, exp.CacheExporter, cr, e.Config().Compression, session.NewGroup(sessionID))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return err
|
||||
}
|
||||
if dtic != nil {
|
||||
inp.Metadata[exptypes.ExporterInlineCache] = dtic
|
||||
}
|
||||
}
|
||||
for k, res := range crMap {
|
||||
dtic, err := inlineCache(ctx, exp.CacheExporter, res, e.Config().Compression, session.NewGroup(sessionID))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if dtic != nil {
|
||||
inp.Metadata[fmt.Sprintf("%s/%s", exptypes.ExporterInlineCache, k)] = dtic
|
||||
}
|
||||
}
|
||||
exp.CacheExporter = nil
|
||||
return nil
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
inp.Refs = m
|
||||
}
|
||||
if err := inBuilderContext(ctx, j, e.Name(), "", func(ctx context.Context, _ session.Group) error {
|
||||
exporterResponse, err = e.Export(ctx, inp, j.SessionID)
|
||||
|
@ -302,10 +318,20 @@ func (s *Solver) Solve(ctx context.Context, id string, sessionID string, req fro
|
|||
}, nil
|
||||
}
|
||||
|
||||
func inlineCache(ctx context.Context, e remotecache.Exporter, res solver.CachedResult, compressionopt compression.Config, g session.Group) ([]byte, error) {
|
||||
if efl, ok := e.(interface {
|
||||
type inlineCacheExporter interface {
|
||||
ExportForLayers(context.Context, []digest.Digest) ([]byte, error)
|
||||
}); ok {
|
||||
}
|
||||
|
||||
func asInlineCache(e remotecache.Exporter) (inlineCacheExporter, bool) {
|
||||
ie, ok := e.(inlineCacheExporter)
|
||||
return ie, ok
|
||||
}
|
||||
|
||||
func inlineCache(ctx context.Context, e remotecache.Exporter, res solver.CachedResult, compressionopt compression.Config, g session.Group) ([]byte, error) {
|
||||
ie, ok := asInlineCache(e)
|
||||
if !ok {
|
||||
return nil, nil
|
||||
}
|
||||
workerRef, ok := res.Sys().(*worker.WorkerRef)
|
||||
if !ok {
|
||||
return nil, errors.Errorf("invalid reference: %T", res.Sys())
|
||||
|
@ -332,10 +358,7 @@ func inlineCache(ctx context.Context, e remotecache.Exporter, res solver.CachedR
|
|||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return efl.ExportForLayers(ctx, digests)
|
||||
}
|
||||
return nil, nil
|
||||
return ie.ExportForLayers(ctx, digests)
|
||||
}
|
||||
|
||||
func withDescHandlerCacheOpts(ctx context.Context, ref cache.ImmutableRef) context.Context {
|
||||
|
|
Loading…
Reference in New Issue