Skip to content

Commit

Permalink
rbd: fix volumeGroup UndoReservation
Browse files Browse the repository at this point in the history
This commit fixes the VolumeGroup UndoReservation
by using the correct RequestName of the VolumeGroup
instead of the volumeGroupHandle.

Signed-off-by: Praveen M <[email protected]>
(cherry picked from commit 51d0a08)
  • Loading branch information
iPraveenParihar authored and mergify[bot] committed Dec 17, 2024
1 parent fc038ea commit 4a6f355
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions internal/rbd/group/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "" {
Expand Down Expand Up @@ -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)
Expand All @@ -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)
}
Expand Down

0 comments on commit 4a6f355

Please sign in to comment.