mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-09 16:00:22 +00:00
cleanup: return InvalidPoolID on error in GetPoolID()
InvalidPoolID has recently been added, and can be used in other location too. As GetPoolID is updated with this patch set, return InvalidPoolID on errors too. Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
parent
08144df2a8
commit
be8c3c4b72
@ -92,15 +92,15 @@ func getPools(ctx context.Context, monitors string, cr *Credentials) ([]cephStor
|
|||||||
func GetPoolID(monitors string, cr *Credentials, poolName string) (int64, error) {
|
func GetPoolID(monitors string, cr *Credentials, poolName string) (int64, error) {
|
||||||
conn, err := connPool.Get(monitors, cr.ID, cr.KeyFile)
|
conn, err := connPool.Get(monitors, cr.ID, cr.KeyFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return InvalidPoolID, err
|
||||||
}
|
}
|
||||||
defer connPool.Put(conn)
|
defer connPool.Put(conn)
|
||||||
|
|
||||||
id, err := conn.GetPoolByName(poolName)
|
id, err := conn.GetPoolByName(poolName)
|
||||||
if err == rados.ErrNotFound {
|
if err == rados.ErrNotFound {
|
||||||
return 0, ErrPoolNotFound{poolName, fmt.Errorf("pool (%s) not found in Ceph cluster", poolName)}
|
return InvalidPoolID, ErrPoolNotFound{poolName, fmt.Errorf("pool (%s) not found in Ceph cluster", poolName)}
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return 0, err
|
return InvalidPoolID, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return id, nil
|
return id, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user