1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

builder: Fix releasing implicit mounts

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi 2017-05-08 10:32:20 -07:00
parent dda41118b0
commit 29efb93a19

View file

@ -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 {