rbd: use rbd.Manager within ControllerServer.DeleteVolume()

Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
Niels de Vos 2025-01-20 18:14:10 +01:00
parent 075abcac67
commit 923e1e3af5

View File

@ -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)
}