Commit f7d55fef authored by Urvashi Mohnani's avatar Urvashi Mohnani

Vendor c/storage v1.13.3

Pull in fixes to avoid doule locking the mounts list when
doing a save or cleanup.
Signed-off-by: default avatarUrvashi Mohnani <[email protected]>
parent 6a84189d
......@@ -16,7 +16,7 @@ require (
github.com/containers/buildah v1.10.1
github.com/containers/image v3.0.2+incompatible
github.com/containers/libpod v1.5.0
github.com/containers/storage v1.13.2
github.com/containers/storage v1.13.3
github.com/coreos/go-systemd v0.0.0-20190620071333-e64a0ec8b42a
github.com/cpuguy83/go-md2man v1.0.10
github.com/cri-o/ocicni v0.1.1-0.20190702175919-7762645d18ca
......
export GO111MODULE=off
export GOPROXY=https://proxy.golang.org
.PHONY: \
all \
......
......@@ -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 {
......
......@@ -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) {
......
......@@ -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...)
......
......@@ -163,7 +163,7 @@ github.com/containers/psgo/internal/dev
github.com/containers/psgo/internal/proc
github.com/containers/psgo/internal/process
github.com/containers/psgo/internal/host
# github.com/containers/storage v1.13.2
# github.com/containers/storage v1.13.3
github.com/containers/storage/pkg/reexec
github.com/containers/storage
github.com/containers/storage/pkg/idtools
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment