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:
Niels de Vos
2024-10-25 17:24:50 +02:00
committed by mergify[bot]
parent ec1e7a4ee0
commit cea8bf8110
5 changed files with 52 additions and 10 deletions

View File

@ -155,6 +155,12 @@ func NewVolumeGroupSnapshot(
}
volumeMap[handle] = name
// store the CSI ID of the group in the snapshot attributes
snapErr = snapshot.SetVolumeGroup(ctx, creds, vgs.id)
if snapErr != nil {
return nil, fmt.Errorf("failed to set volume group ID %q for snapshot %q: %w", vgs.id, name, snapErr)
}
}
j, err := vgs.getJournal(ctx)