mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-17 20:00:23 +00:00
rbd: return more descriptive error
updated GetVolumeByID to return more descriptive error so that caller no need to add more details in the error message. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
parent
8fa3ac9fb3
commit
a243cf52d4
@ -124,7 +124,18 @@ func (mgr *rbdManager) GetVolumeByID(ctx context.Context, id string) (types.Volu
|
||||
|
||||
volume, err := GenVolFromVolID(ctx, id, creds, mgr.secrets)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get volume from id %q: %w", id, err)
|
||||
switch {
|
||||
case errors.Is(err, ErrImageNotFound):
|
||||
err = fmt.Errorf("volume %s not found: %w", id, err)
|
||||
|
||||
return nil, err
|
||||
case errors.Is(err, util.ErrPoolNotFound):
|
||||
err = fmt.Errorf("pool %s not found for %s: %w", volume.Pool, id, err)
|
||||
|
||||
return nil, err
|
||||
default:
|
||||
return nil, fmt.Errorf("failed to get volume from id %q: %w", id, err)
|
||||
}
|
||||
}
|
||||
|
||||
return volume, nil
|
||||
|
Loading…
Reference in New Issue
Block a user