[lxc-devel] [lxd/master] Destroy the correct ZFS volume when deleting a container in a project

freeekanayaka on Github lxc-bot at linuxcontainers.org
Fri Oct 26 09:51:38 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 377 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20181026/ab7aa879/attachment.bin>
-------------- next part --------------
From e27c89afcde9a38c92a940df55ad7a62c3c22cf3 Mon Sep 17 00:00:00 2001
From: Free Ekanayaka <free.ekanayaka at canonical.com>
Date: Fri, 26 Oct 2018 11:49:03 +0200
Subject: [PATCH] Destroy the correct ZFS volume when deleting a container in a
 project

Signed-off-by: Free Ekanayaka <free.ekanayaka at canonical.com>
---
 lxd/storage_zfs_utils.go | 4 ++--
 test/suites/projects.sh  | 7 ++++++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/lxd/storage_zfs_utils.go b/lxd/storage_zfs_utils.go
index a4f9db62df..ab1871772a 100644
--- a/lxd/storage_zfs_utils.go
+++ b/lxd/storage_zfs_utils.go
@@ -664,8 +664,8 @@ func (s *storageZfs) doContainerDelete(project, name string) error {
 
 	poolName := s.getOnDiskPoolName()
 	containerName := name
-	fs := fmt.Sprintf("containers/%s", containerName)
-	containerPoolVolumeMntPoint := getContainerMountPoint("default", s.pool.Name, containerName)
+	fs := fmt.Sprintf("containers/%s", projectPrefix(project, containerName))
+	containerPoolVolumeMntPoint := getContainerMountPoint(project, s.pool.Name, containerName)
 
 	if zfsFilesystemEntityExists(poolName, fs) {
 		removable := true
diff --git a/test/suites/projects.sh b/test/suites/projects.sh
index a5236bd8ce..83de0547e7 100644
--- a/test/suites/projects.sh
+++ b/test/suites/projects.sh
@@ -114,7 +114,6 @@ test_projects_containers() {
   lxc start c1
   lxc list | grep c1 | grep -q RUNNING
   lxc stop --force c1
-  lxc delete c1
 
   # Delete the container
   lxc project switch foo
@@ -125,6 +124,12 @@ test_projects_containers() {
 
   # Delete the project
   lxc project delete foo
+
+  # The container in the default project can still be used
+  lxc start c1
+  lxc list | grep c1 | grep -q RUNNING
+  lxc stop --force c1
+  lxc delete c1
 }
 
 # Use snapshots in a project.


More information about the lxc-devel mailing list