[lxc-devel] [lxd/master] lvm: fix defer calls
brauner on Github
lxc-bot at linuxcontainers.org
Fri Mar 3 02:42:54 UTC 2017
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 364 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170303/25557f35/attachment.bin>
-------------- next part --------------
From 9ef4a9eb8bae7f439ac1477d2800610d2a16d803 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Fri, 3 Mar 2017 03:28:03 +0100
Subject: [PATCH] lvm: fix defer calls
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
lxd/storage_lvm.go | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/lxd/storage_lvm.go b/lxd/storage_lvm.go
index 32a6469..972bbc3 100644
--- a/lxd/storage_lvm.go
+++ b/lxd/storage_lvm.go
@@ -570,6 +570,11 @@ func (s *storageLvm) StoragePoolCreate() error {
func (s *storageLvm) StoragePoolDelete() error {
shared.LogInfof("Deleting LVM storage pool \"%s\".", s.pool.Name)
+ source := s.pool.Config["source"]
+ if source == "" {
+ return fmt.Errorf("No \"source\" property found for the storage pool.")
+ }
+
_, err := s.StoragePoolMount()
if err != nil {
return err
@@ -579,11 +584,6 @@ func (s *storageLvm) StoragePoolDelete() error {
defer func() { s.loopInfo = nil }()
}
- source := s.pool.Config["source"]
- if source == "" {
- return fmt.Errorf("No \"source\" property found for the storage pool.")
- }
-
poolName := s.getOnDiskPoolName()
// Remove the volume group.
output, err := exec.Command("vgremove", "-f", poolName).CombinedOutput()
@@ -598,9 +598,6 @@ func (s *storageLvm) StoragePoolDelete() error {
if err != nil {
shared.LogWarnf("Failed to set LO_FLAGS_AUTOCLEAR on loop device: %s. Manual cleanup needed.", err)
}
-
- defer s.loopInfo.Close()
- defer func() { s.loopInfo = nil }()
}
if filepath.IsAbs(source) {
More information about the lxc-devel
mailing list