The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/6247
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) === Closes #6245 Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
From 9d47bb8a695af66d4837d21cbdf234838688a395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@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 <stgra...@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@snapshot_%s",
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel