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

Merge pull request #40963 from tonistiigi/layer-fix

builder-next: fix layer access bug
This commit is contained in:
Sebastiaan van Stijn 2020-05-20 12:21:09 +02:00 committed by GitHub
commit e5a679cfd2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View file

@ -6,6 +6,7 @@ import (
"github.com/containerd/containerd/leases"
"github.com/sirupsen/logrus"
bolt "go.etcd.io/bbolt"
)
type sLM struct {
@ -99,6 +100,15 @@ func (l *sLM) addRef(lID, sID string) {
if load {
l.s.getLayer(sID, true)
if _, ok := l.s.chainID(sID); ok {
l.s.db.Update(func(tx *bolt.Tx) error {
b, err := tx.CreateBucketIfNotExists([]byte(lID))
if err != nil {
return err
}
return b.Put(keyChainID, []byte(sID))
})
}
}
}

View file

@ -167,10 +167,11 @@ func (s *snapshotter) getLayer(key string, withCommitted bool) (layer.Layer, err
s.mu.Unlock()
return nil, errors.WithStack(err)
}
if id == "" {
s.mu.Unlock()
if id == "" {
return nil, nil
}
return s.getLayer(string(id), withCommitted)
}
var err error
l, err = s.opt.LayerStore.Get(id)