The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/2222
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === Fixes #2194 Signed-off-by: Sean Christopherson <sean.j.christopher...@intel.com>
From 16015f0ab699178f206e4cc9e2c4a4b6e182d976 Mon Sep 17 00:00:00 2001 From: Sean Christopherson <sean.j.christopher...@intel.com> Date: Wed, 20 Jul 2016 10:18:48 -0700 Subject: [PATCH] Remove subvolume in zfs.ImageCreate error flow Fixes #2194 Signed-off-by: Sean Christopherson <sean.j.christopher...@intel.com> --- lxd/images.go | 2 +- lxd/storage_zfs.go | 21 +++++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/lxd/images.go b/lxd/images.go index 916b86a..95ce0f4 100644 --- a/lxd/images.go +++ b/lxd/images.go @@ -106,7 +106,7 @@ func unpack(file string, path string) error { if err != nil { shared.Debugf("Unpacking failed") shared.Debugf(string(output)) - return err + return fmt.Errorf("Unpack failed, %s.", err) } return nil diff --git a/lxd/storage_zfs.go b/lxd/storage_zfs.go index cd6ae52..e755b1a 100644 --- a/lxd/storage_zfs.go +++ b/lxd/storage_zfs.go @@ -625,22 +625,31 @@ func (s *storageZfs) ImageCreate(fingerprint string) error { return err } + cleanup := func(err error) error { + if zerr := s.zfsDestroy(fs); zerr != nil { + err = fmt.Errorf("%s During cleanup: %s", err, zerr) + } + if shared.PathExists(subvol) { + if oserr := os.Remove(subvol); oserr != nil { + err = fmt.Errorf("%s During cleanup: Failed to remove sub-volume %s, %s", err, subvol, oserr) + } + } + return err + } + err = unpackImage(imagePath, subvol) if err != nil { - s.zfsDestroy(fs) - return err + return cleanup(err) } err = s.zfsSet(fs, "readonly", "on") if err != nil { - s.zfsDestroy(fs) - return err + return cleanup(err) } err = s.zfsSnapshotCreate(fs, "readonly") if err != nil { - s.zfsDestroy(fs) - return err + return cleanup(err) } return nil
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel