mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 02:33:34 +00:00
cleanup: address err113 warnings about direct error comparisons
Several places in the code compared errors directly with the go-ceph sentinel errors. This change uses the errors.Is() function of go 1.13 instead. The err113 linter reported this issue as: err113: do not compare errors directly, use errors.Is() instead Signed-off-by: Sven Anderson <sven@redhat.com>
This commit is contained in:
committed by
mergify[bot]
parent
7affb9289d
commit
de74c36d8c
@ -18,6 +18,7 @@ package journal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/ceph/ceph-csi/internal/util"
|
||||
|
||||
@ -60,14 +61,13 @@ func getOMapValues(
|
||||
}
|
||||
},
|
||||
)
|
||||
switch err {
|
||||
case nil:
|
||||
case rados.ErrNotFound:
|
||||
klog.Errorf(
|
||||
util.Log(ctx, "omap not found (pool=%q, namespace=%q, name=%q): %v"),
|
||||
poolName, namespace, oid, err)
|
||||
return nil, util.NewErrKeyNotFound(oid, err)
|
||||
default:
|
||||
if err != nil {
|
||||
if errors.Is(err, rados.ErrNotFound) {
|
||||
klog.Errorf(
|
||||
util.Log(ctx, "omap not found (pool=%q, namespace=%q, name=%q): %v"),
|
||||
poolName, namespace, oid, err)
|
||||
return nil, util.NewErrKeyNotFound(oid, err)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -93,20 +93,20 @@ func removeMapKeys(
|
||||
}
|
||||
|
||||
err = ioctx.RmOmapKeys(oid, keys)
|
||||
switch err {
|
||||
case nil:
|
||||
case rados.ErrNotFound:
|
||||
// the previous implementation of removing omap keys (via the cli)
|
||||
// treated failure to find the omap as a non-error. Do so here to
|
||||
// mimic the previous behavior.
|
||||
klog.V(4).Infof(
|
||||
util.Log(ctx, "when removing omap keys, omap not found (pool=%q, namespace=%q, name=%q): %+v"),
|
||||
poolName, namespace, oid, keys)
|
||||
default:
|
||||
klog.Errorf(
|
||||
util.Log(ctx, "failed removing omap keys (pool=%q, namespace=%q, name=%q): %v"),
|
||||
poolName, namespace, oid, err)
|
||||
return err
|
||||
if err != nil {
|
||||
if errors.Is(err, rados.ErrNotFound) {
|
||||
// the previous implementation of removing omap keys (via the cli)
|
||||
// treated failure to find the omap as a non-error. Do so here to
|
||||
// mimic the previous behavior.
|
||||
klog.V(4).Infof(
|
||||
util.Log(ctx, "when removing omap keys, omap not found (pool=%q, namespace=%q, name=%q): %+v"),
|
||||
poolName, namespace, oid, keys)
|
||||
} else {
|
||||
klog.Errorf(
|
||||
util.Log(ctx, "failed removing omap keys (pool=%q, namespace=%q, name=%q): %v"),
|
||||
poolName, namespace, oid, err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
klog.V(4).Infof(
|
||||
util.Log(ctx, "removed omap keys (pool=%q, namespace=%q, name=%q): %+v"),
|
||||
@ -147,7 +147,7 @@ func setOMapKeys(
|
||||
}
|
||||
|
||||
func omapPoolError(poolName string, err error) error {
|
||||
if err == rados.ErrNotFound {
|
||||
if errors.Is(err, rados.ErrNotFound) {
|
||||
return util.NewErrPoolNotFound(poolName, err)
|
||||
}
|
||||
return err
|
||||
|
Reference in New Issue
Block a user