[lxc-devel] [lxd/master] lvm: fix non-thinpool container creation

brauner on Github lxc-bot at linuxcontainers.org
Thu Jul 13 09:52:09 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 381 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170713/b4fb8e34/attachment.bin>
-------------- next part --------------
From 505f183e842606e843d8896b100ed32eedebd0e6 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Thu, 13 Jul 2017 11:50:08 +0200
Subject: [PATCH 1/2] lvm: non-functional changes

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 lxd/storage_lvm.go       |  5 +++++
 lxd/storage_lvm_utils.go | 20 +++++++++++++++++++-
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/lxd/storage_lvm.go b/lxd/storage_lvm.go
index 381221ea8..6eaeafc77 100644
--- a/lxd/storage_lvm.go
+++ b/lxd/storage_lvm.go
@@ -858,8 +858,13 @@ func (s *storageLvm) ContainerCreateFromImage(container container, fingerprint s
 		err = s.containerCreateFromImageLv(container, fingerprint)
 	}
 	if err != nil {
+		logger.Errorf(`Failed to create LVM storage volume for `+
+		`container "%s" on storage pool "%s": %s`, containerName,
+			s.pool.Name, err)
 		return err
 	}
+	logger.Debugf(`Created LVM storage volume for container "%s" on `+
+		`storage pool "%s"`, containerName, s.pool.Name)
 	defer func() {
 		if tryUndo {
 			s.ContainerDelete(container)
diff --git a/lxd/storage_lvm_utils.go b/lxd/storage_lvm_utils.go
index 6def237ac..c0bb24f18 100644
--- a/lxd/storage_lvm_utils.go
+++ b/lxd/storage_lvm_utils.go
@@ -415,25 +415,43 @@ func (s *storageLvm) copyContainer(target container, source container) error {
 }
 
 func (s *storageLvm) containerCreateFromImageLv(c container, fp string) error {
+	containerName := c.Name()
+
 	err := s.ContainerCreate(c)
 	if err != nil {
+		logger.Errorf(`Failed to create non-thinpool LVM storage `+
+			`volume for container "%s" on storage pool "%s": %s`,
+			containerName, s.pool.Name, err)
 		return err
 	}
+	logger.Debugf(`Created non-thinpool LVM storage volume for container `+
+		`"%s" on storage pool "%s"`, containerName, s.pool.Name)
 
-	containerName := c.Name()
 	containerPath := c.Path()
 	_, err = s.ContainerMount(c)
 	if err != nil {
+		logger.Errorf(`Failed to mount non-thinpool LVM storage `+
+			`volume for container "%s" on storage pool "%s": %s`,
+			containerName, s.pool.Name, err)
 		return err
 	}
+	logger.Debugf(`Mounted non-thinpool LVM storage volume for container `+
+		`"%s" on storage pool "%s"`, containerName, s.pool.Name)
 
 	imagePath := shared.VarPath("images", fp)
 	poolName := s.getOnDiskPoolName()
 	containerMntPoint := getContainerMountPoint(poolName, containerName)
 	err = unpackImage(s.d, imagePath, containerMntPoint, storageTypeLvm)
 	if err != nil {
+		logger.Errorf(`Failed to unpack image "%s" into non-thinpool `+
+			`LVM storage volume "%s" for container "%s" on `+
+			`storage pool "%s": %s`, imagePath, containerMntPoint,
+			containerName, s.pool.Name, err)
 		return err
 	}
+	logger.Debugf(`Unpacked image "%s" into non-thinpool LVM storage `+
+		`volume "%s" for container "%s" on storage pool "%s"`,
+		imagePath, containerMntPoint, containerName, s.pool.Name)
 
 	s.ContainerUmount(containerName, containerPath)
 

From 12a7fd1472f9db7d55985f42e3a0297d1a093a66 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Thu, 13 Jul 2017 11:50:50 +0200
Subject: [PATCH 2/2] lvm: fix non-thinpool container creation

Closes #3543.

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 lxd/storage_lvm_utils.go | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lxd/storage_lvm_utils.go b/lxd/storage_lvm_utils.go
index c0bb24f18..148635542 100644
--- a/lxd/storage_lvm_utils.go
+++ b/lxd/storage_lvm_utils.go
@@ -439,8 +439,7 @@ func (s *storageLvm) containerCreateFromImageLv(c container, fp string) error {
 		`"%s" on storage pool "%s"`, containerName, s.pool.Name)
 
 	imagePath := shared.VarPath("images", fp)
-	poolName := s.getOnDiskPoolName()
-	containerMntPoint := getContainerMountPoint(poolName, containerName)
+	containerMntPoint := getContainerMountPoint(s.pool.Name, containerName)
 	err = unpackImage(s.d, imagePath, containerMntPoint, storageTypeLvm)
 	if err != nil {
 		logger.Errorf(`Failed to unpack image "%s" into non-thinpool `+


More information about the lxc-devel mailing list