Merge pull request #926 from giuseppe/fix-race-reload-store
store: fix graphLock reload
This commit is contained in:
commit
5477b9995b
|
|
@ -626,5 +626,5 @@ func (r *containerStore) ReloadIfChanged() error {
|
||||||
if err == nil && modified {
|
if err == nil && modified {
|
||||||
return r.Load()
|
return r.Load()
|
||||||
}
|
}
|
||||||
return nil
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -810,5 +810,5 @@ func (r *imageStore) ReloadIfChanged() error {
|
||||||
if err == nil && modified {
|
if err == nil && modified {
|
||||||
return r.Load()
|
return r.Load()
|
||||||
}
|
}
|
||||||
return nil
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1780,7 +1780,7 @@ func (r *layerStore) ReloadIfChanged() error {
|
||||||
if err == nil && modified {
|
if err == nil && modified {
|
||||||
return r.Load()
|
return r.Load()
|
||||||
}
|
}
|
||||||
return nil
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func closeAll(closes ...func() error) (rErr error) {
|
func closeAll(closes ...func() error) (rErr error) {
|
||||||
|
|
|
||||||
34
store.go
34
store.go
|
|
@ -788,6 +788,15 @@ func (s *store) load() error {
|
||||||
}
|
}
|
||||||
s.containerStore = rcs
|
s.containerStore = rcs
|
||||||
|
|
||||||
|
for _, store := range driver.AdditionalImageStores() {
|
||||||
|
gipath := filepath.Join(store, driverPrefix+"images")
|
||||||
|
ris, err := newROImageStore(gipath)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
s.roImageStores = append(s.roImageStores, ris)
|
||||||
|
}
|
||||||
|
|
||||||
s.digestLockRoot = filepath.Join(s.runRoot, driverPrefix+"locks")
|
s.digestLockRoot = filepath.Join(s.runRoot, driverPrefix+"locks")
|
||||||
if err := os.MkdirAll(s.digestLockRoot, 0700); err != nil {
|
if err := os.MkdirAll(s.digestLockRoot, 0700); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -910,22 +919,10 @@ func (s *store) ImageStore() (ImageStore, error) {
|
||||||
// Store. Accessing these stores directly will bypass locking and
|
// Store. Accessing these stores directly will bypass locking and
|
||||||
// synchronization, so it is not a part of the exported Store interface.
|
// synchronization, so it is not a part of the exported Store interface.
|
||||||
func (s *store) ROImageStores() ([]ROImageStore, error) {
|
func (s *store) ROImageStores() ([]ROImageStore, error) {
|
||||||
if len(s.roImageStores) != 0 {
|
if s.imageStore == nil {
|
||||||
return s.roImageStores, nil
|
return nil, ErrLoadError
|
||||||
}
|
|
||||||
driver, err := s.getGraphDriver()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
driverPrefix := s.graphDriverName + "-"
|
|
||||||
for _, store := range driver.AdditionalImageStores() {
|
|
||||||
gipath := filepath.Join(store, driverPrefix+"images")
|
|
||||||
ris, err := newROImageStore(gipath)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
s.roImageStores = append(s.roImageStores, ris)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return s.roImageStores, nil
|
return s.roImageStores, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2655,8 +2652,13 @@ func (s *store) mount(id string, options drivers.MountOpts) (string, error) {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
modified, err := s.graphLock.Modified()
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
/* We need to make sure the home mount is present when the Mount is done. */
|
/* We need to make sure the home mount is present when the Mount is done. */
|
||||||
if s.graphLock.TouchedSince(s.lastLoaded) {
|
if modified {
|
||||||
s.graphDriver = nil
|
s.graphDriver = nil
|
||||||
s.layerStore = nil
|
s.layerStore = nil
|
||||||
s.graphDriver, err = s.getGraphDriver()
|
s.graphDriver, err = s.getGraphDriver()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue