graphdriver: change (*Driver).Put signature

There are a couple of drivers that swallow errors that may occur in
their Put() implementation.

This changes the signature of (*Driver).Put for all the drivers implemented.

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
Upstream-commit: 00fd63e55807c36fedf0878645dfec995fba381d
Component: engine
This commit is contained in:
Vincent Batts
2015-01-12 13:34:35 -05:00
parent 7bde3c37f9
commit 0e444dd64f
6 changed files with 19 additions and 12 deletions
@@ -278,7 +278,7 @@ func (a *Driver) Get(id, mountLabel string) (string, error) {
return out, nil
}
func (a *Driver) Put(id string) {
func (a *Driver) Put(id string) error {
// Protect the a.active from concurrent access
a.Lock()
defer a.Unlock()
@@ -293,6 +293,7 @@ func (a *Driver) Put(id string) {
}
delete(a.active, id)
}
return nil
}
// Diff produces an archive of the changes between the specified
@@ -220,9 +220,10 @@ func (d *Driver) Get(id, mountLabel string) (string, error) {
return dir, nil
}
func (d *Driver) Put(id string) {
func (d *Driver) Put(id string) error {
// Get() creates no runtime resources (like e.g. mounts)
// so this doesn't need to do anything.
return nil
}
func (d *Driver) Exists(id string) bool {
@@ -141,10 +141,12 @@ func (d *Driver) Get(id, mountLabel string) (string, error) {
return rootFs, nil
}
func (d *Driver) Put(id string) {
if err := d.DeviceSet.UnmountDevice(id); err != nil {
func (d *Driver) Put(id string) error {
err := d.DeviceSet.UnmountDevice(id)
if err != nil {
log.Errorf("Warning: error unmounting device %s: %s", id, err)
}
return err
}
func (d *Driver) Exists(id string) bool {
@@ -40,7 +40,7 @@ type ProtoDriver interface {
Get(id, mountLabel string) (dir string, err error)
// Put releases the system resources for the specified id,
// e.g, unmounting layered filesystem.
Put(id string)
Put(id string) error
// Exists returns whether a filesystem layer with the specified
// ID exists on this driver.
Exists(id string) bool
@@ -299,7 +299,7 @@ func (d *Driver) Get(id string, mountLabel string) (string, error) {
return mount.path, nil
}
func (d *Driver) Put(id string) {
func (d *Driver) Put(id string) error {
// Protect the d.active from concurrent access
d.Lock()
defer d.Unlock()
@@ -307,21 +307,23 @@ func (d *Driver) Put(id string) {
mount := d.active[id]
if mount == nil {
log.Debugf("Put on a non-mounted device %s", id)
return
return nil
}
mount.count--
if mount.count > 0 {
return
return nil
}
defer delete(d.active, id)
if mount.mounted {
if err := syscall.Unmount(mount.path, 0); err != nil {
err := syscall.Unmount(mount.path, 0)
if err != nil {
log.Debugf("Failed to unmount %s overlay: %v", id, err)
}
return err
}
delete(d.active, id)
return nil
}
func (d *Driver) ApplyDiff(id string, parent string, diff archive.ArchiveReader) (size int64, err error) {
@@ -83,9 +83,10 @@ func (d *Driver) Get(id, mountLabel string) (string, error) {
return dir, nil
}
func (d *Driver) Put(id string) {
func (d *Driver) Put(id string) error {
// The vfs driver has no runtime resources (e.g. mounts)
// to clean up, so we don't need anything here
return nil
}
func (d *Driver) Exists(id string) bool {