diff options
author | Kir Kolyshkin <kolyshkin@gmail.com> | 2018-10-22 18:30:34 -0700 |
---|---|---|
committer | Kir Kolyshkin <kolyshkin@gmail.com> | 2018-12-10 20:07:02 -0800 |
commit | 65331369617e89ce54cc9be080dba70f3a883d1c (patch) | |
tree | 8833887845c71b9e92c57e7496468b84fb1095f8 /volume | |
parent | 90be078fe59a8cfeff2bcc5dc2f34a00309837b6 (diff) | |
download | docker-65331369617e89ce54cc9be080dba70f3a883d1c.tar.gz |
pkg/mount: wrap mount/umount errors
The errors returned from Mount and Unmount functions are raw
syscall.Errno errors (like EPERM or EINVAL), which provides
no context about what has happened and why.
Similar to os.PathError type, introduce mount.Error type
with some context. The error messages will now look like this:
> mount /tmp/mount-tests/source:/tmp/mount-tests/target, flags: 0x1001: operation not permitted
or
> mount tmpfs:/tmp/mount-test-source-516297835: operation not permitted
Before this patch, it was just
> operation not permitted
[v2: add Cause()]
[v3: rename MountError to Error, document Cause()]
[v4: fixes; audited all users]
[v5: make Error type private; changes after @cpuguy83 reviews]
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Diffstat (limited to 'volume')
-rw-r--r-- | volume/local/local.go | 2 | ||||
-rw-r--r-- | volume/local/local_unix.go | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/volume/local/local.go b/volume/local/local.go index 7190de9ed6..d3119cb2ff 100644 --- a/volume/local/local.go +++ b/volume/local/local.go @@ -344,7 +344,7 @@ func (v *localVolume) unmount() error { if v.opts != nil { if err := mount.Unmount(v.path); err != nil { if mounted, mErr := mount.Mounted(v.path); mounted || mErr != nil { - return errdefs.System(errors.Wrapf(err, "error while unmounting volume path '%s'", v.path)) + return errdefs.System(err) } } v.active.mounted = false diff --git a/volume/local/local_unix.go b/volume/local/local_unix.go index b1c68b931b..5ee2ed894b 100644 --- a/volume/local/local_unix.go +++ b/volume/local/local_unix.go @@ -86,7 +86,7 @@ func (v *localVolume) mount() error { } } err := mount.Mount(v.opts.MountDevice, v.path, v.opts.MountType, mountOpts) - return errors.Wrapf(err, "error while mounting volume with options: %s", v.opts) + return errors.Wrap(err, "failed to mount local volume") } func (v *localVolume) CreatedAt() (time.Time, error) { |