|
@@ -12,6 +12,8 @@ import (
|
|
"reflect"
|
|
"reflect"
|
|
"sync"
|
|
"sync"
|
|
|
|
|
|
|
|
+ "github.com/pkg/errors"
|
|
|
|
+
|
|
"github.com/Sirupsen/logrus"
|
|
"github.com/Sirupsen/logrus"
|
|
"github.com/docker/docker/pkg/idtools"
|
|
"github.com/docker/docker/pkg/idtools"
|
|
"github.com/docker/docker/pkg/mount"
|
|
"github.com/docker/docker/pkg/mount"
|
|
@@ -93,7 +95,7 @@ func New(scope string, rootUID, rootGID int) (*Root, error) {
|
|
if b, err := ioutil.ReadFile(optsFilePath); err == nil {
|
|
if b, err := ioutil.ReadFile(optsFilePath); err == nil {
|
|
opts := optsConfig{}
|
|
opts := optsConfig{}
|
|
if err := json.Unmarshal(b, &opts); err != nil {
|
|
if err := json.Unmarshal(b, &opts); err != nil {
|
|
- return nil, err
|
|
|
|
|
|
+ return nil, errors.Wrapf(err, "error while unmarshaling volume options for volume: %s", name)
|
|
}
|
|
}
|
|
// Make sure this isn't an empty optsConfig.
|
|
// Make sure this isn't an empty optsConfig.
|
|
// This could be empty due to buggy behavior in older versions of Docker.
|
|
// This could be empty due to buggy behavior in older versions of Docker.
|
|
@@ -168,7 +170,7 @@ func (r *Root) Create(name string, opts map[string]string) (volume.Volume, error
|
|
if os.IsExist(err) {
|
|
if os.IsExist(err) {
|
|
return nil, fmt.Errorf("volume already exists under %s", filepath.Dir(path))
|
|
return nil, fmt.Errorf("volume already exists under %s", filepath.Dir(path))
|
|
}
|
|
}
|
|
- return nil, err
|
|
|
|
|
|
+ return nil, errors.Wrapf(err, "error while creating volume path '%s'", path)
|
|
}
|
|
}
|
|
|
|
|
|
var err error
|
|
var err error
|
|
@@ -194,7 +196,7 @@ func (r *Root) Create(name string, opts map[string]string) (volume.Volume, error
|
|
return nil, err
|
|
return nil, err
|
|
}
|
|
}
|
|
if err = ioutil.WriteFile(filepath.Join(filepath.Dir(path), "opts.json"), b, 600); err != nil {
|
|
if err = ioutil.WriteFile(filepath.Join(filepath.Dir(path), "opts.json"), b, 600); err != nil {
|
|
- return nil, err
|
|
|
|
|
|
+ return nil, errors.Wrap(err, "error while persisting volume options")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -240,7 +242,7 @@ func removePath(path string) error {
|
|
if os.IsNotExist(err) {
|
|
if os.IsNotExist(err) {
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
- return err
|
|
|
|
|
|
+ return errors.Wrapf(err, "error removing volume path '%s'", path)
|
|
}
|
|
}
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
@@ -327,7 +329,7 @@ func (v *localVolume) Unmount(id string) error {
|
|
if v.active.count == 0 {
|
|
if v.active.count == 0 {
|
|
if err := mount.Unmount(v.path); err != nil {
|
|
if err := mount.Unmount(v.path); err != nil {
|
|
v.active.count++
|
|
v.active.count++
|
|
- return err
|
|
|
|
|
|
+ return errors.Wrapf(err, "error while unmounting volume path '%s'", v.path)
|
|
}
|
|
}
|
|
v.active.mounted = false
|
|
v.active.mounted = false
|
|
}
|
|
}
|