Vendor in latest containers/storage
Fixes store.lock issue comming up when using store.Names Signed-off-by: umohnani8 <umohnani@redhat.com>
This commit is contained in:
parent
400713a58b
commit
cfc2393d58
119 changed files with 2846 additions and 1730 deletions
517
vendor/github.com/containers/storage/store.go
generated
vendored
517
vendor/github.com/containers/storage/store.go
generated
vendored
|
@ -25,36 +25,6 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
// ErrLoadError indicates that there was an initialization error.
|
||||
ErrLoadError = errors.New("error loading storage metadata")
|
||||
// ErrDuplicateID indicates that an ID which is to be assigned to a new item is already being used.
|
||||
ErrDuplicateID = errors.New("that ID is already in use")
|
||||
// ErrDuplicateName indicates that a name which is to be assigned to a new item is already being used.
|
||||
ErrDuplicateName = errors.New("that name is already in use")
|
||||
// ErrParentIsContainer is returned when a caller attempts to create a layer as a child of a container's layer.
|
||||
ErrParentIsContainer = errors.New("would-be parent layer is a container")
|
||||
// ErrNotAContainer is returned when the caller attempts to delete a container that isn't a container.
|
||||
ErrNotAContainer = errors.New("identifier is not a container")
|
||||
// ErrNotAnImage is returned when the caller attempts to delete an image that isn't an image.
|
||||
ErrNotAnImage = errors.New("identifier is not an image")
|
||||
// ErrNotALayer is returned when the caller attempts to delete a layer that isn't a layer.
|
||||
ErrNotALayer = errors.New("identifier is not a layer")
|
||||
// ErrNotAnID is returned when the caller attempts to read or write metadata from an item that doesn't exist.
|
||||
ErrNotAnID = errors.New("identifier is not a layer, image, or container")
|
||||
// ErrLayerHasChildren is returned when the caller attempts to delete a layer that has children.
|
||||
ErrLayerHasChildren = errors.New("layer has children")
|
||||
// ErrLayerUsedByImage is returned when the caller attempts to delete a layer that is an image's top layer.
|
||||
ErrLayerUsedByImage = errors.New("layer is in use by an image")
|
||||
// ErrLayerUsedByContainer is returned when the caller attempts to delete a layer that is a container's layer.
|
||||
ErrLayerUsedByContainer = errors.New("layer is in use by a container")
|
||||
// ErrImageUsedByContainer is returned when the caller attempts to delete an image that is a container's image.
|
||||
ErrImageUsedByContainer = errors.New("image is in use by a container")
|
||||
// ErrIncompleteOptions is returned when the caller attempts to initialize a Store without providing required information.
|
||||
ErrIncompleteOptions = errors.New("missing necessary StoreOptions")
|
||||
// ErrSizeUnknown is returned when the caller asks for the size of a big data item, but the Store couldn't determine the answer.
|
||||
ErrSizeUnknown = errors.New("size is not known")
|
||||
// ErrStoreIsReadOnly is returned when the caller makes a call to a read-only store that would require modifying its contents.
|
||||
ErrStoreIsReadOnly = errors.New("called a write method on a read-only store")
|
||||
// DefaultStoreOptions is a reasonable default set of options.
|
||||
DefaultStoreOptions StoreOptions
|
||||
stores []*store
|
||||
|
@ -183,31 +153,6 @@ type Store interface {
|
|||
// by the Store.
|
||||
GraphDriver() (drivers.Driver, error)
|
||||
|
||||
// LayerStore obtains and returns a handle to the writeable layer store
|
||||
// object used by the Store. Accessing this store directly will bypass
|
||||
// locking and synchronization, so use it with care.
|
||||
LayerStore() (LayerStore, error)
|
||||
|
||||
// ROLayerStore obtains additional read/only layer store objects used
|
||||
// by the Store. Accessing these stores directly will bypass locking
|
||||
// and synchronization, so use them with care.
|
||||
ROLayerStores() ([]ROLayerStore, error)
|
||||
|
||||
// ImageStore obtains and returns a handle to the writable image store
|
||||
// object used by the Store. Accessing this store directly will bypass
|
||||
// locking and synchronization, so use it with care.
|
||||
ImageStore() (ImageStore, error)
|
||||
|
||||
// ROImageStores obtains additional read/only image store objects used
|
||||
// by the Store. Accessing these stores directly will bypass locking
|
||||
// and synchronization, so use them with care.
|
||||
ROImageStores() ([]ROImageStore, error)
|
||||
|
||||
// ContainerStore obtains and returns a handle to the container store
|
||||
// object used by the Store. Accessing this store directly will bypass
|
||||
// locking and synchronization, so use it with care.
|
||||
ContainerStore() (ContainerStore, error)
|
||||
|
||||
// CreateLayer creates a new layer in the underlying storage driver,
|
||||
// optionally having the specified ID (one will be assigned if none is
|
||||
// specified), with the specified layer (or no layer) as its parent,
|
||||
|
@ -225,7 +170,7 @@ type Store interface {
|
|||
// if reexec.Init {
|
||||
// return
|
||||
// }
|
||||
PutLayer(id, parent string, names []string, mountLabel string, writeable bool, diff archive.Reader) (*Layer, int64, error)
|
||||
PutLayer(id, parent string, names []string, mountLabel string, writeable bool, diff io.Reader) (*Layer, int64, error)
|
||||
|
||||
// CreateImage creates a new image, optionally with the specified ID
|
||||
// (one will be assigned if none is specified), with optional names,
|
||||
|
@ -340,7 +285,7 @@ type Store interface {
|
|||
// if reexec.Init {
|
||||
// return
|
||||
// }
|
||||
ApplyDiff(to string, diff archive.Reader) (int64, error)
|
||||
ApplyDiff(to string, diff io.Reader) (int64, error)
|
||||
|
||||
// LayersByCompressedDigest returns a slice of the layers with the
|
||||
// specified compressed digest value recorded for them.
|
||||
|
@ -367,6 +312,7 @@ type Store interface {
|
|||
Names(id string) ([]string, error)
|
||||
|
||||
// SetNames changes the list of names for a layer, image, or container.
|
||||
// Duplicate names are removed from the list automatically.
|
||||
SetNames(id string, names []string) error
|
||||
|
||||
// ListImageBigData retrieves a list of the (possibly large) chunks of
|
||||
|
@ -664,6 +610,9 @@ func (s *store) GraphDriver() (drivers.Driver, error) {
|
|||
return s.getGraphDriver()
|
||||
}
|
||||
|
||||
// LayerStore obtains and returns a handle to the writeable layer store object
|
||||
// used by the Store. Accessing this store directly will bypass locking and
|
||||
// synchronization, so it is not a part of the exported Store interface.
|
||||
func (s *store) LayerStore() (LayerStore, error) {
|
||||
s.graphLock.Lock()
|
||||
defer s.graphLock.Unlock()
|
||||
|
@ -696,6 +645,9 @@ func (s *store) LayerStore() (LayerStore, error) {
|
|||
return s.layerStore, nil
|
||||
}
|
||||
|
||||
// ROLayerStores obtains additional read/only layer store objects used by the
|
||||
// Store. Accessing these stores directly will bypass locking and
|
||||
// synchronization, so it is not part of the exported Store interface.
|
||||
func (s *store) ROLayerStores() ([]ROLayerStore, error) {
|
||||
s.graphLock.Lock()
|
||||
defer s.graphLock.Unlock()
|
||||
|
@ -722,6 +674,9 @@ func (s *store) ROLayerStores() ([]ROLayerStore, error) {
|
|||
return s.roLayerStores, nil
|
||||
}
|
||||
|
||||
// ImageStore obtains and returns a handle to the writable image store object
|
||||
// used by the Store. Accessing this store directly will bypass locking and
|
||||
// synchronization, so it is not a part of the exported Store interface.
|
||||
func (s *store) ImageStore() (ImageStore, error) {
|
||||
if s.imageStore != nil {
|
||||
return s.imageStore, nil
|
||||
|
@ -729,6 +684,9 @@ func (s *store) ImageStore() (ImageStore, error) {
|
|||
return nil, ErrLoadError
|
||||
}
|
||||
|
||||
// ROImageStores obtains additional read/only image store objects used by the
|
||||
// Store. Accessing these stores directly will bypass locking and
|
||||
// synchronization, so it is not a part of the exported Store interface.
|
||||
func (s *store) ROImageStores() ([]ROImageStore, error) {
|
||||
if len(s.roImageStores) != 0 {
|
||||
return s.roImageStores, nil
|
||||
|
@ -749,6 +707,9 @@ func (s *store) ROImageStores() ([]ROImageStore, error) {
|
|||
return s.roImageStores, nil
|
||||
}
|
||||
|
||||
// ContainerStore obtains and returns a handle to the container store object
|
||||
// used by the Store. Accessing this store directly will bypass locking and
|
||||
// synchronization, so it is not a part of the exported Store interface.
|
||||
func (s *store) ContainerStore() (ContainerStore, error) {
|
||||
if s.containerStore != nil {
|
||||
return s.containerStore, nil
|
||||
|
@ -756,7 +717,7 @@ func (s *store) ContainerStore() (ContainerStore, error) {
|
|||
return nil, ErrLoadError
|
||||
}
|
||||
|
||||
func (s *store) PutLayer(id, parent string, names []string, mountLabel string, writeable bool, diff archive.Reader) (*Layer, int64, error) {
|
||||
func (s *store) PutLayer(id, parent string, names []string, mountLabel string, writeable bool, diff io.Reader) (*Layer, int64, error) {
|
||||
rlstore, err := s.LayerStore()
|
||||
if err != nil {
|
||||
return nil, -1, err
|
||||
|
@ -808,23 +769,22 @@ func (s *store) CreateImage(id string, names []string, layer, metadata string, o
|
|||
id = stringid.GenerateRandomID()
|
||||
}
|
||||
|
||||
rlstore, err := s.LayerStore()
|
||||
lstore, err := s.LayerStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
stores, err := s.ROLayerStores()
|
||||
lstores, err := s.ROLayerStores()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
stores = append([]ROLayerStore{rlstore}, stores...)
|
||||
var ilayer *Layer
|
||||
for _, rlstore := range stores {
|
||||
rlstore.Lock()
|
||||
defer rlstore.Unlock()
|
||||
if modified, err := rlstore.Modified(); modified || err != nil {
|
||||
rlstore.Load()
|
||||
for _, store := range append([]ROLayerStore{lstore}, lstores...) {
|
||||
store.Lock()
|
||||
defer store.Unlock()
|
||||
if modified, err := store.Modified(); modified || err != nil {
|
||||
store.Load()
|
||||
}
|
||||
ilayer, err = rlstore.Get(layer)
|
||||
ilayer, err = store.Get(layer)
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
|
@ -869,23 +829,22 @@ func (s *store) CreateContainer(id string, names []string, image, layer, metadat
|
|||
imageTopLayer := ""
|
||||
imageID := ""
|
||||
if image != "" {
|
||||
ristore, err := s.ImageStore()
|
||||
istore, err := s.ImageStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
stores, err := s.ROImageStores()
|
||||
istores, err := s.ROImageStores()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
stores = append([]ROImageStore{ristore}, stores...)
|
||||
var cimage *Image
|
||||
for _, ristore := range stores {
|
||||
ristore.Lock()
|
||||
defer ristore.Unlock()
|
||||
if modified, err := ristore.Modified(); modified || err != nil {
|
||||
ristore.Load()
|
||||
for _, store := range append([]ROImageStore{istore}, istores...) {
|
||||
store.Lock()
|
||||
defer store.Unlock()
|
||||
if modified, err := store.Modified(); modified || err != nil {
|
||||
store.Load()
|
||||
}
|
||||
cimage, err = ristore.Get(image)
|
||||
cimage, err = store.Get(image)
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
|
@ -960,23 +919,22 @@ func (s *store) SetMetadata(id, metadata string) error {
|
|||
}
|
||||
|
||||
func (s *store) Metadata(id string) (string, error) {
|
||||
rlstore, err := s.LayerStore()
|
||||
lstore, err := s.LayerStore()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
stores, err := s.ROLayerStores()
|
||||
lstores, err := s.ROLayerStores()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
stores = append([]ROLayerStore{rlstore}, stores...)
|
||||
for _, rlstore := range stores {
|
||||
rlstore.Lock()
|
||||
defer rlstore.Unlock()
|
||||
if modified, err := rlstore.Modified(); modified || err != nil {
|
||||
rlstore.Load()
|
||||
for _, store := range append([]ROLayerStore{lstore}, lstores...) {
|
||||
store.Lock()
|
||||
defer store.Unlock()
|
||||
if modified, err := store.Modified(); modified || err != nil {
|
||||
store.Load()
|
||||
}
|
||||
if rlstore.Exists(id) {
|
||||
return rlstore.Metadata(id)
|
||||
if store.Exists(id) {
|
||||
return store.Metadata(id)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -988,50 +946,48 @@ func (s *store) Metadata(id string) (string, error) {
|
|||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
istores = append([]ROImageStore{istore}, istores...)
|
||||
for _, ristore := range istores {
|
||||
ristore.Lock()
|
||||
defer ristore.Unlock()
|
||||
if modified, err := ristore.Modified(); modified || err != nil {
|
||||
ristore.Load()
|
||||
for _, store := range append([]ROImageStore{istore}, istores...) {
|
||||
store.Lock()
|
||||
defer store.Unlock()
|
||||
if modified, err := store.Modified(); modified || err != nil {
|
||||
store.Load()
|
||||
}
|
||||
if ristore.Exists(id) {
|
||||
return ristore.Metadata(id)
|
||||
if store.Exists(id) {
|
||||
return store.Metadata(id)
|
||||
}
|
||||
}
|
||||
|
||||
rcstore, err := s.ContainerStore()
|
||||
cstore, err := s.ContainerStore()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
rcstore.Lock()
|
||||
defer rcstore.Unlock()
|
||||
if modified, err := rcstore.Modified(); modified || err != nil {
|
||||
rcstore.Load()
|
||||
cstore.Lock()
|
||||
defer cstore.Unlock()
|
||||
if modified, err := cstore.Modified(); modified || err != nil {
|
||||
cstore.Load()
|
||||
}
|
||||
if rcstore.Exists(id) {
|
||||
return rcstore.Metadata(id)
|
||||
if cstore.Exists(id) {
|
||||
return cstore.Metadata(id)
|
||||
}
|
||||
return "", ErrNotAnID
|
||||
}
|
||||
|
||||
func (s *store) ListImageBigData(id string) ([]string, error) {
|
||||
ristore, err := s.ImageStore()
|
||||
istore, err := s.ImageStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
stores, err := s.ROImageStores()
|
||||
istores, err := s.ROImageStores()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
stores = append([]ROImageStore{ristore}, stores...)
|
||||
for _, ristore := range stores {
|
||||
ristore.Lock()
|
||||
defer ristore.Unlock()
|
||||
if modified, err := ristore.Modified(); modified || err != nil {
|
||||
ristore.Load()
|
||||
for _, store := range append([]ROImageStore{istore}, istores...) {
|
||||
store.Lock()
|
||||
defer store.Unlock()
|
||||
if modified, err := store.Modified(); modified || err != nil {
|
||||
store.Load()
|
||||
}
|
||||
bigDataNames, err := ristore.BigDataNames(id)
|
||||
bigDataNames, err := store.BigDataNames(id)
|
||||
if err == nil {
|
||||
return bigDataNames, err
|
||||
}
|
||||
|
@ -1040,22 +996,21 @@ func (s *store) ListImageBigData(id string) ([]string, error) {
|
|||
}
|
||||
|
||||
func (s *store) ImageBigDataSize(id, key string) (int64, error) {
|
||||
ristore, err := s.ImageStore()
|
||||
istore, err := s.ImageStore()
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
stores, err := s.ROImageStores()
|
||||
istores, err := s.ROImageStores()
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
stores = append([]ROImageStore{ristore}, stores...)
|
||||
for _, ristore := range stores {
|
||||
ristore.Lock()
|
||||
defer ristore.Unlock()
|
||||
if modified, err := ristore.Modified(); modified || err != nil {
|
||||
ristore.Load()
|
||||
for _, store := range append([]ROImageStore{istore}, istores...) {
|
||||
store.Lock()
|
||||
defer store.Unlock()
|
||||
if modified, err := store.Modified(); modified || err != nil {
|
||||
store.Load()
|
||||
}
|
||||
size, err := ristore.BigDataSize(id, key)
|
||||
size, err := store.BigDataSize(id, key)
|
||||
if err == nil {
|
||||
return size, nil
|
||||
}
|
||||
|
@ -1064,27 +1019,25 @@ func (s *store) ImageBigDataSize(id, key string) (int64, error) {
|
|||
}
|
||||
|
||||
func (s *store) ImageBigData(id, key string) ([]byte, error) {
|
||||
ristore, err := s.ImageStore()
|
||||
istore, err := s.ImageStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
stores, err := s.ROImageStores()
|
||||
istores, err := s.ROImageStores()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
stores = append([]ROImageStore{ristore}, stores...)
|
||||
for _, ristore := range stores {
|
||||
ristore.Lock()
|
||||
defer ristore.Unlock()
|
||||
if modified, err := ristore.Modified(); modified || err != nil {
|
||||
ristore.Load()
|
||||
for _, store := range append([]ROImageStore{istore}, istores...) {
|
||||
store.Lock()
|
||||
defer store.Unlock()
|
||||
if modified, err := store.Modified(); modified || err != nil {
|
||||
store.Load()
|
||||
}
|
||||
data, err := ristore.BigData(id, key)
|
||||
data, err := store.BigData(id, key)
|
||||
if err == nil {
|
||||
return data, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, ErrImageUnknown
|
||||
}
|
||||
|
||||
|
@ -1169,34 +1122,32 @@ func (s *store) Exists(id string) bool {
|
|||
if err != nil {
|
||||
return false
|
||||
}
|
||||
lstores = append([]ROLayerStore{lstore}, lstores...)
|
||||
for _, rlstore := range lstores {
|
||||
rlstore.Lock()
|
||||
defer rlstore.Unlock()
|
||||
if modified, err := rlstore.Modified(); modified || err != nil {
|
||||
rlstore.Load()
|
||||
for _, store := range append([]ROLayerStore{lstore}, lstores...) {
|
||||
store.Lock()
|
||||
defer store.Unlock()
|
||||
if modified, err := store.Modified(); modified || err != nil {
|
||||
store.Load()
|
||||
}
|
||||
if rlstore.Exists(id) {
|
||||
if store.Exists(id) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
ristore, err := s.ImageStore()
|
||||
istore, err := s.ImageStore()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
stores, err := s.ROImageStores()
|
||||
istores, err := s.ROImageStores()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
stores = append([]ROImageStore{ristore}, stores...)
|
||||
for _, ristore := range stores {
|
||||
ristore.Lock()
|
||||
defer ristore.Unlock()
|
||||
if modified, err := ristore.Modified(); modified || err != nil {
|
||||
ristore.Load()
|
||||
for _, store := range append([]ROImageStore{istore}, istores...) {
|
||||
store.Lock()
|
||||
defer store.Unlock()
|
||||
if modified, err := store.Modified(); modified || err != nil {
|
||||
store.Load()
|
||||
}
|
||||
if ristore.Exists(id) {
|
||||
if store.Exists(id) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -1269,42 +1220,40 @@ func (s *store) SetNames(id string, names []string) error {
|
|||
}
|
||||
|
||||
func (s *store) Names(id string) ([]string, error) {
|
||||
rlstore, err := s.LayerStore()
|
||||
lstore, err := s.LayerStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
stores, err := s.ROLayerStores()
|
||||
lstores, err := s.ROLayerStores()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
stores = append([]ROLayerStore{rlstore}, stores...)
|
||||
for _, rlstore := range stores {
|
||||
rlstore.Lock()
|
||||
defer rlstore.Unlock()
|
||||
if modified, err := rlstore.Modified(); modified || err != nil {
|
||||
rlstore.Load()
|
||||
for _, store := range append([]ROLayerStore{lstore}, lstores...) {
|
||||
store.Lock()
|
||||
defer store.Unlock()
|
||||
if modified, err := store.Modified(); modified || err != nil {
|
||||
store.Load()
|
||||
}
|
||||
if l, err := rlstore.Get(id); l != nil && err == nil {
|
||||
if l, err := store.Get(id); l != nil && err == nil {
|
||||
return l.Names, nil
|
||||
}
|
||||
}
|
||||
|
||||
ristore, err := s.ImageStore()
|
||||
istore, err := s.ImageStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ristores, err := s.ROImageStores()
|
||||
istores, err := s.ROImageStores()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ristores = append([]ROImageStore{ristore}, ristores...)
|
||||
for _, ristore := range stores {
|
||||
ristore.Lock()
|
||||
defer ristore.Unlock()
|
||||
if modified, err := ristore.Modified(); modified || err != nil {
|
||||
ristore.Load()
|
||||
for _, store := range append([]ROImageStore{istore}, istores...) {
|
||||
store.Lock()
|
||||
defer store.Unlock()
|
||||
if modified, err := store.Modified(); modified || err != nil {
|
||||
store.Load()
|
||||
}
|
||||
if i, err := ristore.Get(id); i != nil && err == nil {
|
||||
if i, err := store.Get(id); i != nil && err == nil {
|
||||
return i.Names, nil
|
||||
}
|
||||
}
|
||||
|
@ -1325,44 +1274,57 @@ func (s *store) Names(id string) ([]string, error) {
|
|||
}
|
||||
|
||||
func (s *store) Lookup(name string) (string, error) {
|
||||
rcstore, err := s.ContainerStore()
|
||||
lstore, err := s.LayerStore()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
ristore, err := s.ImageStore()
|
||||
lstores, err := s.ROLayerStores()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
rlstore, err := s.LayerStore()
|
||||
if err != nil {
|
||||
return "", err
|
||||
for _, store := range append([]ROLayerStore{lstore}, lstores...) {
|
||||
store.Lock()
|
||||
defer store.Unlock()
|
||||
if modified, err := store.Modified(); modified || err != nil {
|
||||
store.Load()
|
||||
}
|
||||
if l, err := store.Get(name); l != nil && err == nil {
|
||||
return l.ID, nil
|
||||
}
|
||||
}
|
||||
|
||||
rlstore.Lock()
|
||||
defer rlstore.Unlock()
|
||||
if modified, err := rlstore.Modified(); modified || err != nil {
|
||||
rlstore.Load()
|
||||
istore, err := s.ImageStore()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
ristore.Lock()
|
||||
defer ristore.Unlock()
|
||||
if modified, err := ristore.Modified(); modified || err != nil {
|
||||
ristore.Load()
|
||||
istores, err := s.ROImageStores()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
rcstore.Lock()
|
||||
defer rcstore.Unlock()
|
||||
if modified, err := rcstore.Modified(); modified || err != nil {
|
||||
rcstore.Load()
|
||||
for _, store := range append([]ROImageStore{istore}, istores...) {
|
||||
store.Lock()
|
||||
defer store.Unlock()
|
||||
if modified, err := store.Modified(); modified || err != nil {
|
||||
store.Load()
|
||||
}
|
||||
if i, err := store.Get(name); i != nil && err == nil {
|
||||
return i.ID, nil
|
||||
}
|
||||
}
|
||||
|
||||
if l, err := rlstore.Get(name); l != nil && err == nil {
|
||||
return l.ID, nil
|
||||
cstore, err := s.ContainerStore()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if i, err := ristore.Get(name); i != nil && err == nil {
|
||||
return i.ID, nil
|
||||
cstore.Lock()
|
||||
defer cstore.Unlock()
|
||||
if modified, err := cstore.Modified(); modified || err != nil {
|
||||
cstore.Load()
|
||||
}
|
||||
if c, err := rcstore.Get(name); c != nil && err == nil {
|
||||
if c, err := cstore.Get(name); c != nil && err == nil {
|
||||
return c.ID, nil
|
||||
}
|
||||
|
||||
return "", ErrLayerUnknown
|
||||
}
|
||||
|
||||
|
@ -1758,75 +1720,72 @@ func (s *store) Unmount(id string) error {
|
|||
}
|
||||
|
||||
func (s *store) Changes(from, to string) ([]archive.Change, error) {
|
||||
rlstore, err := s.LayerStore()
|
||||
lstore, err := s.LayerStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
stores, err := s.ROLayerStores()
|
||||
lstores, err := s.ROLayerStores()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
stores = append([]ROLayerStore{rlstore}, stores...)
|
||||
for _, rlstore := range stores {
|
||||
rlstore.Lock()
|
||||
defer rlstore.Unlock()
|
||||
if modified, err := rlstore.Modified(); modified || err != nil {
|
||||
rlstore.Load()
|
||||
for _, store := range append([]ROLayerStore{lstore}, lstores...) {
|
||||
store.Lock()
|
||||
defer store.Unlock()
|
||||
if modified, err := store.Modified(); modified || err != nil {
|
||||
store.Load()
|
||||
}
|
||||
if rlstore.Exists(to) {
|
||||
return rlstore.Changes(from, to)
|
||||
if store.Exists(to) {
|
||||
return store.Changes(from, to)
|
||||
}
|
||||
}
|
||||
return nil, ErrLayerUnknown
|
||||
}
|
||||
|
||||
func (s *store) DiffSize(from, to string) (int64, error) {
|
||||
rlstore, err := s.LayerStore()
|
||||
lstore, err := s.LayerStore()
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
stores, err := s.ROLayerStores()
|
||||
lstores, err := s.ROLayerStores()
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
stores = append([]ROLayerStore{rlstore}, stores...)
|
||||
for _, rlstore := range stores {
|
||||
rlstore.Lock()
|
||||
defer rlstore.Unlock()
|
||||
if modified, err := rlstore.Modified(); modified || err != nil {
|
||||
rlstore.Load()
|
||||
for _, store := range append([]ROLayerStore{lstore}, lstores...) {
|
||||
store.Lock()
|
||||
defer store.Unlock()
|
||||
if modified, err := store.Modified(); modified || err != nil {
|
||||
store.Load()
|
||||
}
|
||||
if rlstore.Exists(to) {
|
||||
return rlstore.DiffSize(from, to)
|
||||
if store.Exists(to) {
|
||||
return store.DiffSize(from, to)
|
||||
}
|
||||
}
|
||||
return -1, ErrLayerUnknown
|
||||
}
|
||||
|
||||
func (s *store) Diff(from, to string, options *DiffOptions) (io.ReadCloser, error) {
|
||||
rlstore, err := s.LayerStore()
|
||||
lstore, err := s.LayerStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
stores, err := s.ROLayerStores()
|
||||
lstores, err := s.ROLayerStores()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
stores = append([]ROLayerStore{rlstore}, stores...)
|
||||
for _, rlstore := range stores {
|
||||
rlstore.Lock()
|
||||
defer rlstore.Unlock()
|
||||
if modified, err := rlstore.Modified(); modified || err != nil {
|
||||
rlstore.Load()
|
||||
for _, store := range append([]ROLayerStore{lstore}, lstores...) {
|
||||
store.Lock()
|
||||
defer store.Unlock()
|
||||
if modified, err := store.Modified(); modified || err != nil {
|
||||
store.Load()
|
||||
}
|
||||
if rlstore.Exists(to) {
|
||||
return rlstore.Diff(from, to, options)
|
||||
if store.Exists(to) {
|
||||
return store.Diff(from, to, options)
|
||||
}
|
||||
}
|
||||
return nil, ErrLayerUnknown
|
||||
}
|
||||
|
||||
func (s *store) ApplyDiff(to string, diff archive.Reader) (int64, error) {
|
||||
func (s *store) ApplyDiff(to string, diff io.Reader) (int64, error) {
|
||||
rlstore, err := s.LayerStore()
|
||||
if err != nil {
|
||||
return -1, err
|
||||
|
@ -1844,28 +1803,26 @@ func (s *store) ApplyDiff(to string, diff archive.Reader) (int64, error) {
|
|||
|
||||
func (s *store) layersByMappedDigest(m func(ROLayerStore, digest.Digest) ([]Layer, error), d digest.Digest) ([]Layer, error) {
|
||||
var layers []Layer
|
||||
rlstore, err := s.LayerStore()
|
||||
lstore, err := s.LayerStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
stores, err := s.ROLayerStores()
|
||||
lstores, err := s.ROLayerStores()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
stores = append([]ROLayerStore{rlstore}, stores...)
|
||||
|
||||
for _, rlstore := range stores {
|
||||
rlstore.Lock()
|
||||
defer rlstore.Unlock()
|
||||
if modified, err := rlstore.Modified(); modified || err != nil {
|
||||
rlstore.Load()
|
||||
for _, store := range append([]ROLayerStore{lstore}, lstores...) {
|
||||
store.Lock()
|
||||
defer store.Unlock()
|
||||
if modified, err := store.Modified(); modified || err != nil {
|
||||
store.Load()
|
||||
}
|
||||
slayers, err := m(rlstore, d)
|
||||
storeLayers, err := m(store, d)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
layers = append(layers, slayers...)
|
||||
layers = append(layers, storeLayers...)
|
||||
}
|
||||
return layers, nil
|
||||
}
|
||||
|
@ -1887,15 +1844,14 @@ func (s *store) LayerSize(id string) (int64, error) {
|
|||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
lstores = append([]ROLayerStore{lstore}, lstores...)
|
||||
for _, rlstore := range lstores {
|
||||
rlstore.Lock()
|
||||
defer rlstore.Unlock()
|
||||
if modified, err := rlstore.Modified(); modified || err != nil {
|
||||
rlstore.Load()
|
||||
for _, store := range append([]ROLayerStore{lstore}, lstores...) {
|
||||
store.Lock()
|
||||
defer store.Unlock()
|
||||
if modified, err := store.Modified(); modified || err != nil {
|
||||
store.Load()
|
||||
}
|
||||
if rlstore.Exists(id) {
|
||||
return rlstore.Size(id)
|
||||
if store.Exists(id) {
|
||||
return store.Size(id)
|
||||
}
|
||||
}
|
||||
return -1, ErrLayerUnknown
|
||||
|
@ -1903,55 +1859,53 @@ func (s *store) LayerSize(id string) (int64, error) {
|
|||
|
||||
func (s *store) Layers() ([]Layer, error) {
|
||||
var layers []Layer
|
||||
rlstore, err := s.LayerStore()
|
||||
lstore, err := s.LayerStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
stores, err := s.ROLayerStores()
|
||||
lstores, err := s.ROLayerStores()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
stores = append([]ROLayerStore{rlstore}, stores...)
|
||||
|
||||
for _, rlstore := range stores {
|
||||
rlstore.Lock()
|
||||
defer rlstore.Unlock()
|
||||
if modified, err := rlstore.Modified(); modified || err != nil {
|
||||
rlstore.Load()
|
||||
for _, store := range append([]ROLayerStore{lstore}, lstores...) {
|
||||
store.Lock()
|
||||
defer store.Unlock()
|
||||
if modified, err := store.Modified(); modified || err != nil {
|
||||
store.Load()
|
||||
}
|
||||
slayers, err := rlstore.Layers()
|
||||
storeLayers, err := store.Layers()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
layers = append(layers, slayers...)
|
||||
layers = append(layers, storeLayers...)
|
||||
}
|
||||
return layers, nil
|
||||
}
|
||||
|
||||
func (s *store) Images() ([]Image, error) {
|
||||
var images []Image
|
||||
ristore, err := s.ImageStore()
|
||||
istore, err := s.ImageStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
stores, err := s.ROImageStores()
|
||||
istores, err := s.ROImageStores()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
stores = append([]ROImageStore{ristore}, stores...)
|
||||
for _, ristore := range stores {
|
||||
ristore.Lock()
|
||||
defer ristore.Unlock()
|
||||
if modified, err := ristore.Modified(); modified || err != nil {
|
||||
ristore.Load()
|
||||
for _, store := range append([]ROImageStore{istore}, istores...) {
|
||||
store.Lock()
|
||||
defer store.Unlock()
|
||||
if modified, err := store.Modified(); modified || err != nil {
|
||||
store.Load()
|
||||
}
|
||||
simages, err := ristore.Images()
|
||||
storeImages, err := store.Images()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
images = append(images, simages...)
|
||||
images = append(images, storeImages...)
|
||||
}
|
||||
return images, nil
|
||||
}
|
||||
|
@ -1972,24 +1926,21 @@ func (s *store) Containers() ([]Container, error) {
|
|||
}
|
||||
|
||||
func (s *store) Layer(id string) (*Layer, error) {
|
||||
rlstore, err := s.LayerStore()
|
||||
lstore, err := s.LayerStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
stores, err := s.ROLayerStores()
|
||||
lstores, err := s.ROLayerStores()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
stores = append([]ROLayerStore{rlstore}, stores...)
|
||||
|
||||
for _, rlstore := range stores {
|
||||
rlstore.Lock()
|
||||
defer rlstore.Unlock()
|
||||
if modified, err := rlstore.Modified(); modified || err != nil {
|
||||
rlstore.Load()
|
||||
for _, store := range append([]ROLayerStore{lstore}, lstores...) {
|
||||
store.Lock()
|
||||
defer store.Unlock()
|
||||
if modified, err := store.Modified(); modified || err != nil {
|
||||
store.Load()
|
||||
}
|
||||
layer, err := rlstore.Get(id)
|
||||
layer, err := store.Get(id)
|
||||
if err == nil {
|
||||
return layer, nil
|
||||
}
|
||||
|
@ -1998,22 +1949,21 @@ func (s *store) Layer(id string) (*Layer, error) {
|
|||
}
|
||||
|
||||
func (s *store) Image(id string) (*Image, error) {
|
||||
ristore, err := s.ImageStore()
|
||||
istore, err := s.ImageStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
stores, err := s.ROImageStores()
|
||||
istores, err := s.ROImageStores()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
stores = append([]ROImageStore{ristore}, stores...)
|
||||
for _, ristore := range stores {
|
||||
ristore.Lock()
|
||||
defer ristore.Unlock()
|
||||
if modified, err := ristore.Modified(); modified || err != nil {
|
||||
ristore.Load()
|
||||
for _, store := range append([]ROImageStore{istore}, istores...) {
|
||||
store.Lock()
|
||||
defer store.Unlock()
|
||||
if modified, err := store.Modified(); modified || err != nil {
|
||||
store.Load()
|
||||
}
|
||||
image, err := ristore.Get(id)
|
||||
image, err := store.Get(id)
|
||||
if err == nil {
|
||||
return image, nil
|
||||
}
|
||||
|
@ -2028,23 +1978,22 @@ func (s *store) ImagesByTopLayer(id string) ([]*Image, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
ristore, err := s.ImageStore()
|
||||
istore, err := s.ImageStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
stores, err := s.ROImageStores()
|
||||
istores, err := s.ROImageStores()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
stores = append([]ROImageStore{ristore}, stores...)
|
||||
for _, ristore := range stores {
|
||||
ristore.Lock()
|
||||
defer ristore.Unlock()
|
||||
if modified, err := ristore.Modified(); modified || err != nil {
|
||||
ristore.Load()
|
||||
for _, store := range append([]ROImageStore{istore}, istores...) {
|
||||
store.Lock()
|
||||
defer store.Unlock()
|
||||
if modified, err := store.Modified(); modified || err != nil {
|
||||
store.Load()
|
||||
}
|
||||
imageList, err := ristore.Images()
|
||||
imageList, err := store.Images()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue