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 <ndevos@ibm.com>
This commit is contained in:
Niels de Vos 2023-11-15 10:04:43 +01:00
parent a228b14200
commit 58573a1d14

View File

@ -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.