The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/5470

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) ===

From 7f7ae818c6b0914965c512bf0dfdb9bac5668b78 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Wed, 6 Feb 2019 19:48:58 -0500
Subject: [PATCH 1/4] lxd/storage/ceph: Unmap volume after creation
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #5421

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 lxd/storage_ceph.go | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/lxd/storage_ceph.go b/lxd/storage_ceph.go
index 8158e7a1dc..944ec1bc83 100644
--- a/lxd/storage_ceph.go
+++ b/lxd/storage_ceph.go
@@ -380,10 +380,6 @@ func (s *storageCeph) StoragePoolVolumeCreate() error {
                s.volume.Name, s.pool.Name)
 
        defer func() {
-               if !revert {
-                       return
-               }
-
                err := cephRBDVolumeUnmap(s.ClusterName, s.OSDPoolName,
                        s.volume.Name, storagePoolVolumeTypeNameCustom,
                        s.UserName, true)

From 39d569e5242795f1e836daf45d37e3ec5a556670 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Wed, 6 Feb 2019 20:02:53 -0500
Subject: [PATCH 2/4] lxd/storage/ceph: Create custom mountpoints if missing
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #5421

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 lxd/storage_ceph.go | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lxd/storage_ceph.go b/lxd/storage_ceph.go
index 944ec1bc83..e9c1efa7fc 100644
--- a/lxd/storage_ceph.go
+++ b/lxd/storage_ceph.go
@@ -519,6 +519,13 @@ func (s *storageCeph) StoragePoolVolumeMount() (bool, 
error) {
        ourMount := false
        RBDDevPath := ""
        if !shared.IsMountPoint(volumeMntPoint) {
+               if !shared.PathExists(volumeMntPoint) {
+                       err := os.MkdirAll(volumeMntPoint, 0711)
+                       if err != nil {
+                               return false, err
+                       }
+               }
+
                RBDDevPath, ret = getRBDMappedDevPath(s.ClusterName, 
s.OSDPoolName,
                        storagePoolVolumeTypeNameCustom, s.volume.Name, true,
                        s.UserName)

From 27a60f7d1a609ae375cf3289e3424885b7942aff Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Wed, 6 Feb 2019 21:19:04 -0500
Subject: [PATCH 3/4] lxd/containers: Call storage unmount on detach
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 lxd/container_lxc.go | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index d9e6174146..d4bc9fd5d2 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -8219,6 +8219,19 @@ func (c *containerLXC) removeDiskDevice(name string, m 
types.Device) error {
                return err
        }
 
+       // Check if pool-specific action should be taken
+       if m["pool"] != "" {
+               s, err := storagePoolVolumeInit(c.state, "default", m["pool"], 
m["source"], storagePoolVolumeTypeCustom)
+               if err != nil {
+                       return err
+               }
+
+               _, err = s.StoragePoolVolumeUmount()
+               if err != nil {
+                       return err
+               }
+       }
+
        // Remove the host side
        err = os.Remove(devPath)
        if err != nil {

From bcc7aee9c8cf1f8ed31f0957622c4296ec70a2b2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Wed, 6 Feb 2019 21:18:48 -0500
Subject: [PATCH 4/4] lxd/storage/ceph: Unmap on unmount
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #5421

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 lxd/storage_ceph.go | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/lxd/storage_ceph.go b/lxd/storage_ceph.go
index e9c1efa7fc..dd7323871c 100644
--- a/lxd/storage_ceph.go
+++ b/lxd/storage_ceph.go
@@ -583,7 +583,6 @@ func (s *storageCeph) StoragePoolVolumeUmount() (bool, 
error) {
        if shared.IsMountPoint(volumeMntPoint) {
                customerr = tryUnmount(volumeMntPoint, syscall.MNT_DETACH)
                ourUmount = true
-               logger.Debugf(`Path "%s" is a mountpoint for RBD storage volume 
"%s" on storage pool "%s"`, volumeMntPoint, s.volume.Name, s.pool.Name)
        }
 
        lxdStorageMapLock.Lock()
@@ -598,6 +597,17 @@ func (s *storageCeph) StoragePoolVolumeUmount() (bool, 
error) {
                return false, customerr
        }
 
+       if ourUmount {
+               // Attempt to unmap
+               err := cephRBDVolumeUnmap(s.ClusterName, s.OSDPoolName,
+                       s.volume.Name, storagePoolVolumeTypeNameCustom,
+                       s.UserName, true)
+               if err != nil {
+                       logger.Errorf(`Failed to unmap RBD storage volume for 
container "%s" on storage pool "%s": %s`, s.volume.Name, s.pool.Name, err)
+                       return ourUmount, err
+               }
+       }
+
        logger.Debugf(`Unmounted RBD storage volume "%s" on storage pool "%s"`,
                s.volume.Name, s.pool.Name)
        return ourUmount, nil
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to