From 58573a1d1440bdac7a6e01356526358b09a1625c Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Wed, 15 Nov 2023 10:04:43 +0100 Subject: [PATCH] rbd: prevent presetting the ImageID of a new volume When a new volume is not created yet, the ImageID should not be set to the ID of the snapshot. Signed-off-by: Niels de Vos --- internal/rbd/snapshot.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/rbd/snapshot.go b/internal/rbd/snapshot.go index bb420475c3d..92823e40ef9 100644 --- a/internal/rbd/snapshot.go +++ b/internal/rbd/snapshot.go @@ -107,7 +107,15 @@ func generateVolFromSnap(rbdSnap *rbdSnapshot) *rbdVolume { vol.JournalPool = rbdSnap.JournalPool vol.RadosNamespace = rbdSnap.RadosNamespace vol.RbdImageName = rbdSnap.RbdSnapName - vol.ImageID = rbdSnap.ImageID + + // /!\ WARNING /!\ + // + // Do not set the ImageID to the ID of the snapshot, a new image will + // be created based on the returned rbdVolume. If the ImageID is set to + // the ID of the snapshot, accessing the new image by ID will actually + // access the snapshot! + // vol.ImageID = rbdSnap.ImageID + // copyEncryptionConfig cannot be used here because the volume and the // snapshot will have the same volumeID which cases the panic in // copyEncryptionConfig function.