Skip to content

Commit

Permalink
rbd: use rbd.Manager within ControllerServer.DeleteVolume()
Browse files Browse the repository at this point in the history
Signed-off-by: Niels de Vos <[email protected]>
  • Loading branch information
nixpanic committed Jan 22, 2025
1 parent 649e16b commit dc15f2f
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions internal/rbd/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -957,12 +957,17 @@ func (cs *ControllerServer) DeleteVolume(
return &csi.DeleteVolumeResponse{}, nil
}

rbdVol, err := GenVolFromVolID(ctx, volumeID, cr, req.GetSecrets())
defer func() {
if rbdVol != nil {
rbdVol.Destroy(ctx)
}
}()
mgr := NewManager(cs.Driver.GetInstanceID(), nil, req.GetSecrets())
defer mgr.Destroy(ctx)

vol, err := mgr.GetVolumeByID(ctx, volumeID)
if vol != nil {
defer vol.Destroy(ctx)
}
rbdVol, ok := vol.(*rbdVolume) // FIXME: temporary cast until rbdVolume is cleaned up
if !ok {
return nil, status.Error(codes.Internal, "BUG: failed to cast Volume to rbdVolume")
}
if err != nil {
return cs.checkErrAndUndoReserve(ctx, err, volumeID, rbdVol, cr)
}
Expand Down

0 comments on commit dc15f2f

Please sign in to comment.