diff options
author | Urvashi Mohnani <umohnani@redhat.com> | 2019-09-16 14:52:24 -0400 |
---|---|---|
committer | Urvashi Mohnani <umohnani@redhat.com> | 2019-09-17 14:35:24 -0400 |
commit | 518d59182eef09254a5c3df30d8af61c5f445c80 (patch) | |
tree | 75db8c5406f22f5dd998cbc60007bc2f6d1b9399 /vendor/github.com | |
parent | 143caa98bf07eef1a4d46da2cc56603a3ef739b8 (diff) | |
download | podman-518d59182eef09254a5c3df30d8af61c5f445c80.tar.gz podman-518d59182eef09254a5c3df30d8af61c5f445c80.tar.bz2 podman-518d59182eef09254a5c3df30d8af61c5f445c80.zip |
Vendor c/storage 1.13.3
Pull in fixes to avoid double locking the mounts list when
doing a save or cleanup.
Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
Diffstat (limited to 'vendor/github.com')
-rw-r--r-- | vendor/github.com/containers/storage/Makefile | 1 | ||||
-rw-r--r-- | vendor/github.com/containers/storage/VERSION | 2 | ||||
-rw-r--r-- | vendor/github.com/containers/storage/images.go | 30 | ||||
-rw-r--r-- | vendor/github.com/containers/storage/layers.go | 71 | ||||
-rw-r--r-- | vendor/github.com/containers/storage/store.go | 10 |
5 files changed, 64 insertions, 50 deletions
diff --git a/vendor/github.com/containers/storage/Makefile b/vendor/github.com/containers/storage/Makefile index bb1de007b..fa0fddaeb 100644 --- a/vendor/github.com/containers/storage/Makefile +++ b/vendor/github.com/containers/storage/Makefile @@ -1,4 +1,5 @@ export GO111MODULE=off +export GOPROXY=https://proxy.golang.org .PHONY: \ all \ diff --git a/vendor/github.com/containers/storage/VERSION b/vendor/github.com/containers/storage/VERSION index 065f9ec4c..01b756823 100644 --- a/vendor/github.com/containers/storage/VERSION +++ b/vendor/github.com/containers/storage/VERSION @@ -1 +1 @@ -1.13.3-dev +1.13.3 diff --git a/vendor/github.com/containers/storage/images.go b/vendor/github.com/containers/storage/images.go index b1df9b765..5d6a2e48d 100644 --- a/vendor/github.com/containers/storage/images.go +++ b/vendor/github.com/containers/storage/images.go @@ -372,7 +372,7 @@ func (r *imageStore) ClearFlag(id string, flag string) error { } image, ok := r.lookup(id) if !ok { - return ErrImageUnknown + return errors.Wrapf(ErrImageUnknown, "error locating image with ID %q", id) } delete(image.Flags, flag) return r.Save() @@ -384,7 +384,7 @@ func (r *imageStore) SetFlag(id string, flag string, value interface{}) error { } image, ok := r.lookup(id) if !ok { - return ErrImageUnknown + return errors.Wrapf(ErrImageUnknown, "error locating image with ID %q", id) } if image.Flags == nil { image.Flags = make(map[string]interface{}) @@ -456,14 +456,14 @@ func (r *imageStore) addMappedTopLayer(id, layer string) error { image.MappedTopLayers = append(image.MappedTopLayers, layer) return r.Save() } - return ErrImageUnknown + return errors.Wrapf(ErrImageUnknown, "error locating image with ID %q", id) } func (r *imageStore) Metadata(id string) (string, error) { if image, ok := r.lookup(id); ok { return image.Metadata, nil } - return "", ErrImageUnknown + return "", errors.Wrapf(ErrImageUnknown, "error locating image with ID %q", id) } func (r *imageStore) SetMetadata(id, metadata string) error { @@ -474,7 +474,7 @@ func (r *imageStore) SetMetadata(id, metadata string) error { image.Metadata = metadata return r.Save() } - return ErrImageUnknown + return errors.Wrapf(ErrImageUnknown, "error locating image with ID %q", id) } func (r *imageStore) removeName(image *Image, name string) { @@ -499,7 +499,7 @@ func (r *imageStore) SetNames(id string, names []string) error { image.Names = names return r.Save() } - return ErrImageUnknown + return errors.Wrapf(ErrImageUnknown, "error locating image with ID %q", id) } func (r *imageStore) Delete(id string) error { @@ -508,7 +508,7 @@ func (r *imageStore) Delete(id string) error { } image, ok := r.lookup(id) if !ok { - return ErrImageUnknown + return errors.Wrapf(ErrImageUnknown, "error locating image with ID %q", id) } id = image.ID toDeleteIndex := -1 @@ -551,14 +551,14 @@ func (r *imageStore) Get(id string) (*Image, error) { if image, ok := r.lookup(id); ok { return copyImage(image), nil } - return nil, ErrImageUnknown + return nil, errors.Wrapf(ErrImageUnknown, "error locating image with ID %q", id) } func (r *imageStore) Lookup(name string) (id string, err error) { if image, ok := r.lookup(name); ok { return image.ID, nil } - return "", ErrImageUnknown + return "", errors.Wrapf(ErrImageUnknown, "error locating image with ID %q", id) } func (r *imageStore) Exists(id string) bool { @@ -570,7 +570,7 @@ func (r *imageStore) ByDigest(d digest.Digest) ([]*Image, error) { if images, ok := r.bydigest[d]; ok { return copyImageSlice(images), nil } - return nil, ErrImageUnknown + return nil, errors.Wrapf(ErrImageUnknown, "error locating image with digest %q", d) } func (r *imageStore) BigData(id, key string) ([]byte, error) { @@ -579,7 +579,7 @@ func (r *imageStore) BigData(id, key string) ([]byte, error) { } image, ok := r.lookup(id) if !ok { - return nil, ErrImageUnknown + return nil, errors.Wrapf(ErrImageUnknown, "error locating image with ID %q", id) } return ioutil.ReadFile(r.datapath(image.ID, key)) } @@ -590,7 +590,7 @@ func (r *imageStore) BigDataSize(id, key string) (int64, error) { } image, ok := r.lookup(id) if !ok { - return -1, ErrImageUnknown + return -1, errors.Wrapf(ErrImageUnknown, "error locating image with ID %q", id) } if image.BigDataSizes == nil { image.BigDataSizes = make(map[string]int64) @@ -610,7 +610,7 @@ func (r *imageStore) BigDataDigest(id, key string) (digest.Digest, error) { } image, ok := r.lookup(id) if !ok { - return "", ErrImageUnknown + return "", errors.Wrapf(ErrImageUnknown, "error locating image with ID %q", id) } if image.BigDataDigests == nil { image.BigDataDigests = make(map[string]digest.Digest) @@ -624,7 +624,7 @@ func (r *imageStore) BigDataDigest(id, key string) (digest.Digest, error) { func (r *imageStore) BigDataNames(id string) ([]string, error) { image, ok := r.lookup(id) if !ok { - return nil, ErrImageUnknown + return nil, errors.Wrapf(ErrImageUnknown, "error locating image with ID %q", id) } return copyStringSlice(image.BigDataNames), nil } @@ -649,7 +649,7 @@ func (r *imageStore) SetBigData(id, key string, data []byte, digestManifest func } image, ok := r.lookup(id) if !ok { - return ErrImageUnknown + return errors.Wrapf(ErrImageUnknown, "error locating image with ID %q", id) } err := os.MkdirAll(r.datadir(image.ID), 0700) if err != nil { diff --git a/vendor/github.com/containers/storage/layers.go b/vendor/github.com/containers/storage/layers.go index d746ba061..ac905b0b4 100644 --- a/vendor/github.com/containers/storage/layers.go +++ b/vendor/github.com/containers/storage/layers.go @@ -363,7 +363,7 @@ func (r *layerStore) Load() error { } if cleanup, ok := layer.Flags[incompleteFlag]; ok { if b, ok := cleanup.(bool); ok && b { - err = r.Delete(layer.ID) + err = r.deleteInternal(layer.ID) if err != nil { break } @@ -372,7 +372,7 @@ func (r *layerStore) Load() error { } } if shouldSave { - return r.Save() + return r.saveLayers() } } return err @@ -416,6 +416,16 @@ func (r *layerStore) loadMounts() error { } func (r *layerStore) Save() error { + r.mountsLockfile.Lock() + defer r.mountsLockfile.Unlock() + defer r.mountsLockfile.Touch() + if err := r.saveLayers(); err != nil { + return err + } + return r.saveMounts() +} + +func (r *layerStore) saveLayers() error { if !r.IsReadWrite() { return errors.Wrapf(ErrStoreIsReadOnly, "not allowed to modify the layer store at %q", r.layerspath()) } @@ -431,13 +441,7 @@ func (r *layerStore) Save() error { return err } defer r.Touch() - if err := ioutils.AtomicWriteFile(rpath, jldata, 0600); err != nil { - return err - } - r.mountsLockfile.Lock() - defer r.mountsLockfile.Unlock() - defer r.mountsLockfile.Touch() - return r.saveMounts() + return ioutils.AtomicWriteFile(rpath, jldata, 0600) } func (r *layerStore) saveMounts() error { @@ -954,7 +958,7 @@ func (r *layerStore) tspath(id string) string { return filepath.Join(r.layerdir, id+tarSplitSuffix) } -func (r *layerStore) Delete(id string) error { +func (r *layerStore) deleteInternal(id string) error { if !r.IsReadWrite() { return errors.Wrapf(ErrStoreIsReadOnly, "not allowed to delete layers at %q", r.layerspath()) } @@ -963,23 +967,7 @@ func (r *layerStore) Delete(id string) error { return ErrLayerUnknown } id = layer.ID - // The layer may already have been explicitly unmounted, but if not, we - // should try to clean that up before we start deleting anything at the - // driver level. - mountCount, err := r.Mounted(id) - if err != nil { - return errors.Wrapf(err, "error checking if layer %q is still mounted", id) - } - for mountCount > 0 { - if _, err := r.Unmount(id, false); err != nil { - return err - } - mountCount, err = r.Mounted(id) - if err != nil { - return errors.Wrapf(err, "error checking if layer %q is still mounted", id) - } - } - err = r.driver.Remove(id) + err := r.driver.Remove(id) if err == nil { os.Remove(r.tspath(id)) delete(r.byid, id) @@ -1015,11 +1003,36 @@ func (r *layerStore) Delete(id string) error { label.ReleaseLabel(mountLabel) } } - if err = r.Save(); err != nil { + } + return err +} + +func (r *layerStore) Delete(id string) error { + layer, ok := r.lookup(id) + if !ok { + return ErrLayerUnknown + } + id = layer.ID + // The layer may already have been explicitly unmounted, but if not, we + // should try to clean that up before we start deleting anything at the + // driver level. + mountCount, err := r.Mounted(id) + if err != nil { + return errors.Wrapf(err, "error checking if layer %q is still mounted", id) + } + for mountCount > 0 { + if _, err := r.Unmount(id, false); err != nil { return err } + mountCount, err = r.Mounted(id) + if err != nil { + return errors.Wrapf(err, "error checking if layer %q is still mounted", id) + } } - return err + if err := r.deleteInternal(id); err != nil { + return err + } + return r.Save() } func (r *layerStore) Lookup(name string) (id string, err error) { diff --git a/vendor/github.com/containers/storage/store.go b/vendor/github.com/containers/storage/store.go index 74275482b..dd3405212 100644 --- a/vendor/github.com/containers/storage/store.go +++ b/vendor/github.com/containers/storage/store.go @@ -1202,7 +1202,7 @@ func (s *store) CreateContainer(id string, names []string, image, layer, metadat } } if cimage == nil { - return nil, ErrImageUnknown + return nil, errors.Wrapf(ErrImageUnknown, "error locating image with ID %q", id) } imageID = cimage.ID @@ -1437,7 +1437,7 @@ func (s *store) ListImageBigData(id string) ([]string, error) { return bigDataNames, err } } - return nil, ErrImageUnknown + return nil, errors.Wrapf(ErrImageUnknown, "error locating image with ID %q", id) } func (s *store) ImageBigDataSize(id, key string) (int64, error) { @@ -1516,7 +1516,7 @@ func (s *store) ImageBigData(id, key string) ([]byte, error) { return data, nil } } - return nil, ErrImageUnknown + return nil, errors.Wrapf(ErrImageUnknown, "error locating image with ID %q", id) } func (s *store) SetImageBigData(id, key string, data []byte, digestManifest func([]byte) (digest.Digest, error)) error { @@ -2891,7 +2891,7 @@ func (s *store) Image(id string) (*Image, error) { return image, nil } } - return nil, ErrImageUnknown + return nil, errors.Wrapf(ErrImageUnknown, "error locating image with ID %q", id) } func (s *store) ImagesByTopLayer(id string) ([]*Image, error) { @@ -2953,7 +2953,7 @@ func (s *store) ImagesByDigest(d digest.Digest) ([]*Image, error) { } } imageList, err := store.ByDigest(d) - if err != nil && err != ErrImageUnknown { + if err != nil && errors.Cause(err) != ErrImageUnknown { return nil, err } images = append(images, imageList...) |