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

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 027ed7dbad97446eec5c9d93c6754bd8635f7c2c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Tue, 20 Oct 2020 17:27:06 -0400
Subject: [PATCH 1/3] tests: Fix missing clustering cleanup
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 test/suites/clustering.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/test/suites/clustering.sh b/test/suites/clustering.sh
index 1ce7d1781b..0157dbbb2d 100644
--- a/test/suites/clustering.sh
+++ b/test/suites/clustering.sh
@@ -689,6 +689,8 @@ test_clustering_storage_single_node() {
   # Delete the storage pool
   LXD_DIR="${LXD_ONE_DIR}" lxc storage delete pool1
 
+  printf 'config: {}\ndevices: {}' | LXD_DIR="${LXD_ONE_DIR}" lxc profile edit 
default
+  LXD_DIR="${LXD_ONE_DIR}" lxc storage delete data
   LXD_DIR="${LXD_ONE_DIR}" lxd shutdown
   sleep 0.5
   rm -f "${LXD_ONE_DIR}/unix.socket"

From 39e66f7095c313d45cde5c770304f23ec7e034ed Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Tue, 20 Oct 2020 17:47:50 -0400
Subject: [PATCH 2/3] lxd/storage/zfs: Properly recurse delete volumes
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/storage/drivers/driver_zfs_utils.go   | 45 +++++++++++++++++++++++
 lxd/storage/drivers/driver_zfs_volumes.go | 37 +------------------
 2 files changed, 46 insertions(+), 36 deletions(-)

diff --git a/lxd/storage/drivers/driver_zfs_utils.go 
b/lxd/storage/drivers/driver_zfs_utils.go
index edc01f2dbb..13e59cb80f 100644
--- a/lxd/storage/drivers/driver_zfs_utils.go
+++ b/lxd/storage/drivers/driver_zfs_utils.go
@@ -81,6 +81,51 @@ func (d *zfs) checkDataset(dataset string) bool {
        return strings.TrimSpace(out) == dataset
 }
 
+func (d *zfs) deleteDatasetRecursive(dataset string) error {
+       // Locate the origin snapshot (if any).
+       origin, err := d.getDatasetProperty(dataset, "origin")
+       if err != nil {
+               return err
+       }
+
+       // Delete the dataset (and any snapshots left).
+       _, err = shared.RunCommand("zfs", "destroy", "-r", dataset)
+       if err != nil {
+               return err
+       }
+
+       // Check if the origin can now be deleted.
+       if origin != "" && origin != "-" {
+               if strings.HasPrefix(origin, 
filepath.Join(d.config["zfs.pool_name"], "deleted")) {
+                       // Strip the snapshot name when dealing with a deleted 
volume.
+                       dataset = strings.SplitN(origin, "@", 2)[0]
+               } else if strings.Contains(origin, "@deleted-") || 
strings.Contains(origin, "@copy-") {
+                       // Handle deleted snapshots.
+                       dataset = origin
+               } else {
+                       // Origin is still active.
+                       dataset = ""
+               }
+
+               if dataset != "" {
+                       // Get all clones.
+                       clones, err := d.getClones(dataset)
+                       if err != nil {
+                               return err
+                       }
+
+                       if len(clones) == 0 {
+                               // Delete the origin.
+                               err = d.deleteDatasetRecursive(dataset)
+                               if err != nil {
+                                       return err
+                               }
+                       }
+               }
+       }
+       return nil
+}
+
 func (d *zfs) getClones(dataset string) ([]string, error) {
        out, err := shared.RunCommand("zfs", "get", "-H", "-p", "-r", "-o", 
"value", "clones", dataset)
        if err != nil {
diff --git a/lxd/storage/drivers/driver_zfs_volumes.go 
b/lxd/storage/drivers/driver_zfs_volumes.go
index 57103887cf..0f06215306 100644
--- a/lxd/storage/drivers/driver_zfs_volumes.go
+++ b/lxd/storage/drivers/driver_zfs_volumes.go
@@ -736,45 +736,10 @@ func (d *zfs) DeleteVolume(vol Volume, op 
*operations.Operation) error {
                                return err
                        }
                } else {
-                       // Locate the origin snapshot (if any).
-                       origin, err := d.getDatasetProperty(d.dataset(vol, 
false), "origin")
+                       err := d.deleteDatasetRecursive(d.dataset(vol, false))
                        if err != nil {
                                return err
                        }
-
-                       // Delete the dataset (and any snapshots left).
-                       _, err = shared.RunCommand("zfs", "destroy", "-r", 
d.dataset(vol, false))
-                       if err != nil {
-                               return err
-                       }
-
-                       // Check if the origin can now be deleted.
-                       if origin != "" && origin != "-" {
-                               dataset := ""
-                               if strings.HasPrefix(origin, 
filepath.Join(d.config["zfs.pool_name"], "deleted")) {
-                                       // Strip the snapshot name when dealing 
with a deleted volume.
-                                       dataset = strings.SplitN(origin, "@", 
2)[0]
-                               } else if strings.Contains(origin, "@deleted-") 
|| strings.Contains(origin, "@copy-") {
-                                       // Handle deleted snapshots.
-                                       dataset = origin
-                               }
-
-                               if dataset != "" {
-                                       // Get all clones.
-                                       clones, err := d.getClones(dataset)
-                                       if err != nil {
-                                               return err
-                                       }
-
-                                       if len(clones) == 0 {
-                                               // Delete the origin.
-                                               _, err := 
shared.RunCommand("zfs", "destroy", "-r", dataset)
-                                               if err != nil {
-                                                       return err
-                                               }
-                                       }
-                               }
-                       }
                }
        }
 

From a4bc53da158f25e442f6c165c78ca3bf77494ef8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Tue, 20 Oct 2020 18:37:53 -0400
Subject: [PATCH 3/3] tests: Fix cleanup in backup
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 test/suites/backup.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/test/suites/backup.sh b/test/suites/backup.sh
index 11b79c10cd..0392aca437 100644
--- a/test/suites/backup.sh
+++ b/test/suites/backup.sh
@@ -622,9 +622,11 @@ test_backup_volume_export_with_project() {
   rmdir "${LXD_DIR}/non-optimized"
 
   if [ "$#" -ne 0 ]; then
-    lxc image rm testimage
     lxc project switch default
+    lxc image rm testimage --project "$project"
+    lxc image rm testimage --project "$project-b"
     lxc project delete "$project"
+    lxc project delete "$project-b"
   fi
 }
 
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to