[lxc-devel] [lxd/master] Storage fixes
stgraber on Github
lxc-bot at linuxcontainers.org
Wed Jan 8 14:56:09 UTC 2020
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/20200108/2b955031/attachment.bin>
-------------- next part --------------
From b48bf30e70ea1167c1871165150bccd4b9c41924 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 7 Jan 2020 20:05:24 -0500
Subject: [PATCH 1/2] tests: Don't leak CEPH pools
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>
---
test/suites/container_devices_disk.sh | 1 +
1 file changed, 1 insertion(+)
diff --git a/test/suites/container_devices_disk.sh b/test/suites/container_devices_disk.sh
index da5f200a61..7f80bc1ec7 100644
--- a/test/suites/container_devices_disk.sh
+++ b/test/suites/container_devices_disk.sh
@@ -112,6 +112,7 @@ test_container_devices_disk_ceph() {
lxc restart ceph-disk --force
lxc exec ceph-disk -- stat /ceph/lost+found
lxc delete -f ceph-disk
+ ceph osd pool rm "${RBD_POOL_NAME}" "${RBD_POOL_NAME}" --yes-i-really-really-mean-it
}
test_container_devices_disk_cephfs() {
From cc2223231e8f8e93fcf5118f5bad1020666dd670 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 7 Jan 2020 21:21:31 -0500
Subject: [PATCH 2/2] lxd/storage: Set contentType during image deletion
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/backend_lxd.go | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/lxd/storage/backend_lxd.go b/lxd/storage/backend_lxd.go
index e4219293da..d0d9145823 100644
--- a/lxd/storage/backend_lxd.go
+++ b/lxd/storage/backend_lxd.go
@@ -5,7 +5,6 @@ import (
"io"
"os"
"path/filepath"
- "regexp"
"strings"
"github.com/lxc/lxd/lxd/backup"
@@ -1838,18 +1837,25 @@ func (b *lxdBackend) DeleteImage(fingerprint string, op *operations.Operation) e
logger.Debug("DeleteImage started")
defer logger.Debug("DeleteImage finished")
- regexSHA256, err := regexp.Compile("^[0-9a-f]{64}$")
+ // We need to lock this operation to ensure that the image is not being
+ // deleted multiple times.
+ unlock := locking.Lock(b.name, string(drivers.VolumeTypeImage), fingerprint)
+ defer unlock()
+
+ // Load image info from database.
+ _, image, err := b.state.Cluster.ImageGetFromAnyProject(fingerprint)
if err != nil {
return err
}
- if !regexSHA256.MatchString(fingerprint) {
- return fmt.Errorf("Invalid fingerprint")
+ contentType := drivers.ContentTypeFS
+
+ // Image types are not the same as instance types, so don't use instance type constants.
+ if image.Type == "virtual-machine" {
+ contentType = drivers.ContentTypeBlock
}
- // There's no need to pass the content type or config. Both are not needed
- // when removing an image.
- vol := b.newVolume(drivers.VolumeTypeImage, "", fingerprint, nil)
+ vol := b.newVolume(drivers.VolumeTypeImage, contentType, fingerprint, nil)
err = b.driver.DeleteVolume(vol, op)
if err != nil {
More information about the lxc-devel
mailing list