[lxc-devel] [lxd/master] lxd/storage/ceph: Fix volume snapshot handling
stgraber on Github
lxc-bot at linuxcontainers.org
Thu Sep 26 18:18:25 UTC 2019
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 370 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190926/937bca6d/attachment-0001.bin>
-------------- next part --------------
From 9d47bb8a695af66d4837d21cbdf234838688a395 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Thu, 26 Sep 2019 14:14:27 -0400
Subject: [PATCH] lxd/storage/ceph: Fix volume snapshot handling
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Closes #6245
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
lxd/storage_ceph.go | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/lxd/storage_ceph.go b/lxd/storage_ceph.go
index 0abd661940..6a15cfd92e 100644
--- a/lxd/storage_ceph.go
+++ b/lxd/storage_ceph.go
@@ -2521,11 +2521,18 @@ func (s *storageCeph) StoragePoolVolumeCopy(source *api.StorageVolumeSource) err
return s.doCrossPoolVolumeCopy(source)
}
- snapshots, err := cephRBDVolumeListSnapshots(s.ClusterName, s.OSDPoolName, source.Name, storagePoolVolumeTypeNameCustom, s.UserName)
- if err != nil {
+ rbdSnapshots, err := cephRBDVolumeListSnapshots(s.ClusterName, s.OSDPoolName, source.Name, storagePoolVolumeTypeNameCustom, s.UserName)
+ if err != nil && err != db.ErrNoSuchObject {
return err
}
+ snapshots := []string{}
+ for _, name := range rbdSnapshots {
+ if strings.HasPrefix(name, "snapshot_") {
+ snapshots = append(snapshots, name)
+ }
+ }
+
if source.VolumeOnly || len(snapshots) == 0 {
if s.pool.Config["ceph.rbd.clone_copy"] != "" && !shared.IsTrue(s.pool.Config["ceph.rbd.clone_copy"]) {
err = s.copyVolumeWithoutSnapshotsFull(source)
@@ -2594,11 +2601,11 @@ func (s *storageCeph) StoragePoolVolumeCopy(source *api.StorageVolumeSource) err
for i, snap := range snapshots {
prev := ""
if i > 0 {
- _, snapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(snapshots[i-1])
+ snapOnlyName := strings.SplitN(snapshots[i-1], "snapshot_", 2)[1]
prev = fmt.Sprintf("snapshot_%s", snapOnlyName)
}
- _, snapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(snap)
+ snapOnlyName := strings.SplitN(snap, "snapshot_", 2)[1]
lastSnap = fmt.Sprintf("snapshot_%s", snapOnlyName)
sourceVolumeName := fmt.Sprintf(
"%s/custom_%s at snapshot_%s",
More information about the lxc-devel
mailing list