rbd: replace Manager.DeleteVolumeGroup() by VolumeGroup.Delete()

There is no need for the `Manager.DeleteVolumeGroup()` function as
`VolumeGroup.Delete()` should cover everything too.

By moving the `.Delete()` functionality of removing the group from the
journal to the shared `commonVolumeGroup` type, a volume group snaphot
can use it as well.

Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
Niels de Vos
2024-09-17 14:07:19 +02:00
committed by mergify[bot]
parent 01a0ec2d8c
commit f2bc1c674b
5 changed files with 27 additions and 47 deletions

View File

@ -233,6 +233,31 @@ func (cvg *commonVolumeGroup) GetIOContext(ctx context.Context) (*rados.IOContex
return ioctx, nil
}
// Delete removes the volume group from the journal.
func (cvg *commonVolumeGroup) Delete(ctx context.Context) error {
name, err := cvg.GetName(ctx)
if err != nil {
return fmt.Errorf("failed to get name for volume group %q: %w", cvg, err)
}
csiID, err := cvg.GetID(ctx)
if err != nil {
return fmt.Errorf("failed to get id for volume group %q: %w", cvg, err)
}
pool, err := cvg.GetPool(ctx)
if err != nil {
return fmt.Errorf("failed to get pool for volume group %q: %w", cvg, err)
}
err = cvg.journal.UndoReservation(ctx, pool, name, csiID)
if err != nil /* TODO? !errors.Is(..., err) */ {
return fmt.Errorf("failed to undo the reservation for volume group %q: %w", cvg, err)
}
return nil
}
// GetCreationTime fetches the creation time of the volume group from the
// journal and returns it.
func (cvg *commonVolumeGroup) GetCreationTime(ctx context.Context) (*time.Time, error) {