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:
commit
e5a679cfd2
2 changed files with 12 additions and 1 deletions
|
@ -6,6 +6,7 @@ import (
|
||||||
|
|
||||||
"github.com/containerd/containerd/leases"
|
"github.com/containerd/containerd/leases"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
bolt "go.etcd.io/bbolt"
|
||||||
)
|
)
|
||||||
|
|
||||||
type sLM struct {
|
type sLM struct {
|
||||||
|
@ -99,6 +100,15 @@ func (l *sLM) addRef(lID, sID string) {
|
||||||
|
|
||||||
if load {
|
if load {
|
||||||
l.s.getLayer(sID, true)
|
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))
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -167,10 +167,11 @@ func (s *snapshotter) getLayer(key string, withCommitted bool) (layer.Layer, err
|
||||||
s.mu.Unlock()
|
s.mu.Unlock()
|
||||||
return nil, errors.WithStack(err)
|
return nil, errors.WithStack(err)
|
||||||
}
|
}
|
||||||
if id == "" {
|
|
||||||
s.mu.Unlock()
|
s.mu.Unlock()
|
||||||
|
if id == "" {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
return s.getLayer(string(id), withCommitted)
|
||||||
}
|
}
|
||||||
var err error
|
var err error
|
||||||
l, err = s.opt.LayerStore.Get(id)
|
l, err = s.opt.LayerStore.Get(id)
|
||||||
|
|
Loading…
Add table
Reference in a new issue