mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #33090 from tonistiigi/fix-release-mounts
builder: Fix releasing implicit mounts
This commit is contained in:
commit
a3eebaf509
1 changed files with 12 additions and 8 deletions
|
@ -19,10 +19,11 @@ type pathCache interface {
|
||||||
// imageContexts is a helper for stacking up built image rootfs and reusing
|
// imageContexts is a helper for stacking up built image rootfs and reusing
|
||||||
// them as contexts
|
// them as contexts
|
||||||
type imageContexts struct {
|
type imageContexts struct {
|
||||||
b *Builder
|
b *Builder
|
||||||
list []*imageMount
|
list []*imageMount // indexed list of stages
|
||||||
byName map[string]*imageMount
|
implicitMounts []*imageMount // implicitly mounted images
|
||||||
cache pathCache
|
byName map[string]*imageMount
|
||||||
|
cache pathCache
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ic *imageContexts) newImageMount(id string) *imageMount {
|
func (ic *imageContexts) newImageMount(id string) *imageMount {
|
||||||
|
@ -75,14 +76,17 @@ func (ic *imageContexts) get(indexOrName string) (*imageMount, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "invalid from flag value %s", indexOrName)
|
return nil, errors.Wrapf(err, "invalid from flag value %s", indexOrName)
|
||||||
}
|
}
|
||||||
|
ic.implicitMounts = append(ic.implicitMounts, im)
|
||||||
return im, nil
|
return im, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ic *imageContexts) unmount() (retErr error) {
|
func (ic *imageContexts) unmount() (retErr error) {
|
||||||
for _, im := range ic.list {
|
for _, iml := range append([][]*imageMount{}, ic.list, ic.implicitMounts) {
|
||||||
if err := im.unmount(); err != nil {
|
for _, im := range iml {
|
||||||
logrus.Error(err)
|
if err := im.unmount(); err != nil {
|
||||||
retErr = err
|
logrus.Error(err)
|
||||||
|
retErr = err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, im := range ic.byName {
|
for _, im := range ic.byName {
|
||||||
|
|
Loading…
Add table
Reference in a new issue