[lxc-devel] [lxd/master] lxd/storage/drivers/ceph: Re-create image snapshot

monstermunchkin on Github lxc-bot at linuxcontainers.org
Mon Mar 30 10:36:26 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 355 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200330/82388b56/attachment.bin>
-------------- next part --------------
From fca52bbac419b1d1c17d98ed45a3fc530b86af6b Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.hipp at canonical.com>
Date: Mon, 30 Mar 2020 12:31:03 +0200
Subject: [PATCH] lxd/storage/drivers/ceph: Re-create image snapshot

Signed-off-by: Thomas Hipp <thomas.hipp at canonical.com>
---
 lxd/storage/drivers/driver_ceph_volumes.go | 27 ++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/lxd/storage/drivers/driver_ceph_volumes.go b/lxd/storage/drivers/driver_ceph_volumes.go
index fa967dbcdb..562093a5b6 100644
--- a/lxd/storage/drivers/driver_ceph_volumes.go
+++ b/lxd/storage/drivers/driver_ceph_volumes.go
@@ -175,6 +175,33 @@ func (d *ceph) CreateVolume(vol Volume, filler *VolumeFiller, op *operations.Ope
 		if err != nil {
 			return err
 		}
+
+		if vol.contentType == ContentTypeBlock {
+			// Re-create the readonly snapshot, post-filling.
+			fsVol := NewVolume(d, d.name, vol.volType, ContentTypeFS, vol.name, vol.config, vol.poolConfig)
+
+			err := d.rbdUnprotectVolumeSnapshot(fsVol, "readonly")
+			if err != nil {
+				return err
+			}
+
+			_, err = d.deleteVolumeSnapshot(fsVol, "readonly")
+			if err != nil {
+				return err
+			}
+
+			err = d.rbdCreateVolumeSnapshot(fsVol, "readonly")
+			if err != nil {
+				return err
+			}
+
+			revert.Add(func() { d.deleteVolumeSnapshot(fsVol, "readonly") })
+
+			err = d.rbdProtectVolumeSnapshot(fsVol, "readonly")
+			if err != nil {
+				return err
+			}
+		}
 	}
 
 	revert.Success()


More information about the lxc-devel mailing list