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:
Niels de Vos 2020-05-14 14:28:55 +02:00 committed by mergify[bot]
parent 08144df2a8
commit be8c3c4b72

View File

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