Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Commit bf20c56

Browse files
authored
Merge pull request #331 from tiborvass/19.03-buildkit-fixes
[19.03 backport] Cherry-picking build fixes Upstream-commit: ed20165a37b40ff1cfbe55e218344c5e89f30ee2 Component: engine
2 parents 2f9ab52 + 6328c17 commit bf20c56

13 files changed

Lines changed: 115 additions & 133 deletions

File tree

components/engine/builder/builder-next/adapters/snapshot/snapshot.go

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -255,24 +255,23 @@ func (s *snapshotter) Mounts(ctx context.Context, key string) (snapshot.Mountabl
255255
var rwlayer layer.RWLayer
256256
return &mountable{
257257
idmap: s.opt.IdentityMapping,
258-
acquire: func() ([]mount.Mount, error) {
258+
acquire: func() ([]mount.Mount, func() error, error) {
259259
rwlayer, err = s.opt.LayerStore.CreateRWLayer(id, l.ChainID(), nil)
260260
if err != nil {
261-
return nil, err
261+
return nil, nil, err
262262
}
263263
rootfs, err := rwlayer.Mount("")
264264
if err != nil {
265-
return nil, err
265+
return nil, nil, err
266266
}
267267
return []mount.Mount{{
268-
Source: rootfs.Path(),
269-
Type: "bind",
270-
Options: []string{"rbind"},
271-
}}, nil
272-
},
273-
release: func() error {
274-
_, err := s.opt.LayerStore.ReleaseRWLayer(rwlayer)
275-
return err
268+
Source: rootfs.Path(),
269+
Type: "bind",
270+
Options: []string{"rbind"},
271+
}}, func() error {
272+
_, err := s.opt.LayerStore.ReleaseRWLayer(rwlayer)
273+
return err
274+
}, nil
276275
},
277276
}, nil
278277
}
@@ -281,19 +280,18 @@ func (s *snapshotter) Mounts(ctx context.Context, key string) (snapshot.Mountabl
281280

282281
return &mountable{
283282
idmap: s.opt.IdentityMapping,
284-
acquire: func() ([]mount.Mount, error) {
283+
acquire: func() ([]mount.Mount, func() error, error) {
285284
rootfs, err := s.opt.GraphDriver.Get(id, "")
286285
if err != nil {
287-
return nil, err
286+
return nil, nil, err
288287
}
289288
return []mount.Mount{{
290-
Source: rootfs.Path(),
291-
Type: "bind",
292-
Options: []string{"rbind"},
293-
}}, nil
294-
},
295-
release: func() error {
296-
return s.opt.GraphDriver.Put(id)
289+
Source: rootfs.Path(),
290+
Type: "bind",
291+
Options: []string{"rbind"},
292+
}}, func() error {
293+
return s.opt.GraphDriver.Put(id)
294+
}, nil
297295
},
298296
}, nil
299297
}
@@ -440,32 +438,33 @@ func (s *snapshotter) Close() error {
440438
type mountable struct {
441439
mu sync.Mutex
442440
mounts []mount.Mount
443-
acquire func() ([]mount.Mount, error)
441+
acquire func() ([]mount.Mount, func() error, error)
444442
release func() error
445443
refCount int
446444
idmap *idtools.IdentityMapping
447445
}
448446

449-
func (m *mountable) Mount() ([]mount.Mount, error) {
447+
func (m *mountable) Mount() ([]mount.Mount, func() error, error) {
450448
m.mu.Lock()
451449
defer m.mu.Unlock()
452450

453451
if m.mounts != nil {
454452
m.refCount++
455-
return m.mounts, nil
453+
return m.mounts, m.releaseMount, nil
456454
}
457455

458-
mounts, err := m.acquire()
456+
mounts, release, err := m.acquire()
459457
if err != nil {
460-
return nil, err
458+
return nil, nil, err
461459
}
462460
m.mounts = mounts
461+
m.release = release
463462
m.refCount = 1
464463

465-
return m.mounts, nil
464+
return m.mounts, m.releaseMount, nil
466465
}
467466

468-
func (m *mountable) Release() error {
467+
func (m *mountable) releaseMount() error {
469468
m.mu.Lock()
470469
defer m.mu.Unlock()
471470

components/engine/builder/builder-next/exporter/export.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,12 @@ func (e *imageExporterInstance) Export(ctx context.Context, inp exporter.Source)
117117
layersDone := oneOffProgress(ctx, "exporting layers")
118118

119119
if err := ref.Finalize(ctx, true); err != nil {
120-
return nil, err
120+
return nil, layersDone(err)
121121
}
122122

123123
diffIDs, err := e.opt.Differ.EnsureLayer(ctx, ref.ID())
124124
if err != nil {
125-
return nil, err
125+
return nil, layersDone(err)
126126
}
127127

128128
diffs = make([]digest.Digest, len(diffIDs))

components/engine/vendor.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ github.com/imdario/mergo 7c29201646fa3de8506f70121347
2727
golang.org/x/sync e225da77a7e68af35c70ccbf71af2b83e6acac3c
2828

2929
# buildkit
30-
github.com/moby/buildkit be0d75f074e7a4b0f5b5877c719213a3f5057e60 # v0.6.1
30+
github.com/moby/buildkit 588c73e1e4f0f3d7d3738abaaa7cf8026064b33e
3131
github.com/tonistiigi/fsutil 3bbb99cdbd76619ab717299830c60f6f2a533a6b
3232
github.com/grpc-ecosystem/grpc-opentracing 8e809c8a86450a29b90dcc9efbf062d0fe6d9746
3333
github.com/opentracing/opentracing-go 1361b9cd60be79c4c3a7fa9841b3c132e40066a7

components/engine/vendor/github.com/moby/buildkit/cache/contenthash/checksum.go

Lines changed: 7 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/engine/vendor/github.com/moby/buildkit/cache/refs.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/engine/vendor/github.com/moby/buildkit/executor/oci/spec_unix.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/engine/vendor/github.com/moby/buildkit/executor/runcexecutor/executor.go

Lines changed: 10 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/engine/vendor/github.com/moby/buildkit/snapshot/localmounter.go

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/engine/vendor/github.com/moby/buildkit/snapshot/localmounter_unix.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/engine/vendor/github.com/moby/buildkit/snapshot/localmounter_windows.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)