diff --git a/internal/journal/omap.go b/internal/journal/omap.go index 71c9ae5f81e6..ec8170361bd8 100644 --- a/internal/journal/omap.go +++ b/internal/journal/omap.go @@ -16,9 +16,10 @@ func getOneOMapValue( // fetch and configure the rados ioctx ioctx, err := conn.conn.GetIoctx(poolName) if err != nil { - return "", err + return "", omapPoolError(poolName, err) } defer ioctx.Destroy() + if namespace != "" { ioctx.SetNamespace(namespace) } @@ -60,7 +61,7 @@ func removeOneOMapKey( // fetch and configure the rados ioctx ioctx, err := conn.conn.GetIoctx(poolName) if err != nil { - return err + return omapPoolError(poolName, err) } defer ioctx.Destroy() @@ -88,7 +89,7 @@ func setOneOMapKey( // fetch and configure the rados ioctx ioctx, err := conn.conn.GetIoctx(poolName) if err != nil { - return err + return omapPoolError(poolName, err) } defer ioctx.Destroy() @@ -111,3 +112,10 @@ func setOneOMapKey( } return err } + +func omapPoolError(poolName string, err error) error { + if err == rados.ErrNotFound { + return util.NewErrPoolNotFound(poolName, err) + } + return err +} diff --git a/internal/util/errors.go b/internal/util/errors.go index e6ce3d11c83a..c407e5cb53b2 100644 --- a/internal/util/errors.go +++ b/internal/util/errors.go @@ -74,3 +74,7 @@ type ErrPoolNotFound struct { func (e ErrPoolNotFound) Error() string { return e.Err.Error() } + +func NewErrPoolNotFound(pool string, err error) ErrPoolNotFound { + return ErrPoolNotFound{pool, err} +}