Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
| ... | ... |
@@ -97,7 +97,7 @@ func (s *systemRouter) getDiskUsage(ctx context.Context, w http.ResponseWriter, |
| 97 | 97 |
var err error |
| 98 | 98 |
buildCache, err = s.builder.DiskUsage(ctx) |
| 99 | 99 |
if err != nil {
|
| 100 |
- return pkgerrors.Wrap(err, "error getting fscache build cache usage") |
|
| 100 |
+ return pkgerrors.Wrap(err, "error getting build cache usage") |
|
| 101 | 101 |
} |
| 102 | 102 |
return nil |
| 103 | 103 |
}) |
| ... | ... |
@@ -291,15 +291,14 @@ func (p *puller) Snapshot(ctx context.Context) (cache.ImmutableRef, error) {
|
| 291 | 291 |
} |
| 292 | 292 |
|
| 293 | 293 |
if p.config != nil {
|
| 294 |
- img, err := p.is.ImageStore.Get(image.ID(digest.Digest(p.config))) |
|
| 295 |
- if err != nil {
|
|
| 296 |
- return nil, err |
|
| 297 |
- } |
|
| 298 |
- ref, err := p.is.CacheAccessor.GetFromSnapshotter(ctx, string(img.RootFS.ChainID()), cache.WithDescription(fmt.Sprintf("from local %s", p.ref)))
|
|
| 299 |
- if err != nil {
|
|
| 300 |
- return nil, err |
|
| 294 |
+ img, err := p.is.ImageStore.Get(image.ID(digest.FromBytes(p.config))) |
|
| 295 |
+ if err == nil {
|
|
| 296 |
+ ref, err := p.is.CacheAccessor.GetFromSnapshotter(ctx, string(img.RootFS.ChainID()), cache.WithDescription(fmt.Sprintf("from local %s", p.ref)))
|
|
| 297 |
+ if err != nil {
|
|
| 298 |
+ return nil, err |
|
| 299 |
+ } |
|
| 300 |
+ return ref, nil |
|
| 301 | 301 |
} |
| 302 |
- return ref, nil |
|
| 303 | 302 |
} |
| 304 | 303 |
|
| 305 | 304 |
ongoing := newJobs(p.ref) |
| ... | ... |
@@ -109,6 +109,15 @@ func (b *Builder) Prune(ctx context.Context) (int64, error) {
|
| 109 | 109 |
} |
| 110 | 110 |
|
| 111 | 111 |
func (b *Builder) Build(ctx context.Context, opt backend.BuildConfig) (*builder.Result, error) {
|
| 112 |
+ if buildID := opt.Options.BuildID; buildID != "" {
|
|
| 113 |
+ b.mu.Lock() |
|
| 114 |
+ ctx, b.jobs[buildID] = context.WithCancel(ctx) |
|
| 115 |
+ b.mu.Unlock() |
|
| 116 |
+ defer func() {
|
|
| 117 |
+ delete(b.jobs, buildID) |
|
| 118 |
+ }() |
|
| 119 |
+ } |
|
| 120 |
+ |
|
| 112 | 121 |
var out builder.Result |
| 113 | 122 |
|
| 114 | 123 |
id := identity.NewID() |
| ... | ... |
@@ -73,23 +73,26 @@ func (e *imageExporterInstance) Export(ctx context.Context, ref cache.ImmutableR |
| 73 | 73 |
} |
| 74 | 74 |
config := e.config |
| 75 | 75 |
|
| 76 |
- layersDone := oneOffProgress(ctx, "exporting layers") |
|
| 76 |
+ var diffs []digest.Digest |
|
| 77 |
+ if ref != nil {
|
|
| 78 |
+ layersDone := oneOffProgress(ctx, "exporting layers") |
|
| 77 | 79 |
|
| 78 |
- if err := ref.Finalize(ctx); err != nil {
|
|
| 79 |
- return nil, err |
|
| 80 |
- } |
|
| 80 |
+ if err := ref.Finalize(ctx); err != nil {
|
|
| 81 |
+ return nil, err |
|
| 82 |
+ } |
|
| 81 | 83 |
|
| 82 |
- diffIDs, err := e.opt.Differ.EnsureLayer(ctx, ref.ID()) |
|
| 83 |
- if err != nil {
|
|
| 84 |
- return nil, err |
|
| 85 |
- } |
|
| 84 |
+ diffIDs, err := e.opt.Differ.EnsureLayer(ctx, ref.ID()) |
|
| 85 |
+ if err != nil {
|
|
| 86 |
+ return nil, err |
|
| 87 |
+ } |
|
| 86 | 88 |
|
| 87 |
- diffs := make([]digest.Digest, len(diffIDs)) |
|
| 88 |
- for i := range diffIDs {
|
|
| 89 |
- diffs[i] = digest.Digest(diffIDs[i]) |
|
| 90 |
- } |
|
| 89 |
+ diffs = make([]digest.Digest, len(diffIDs)) |
|
| 90 |
+ for i := range diffIDs {
|
|
| 91 |
+ diffs[i] = digest.Digest(diffIDs[i]) |
|
| 92 |
+ } |
|
| 91 | 93 |
|
| 92 |
- layersDone(nil) |
|
| 94 |
+ layersDone(nil) |
|
| 95 |
+ } |
|
| 93 | 96 |
|
| 94 | 97 |
if len(config) == 0 {
|
| 95 | 98 |
var err error |