mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 02:43:36 +00:00
rbd: set SnapshotGroupID on each Snapshot of a VolumeGroupSnapshot
Without the SnapshotGroupID in the Snapshot object, Kubernetes CSI does not know that the Snapshot belongs to a group. In that case, it allows the deletion of the Snapshot, which should be denied. Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
committed by
mergify[bot]
parent
ec1e7a4ee0
commit
cea8bf8110
@ -191,6 +191,9 @@ type rbdSnapshot struct {
|
||||
// RbdSnapName is the name of the RBD snapshot backing this rbdSnapshot
|
||||
SourceVolumeID string
|
||||
RbdSnapName string
|
||||
|
||||
// groupID is the CSI volume group ID where this snapshot belongs to
|
||||
groupID string
|
||||
}
|
||||
|
||||
// imageFeature represents required image features and value.
|
||||
@ -1054,6 +1057,15 @@ func genSnapFromSnapID(
|
||||
}
|
||||
}
|
||||
|
||||
if imageAttributes.GroupID != "" {
|
||||
rbdSnap.groupID = imageAttributes.GroupID
|
||||
// FIXME: The snapshot will have RbdImageName set to the image
|
||||
// that was used as source. This is not correct for group
|
||||
// snapshots images, and need to be fixed. See
|
||||
// rbdVolume.NewSnapshotByID() for more details.
|
||||
rbdSnap.RbdImageName = rbdSnap.RbdSnapName
|
||||
}
|
||||
|
||||
err = rbdSnap.Connect(cr)
|
||||
if err != nil {
|
||||
return rbdSnap, fmt.Errorf("failed to connect to %q: %w",
|
||||
|
Reference in New Issue
Block a user