Skip to content

Commit

Permalink
rbd: prevent presetting the ImageID of a new volume
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
nixpanic committed Nov 27, 2023
1 parent 4b1dfeb commit 319aece
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion internal/rbd/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 319aece

Please sign in to comment.