From bbfb3a77d9e7c72f858f56050c2a9ac5f34d4f99 Mon Sep 17 00:00:00 2001 From: Praveen M Date: Mon, 9 Dec 2024 13:36:09 +0530 Subject: [PATCH] rbd: fix volumeGroup UndoReservation This commit fixes the VolumeGroup UndoReservation by using the correct RequestName of the VolumeGroup instead of the volumeGroupHandle. Signed-off-by: Praveen M (cherry picked from commit 51d0a081126a4f20081770efa678f91e47c78e38) --- internal/rbd/group/util.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/internal/rbd/group/util.go b/internal/rbd/group/util.go index 39583edf0..6dcf28e44 100644 --- a/internal/rbd/group/util.go +++ b/internal/rbd/group/util.go @@ -183,6 +183,15 @@ func (cvg *commonVolumeGroup) GetName(ctx context.Context) (string, error) { return cvg.name, nil } +// GetRequestName returns the requestName of the VolumeGroup. +func (cvg *commonVolumeGroup) GetRequestName(ctx context.Context) (string, error) { + if cvg.requestName == "" { + return "", errors.New("BUG: requestName is not set") + } + + return cvg.requestName, nil +} + // GetPool returns the name of the pool that holds the VolumeGroup. func (cvg *commonVolumeGroup) GetPool(ctx context.Context) (string, error) { if cvg.pool == "" { @@ -285,9 +294,9 @@ func (cvg *commonVolumeGroup) Delete(ctx context.Context) error { return fmt.Errorf("failed to get name for volume group %q: %w", cvg, err) } - csiID, err := cvg.GetID(ctx) + reqName, err := cvg.GetRequestName(ctx) if err != nil { - return fmt.Errorf("failed to get id for volume group %q: %w", cvg, err) + return fmt.Errorf("failed to get request name for volume group %q: %w", cvg, err) } pool, err := cvg.GetPool(ctx) @@ -300,7 +309,7 @@ func (cvg *commonVolumeGroup) Delete(ctx context.Context) error { return err } - err = j.UndoReservation(ctx, pool, name, csiID) + err = j.UndoReservation(ctx, pool, name, reqName) if err != nil /* TODO? !errors.Is(..., err) */ { return fmt.Errorf("failed to undo the reservation for volume group %q: %w", cvg, err) }