mirror of
https://github.com/moby/buildkit.git
synced 2026-06-24 08:47:57 +00:00
solver: avoid failing cache export on subbranch error
Don't fail whole cache export on subbranch error. This behavior changed in v0.25, but while before error was not returned, the cache chains were either too agressively dropped or the whole exported cache chain got corrupted. Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
@@ -237,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
|
||||
}
|
||||
for _, r := range rec {
|
||||
srcs[i] = append(srcs[i], CacheLink{Src: r, Selector: string(dep.Selector)})
|
||||
@@ -249,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
|
||||
}
|
||||
for _, r := range recs {
|
||||
srcs[de.index] = append(srcs[de.index], CacheLink{Src: r, Selector: de.cacheKey.Selector.String()})
|
||||
@@ -266,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)
|
||||
|
||||
Reference in New Issue
Block a user