[lxc-devel] [lxd/master] Fix some pool deletion problems

stgraber on Github lxc-bot at linuxcontainers.org
Sun Sep 30 07:17:26 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180930/1fc53abb/attachment.bin>
-------------- next part --------------
From a55f1030345d7b3498d4446d1b3879d8ebf3f133 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Sun, 30 Sep 2018 09:08:51 +0200
Subject: [PATCH 1/2] storage: Fix error strings
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/storage_cgo.go | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lxd/storage_cgo.go b/lxd/storage_cgo.go
index 2a3a017491..b0a3be5a17 100644
--- a/lxd/storage_cgo.go
+++ b/lxd/storage_cgo.go
@@ -293,7 +293,7 @@ const MS_LAZYTIME uintptr = C.MS_LAZYTIME
 func prepareLoopDev(source string, flags int) (*os.File, error) {
 	cLoopDev := C.malloc(C.size_t(C.LO_NAME_SIZE))
 	if cLoopDev == nil {
-		return nil, fmt.Errorf("failed to allocate memory in C")
+		return nil, fmt.Errorf("Failed to allocate memory in C")
 	}
 	defer C.free(cLoopDev)
 
@@ -307,9 +307,9 @@ func prepareLoopDev(source string, flags int) (*os.File, error) {
 	loopFd, err := C.prepare_loop_dev(cSource, (*C.char)(cLoopDev), C.int(flags))
 	if loopFd < 0 {
 		if err != nil {
-			return nil, fmt.Errorf("failed to prepare loop device: %s", err)
+			return nil, fmt.Errorf("Failed to prepare loop device: %s", err)
 		}
-		return nil, fmt.Errorf("failed to prepare loop device")
+		return nil, fmt.Errorf("Failed to prepare loop device")
 	}
 
 	return os.NewFile(uintptr(loopFd), C.GoString((*C.char)(cLoopDev))), nil
@@ -321,7 +321,7 @@ func setAutoclearOnLoopDev(loopFd int) error {
 		if err != nil {
 			return err
 		}
-		return fmt.Errorf("failed to set LO_FLAGS_AUTOCLEAR")
+		return fmt.Errorf("Failed to set LO_FLAGS_AUTOCLEAR")
 	}
 
 	return nil
@@ -333,7 +333,7 @@ func unsetAutoclearOnLoopDev(loopFd int) error {
 		if err != nil {
 			return err
 		}
-		return fmt.Errorf("failed to unset LO_FLAGS_AUTOCLEAR")
+		return fmt.Errorf("Failed to unset LO_FLAGS_AUTOCLEAR")
 	}
 
 	return nil
@@ -342,7 +342,7 @@ func unsetAutoclearOnLoopDev(loopFd int) error {
 func loopDeviceHasBackingFile(loopDevice string, loopFile string) (*os.File, error) {
 	lidx := strings.LastIndex(loopDevice, "/")
 	if lidx < 0 {
-		return nil, fmt.Errorf("invalid loop device path: \"%s\"", loopDevice)
+		return nil, fmt.Errorf("Invalid loop device path: \"%s\"", loopDevice)
 	}
 
 	loopName := loopDevice[(lidx + 1):]

From 7f5c5cdb79b61cd71199b9aa3a587bc5932a0f4f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Sun, 30 Sep 2018 09:12:00 +0200
Subject: [PATCH 2/2] lxd/storage/btrfs: Don't fail deleting pools on misisng
 disk
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #5088

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/storage_btrfs.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lxd/storage_btrfs.go b/lxd/storage_btrfs.go
index b057374919..49dc007f97 100644
--- a/lxd/storage_btrfs.go
+++ b/lxd/storage_btrfs.go
@@ -339,7 +339,7 @@ func (s *storageBtrfs) StoragePoolDelete() error {
 				err = btrfsSubVolumesDelete(source)
 			}
 		}
-		if err != nil {
+		if err != nil && !os.IsNotExist(err) {
 			return err
 		}
 	}


More information about the lxc-devel mailing list