[#195] services/object: Write debug log messages on internal service errors

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-11-23 14:51:02 +03:00 committed by Alex Vanin
parent 6a5c37d592
commit fa6e4a3ca4
7 changed files with 41 additions and 14 deletions

View file

@ -6,7 +6,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/core/netmap" "github.com/nspcc-dev/neofs-node/pkg/core/netmap"
"github.com/nspcc-dev/neofs-node/pkg/network" "github.com/nspcc-dev/neofs-node/pkg/network"
"github.com/nspcc-dev/neofs-node/pkg/services/object/util" svcutil "github.com/nspcc-dev/neofs-node/pkg/services/object/util"
"github.com/nspcc-dev/neofs-node/pkg/services/object_manager/placement" "github.com/nspcc-dev/neofs-node/pkg/services/object_manager/placement"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@ -62,7 +62,7 @@ func (h *distributedHeader) prepare(ctx context.Context, prm *Prm) error {
if prm.common.LocalOnly() { if prm.common.LocalOnly() {
// use local-only placement builder // use local-only placement builder
builder = util.NewLocalPlacement(builder, h.localAddrSrc) builder = svcutil.NewLocalPlacement(builder, h.localAddrSrc)
} }
// set placement builder // set placement builder
@ -106,7 +106,7 @@ loop:
if network.IsLocalAddress(h.localAddrSrc, addr) { if network.IsLocalAddress(h.localAddrSrc, addr) {
if err := h.localHeader.head(ctx, prm, h.w.write); err != nil { if err := h.localHeader.head(ctx, prm, h.w.write); err != nil {
// TODO: log error svcutil.LogServiceError(h.log, "HEAD", addr, err)
} }
return return
@ -117,7 +117,8 @@ loop:
node: addr, node: addr,
}) })
if err != nil { if err != nil {
// TODO: log error svcutil.LogServiceError(h.log, "HEAD", addr, err)
return return
} }

View file

@ -5,9 +5,11 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/core/object" "github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/network" "github.com/nspcc-dev/neofs-node/pkg/network"
svcutil "github.com/nspcc-dev/neofs-node/pkg/services/object/util"
"github.com/nspcc-dev/neofs-node/pkg/services/object_manager/placement" "github.com/nspcc-dev/neofs-node/pkg/services/object_manager/placement"
"github.com/nspcc-dev/neofs-node/pkg/services/object_manager/transformer" "github.com/nspcc-dev/neofs-node/pkg/services/object_manager/transformer"
"github.com/nspcc-dev/neofs-node/pkg/util" "github.com/nspcc-dev/neofs-node/pkg/util"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@ -23,6 +25,8 @@ type distributedTarget struct {
nodeTargetInitializer func(*network.Address) transformer.ObjectTarget nodeTargetInitializer func(*network.Address) transformer.ObjectTarget
fmt *object.FormatValidator fmt *object.FormatValidator
log *logger.Logger
} }
var errIncompletePut = errors.New("incomplete object put") var errIncompletePut = errors.New("incomplete object put")
@ -85,10 +89,14 @@ loop:
target := t.nodeTargetInitializer(addr) target := t.nodeTargetInitializer(addr)
if err := target.WriteHeader(t.obj); err != nil { if err := target.WriteHeader(t.obj); err != nil {
// TODO: log error svcutil.LogServiceError(t.log, "PUT", addr,
errors.Wrap(err, "could not write header"))
return return
} else if _, err := target.Close(); err != nil { } else if _, err := target.Close(); err != nil {
// TODO: log error svcutil.LogServiceError(t.log, "PUT", addr,
errors.Wrap(err, "could not close object stream"))
return return
} }

View file

@ -148,6 +148,7 @@ func (p *Streamer) newCommonTarget(prm *PutInitPrm) transformer.ObjectTarget {
} }
}, },
fmt: p.fmtValidator, fmt: p.fmtValidator,
log: p.log,
} }
} }

View file

@ -8,7 +8,7 @@ import (
"github.com/nspcc-dev/neofs-api-go/pkg/object" "github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/nspcc-dev/neofs-node/pkg/core/netmap" "github.com/nspcc-dev/neofs-node/pkg/core/netmap"
"github.com/nspcc-dev/neofs-node/pkg/network" "github.com/nspcc-dev/neofs-node/pkg/network"
"github.com/nspcc-dev/neofs-node/pkg/services/object/util" svcutil "github.com/nspcc-dev/neofs-node/pkg/services/object/util"
"github.com/nspcc-dev/neofs-node/pkg/services/object_manager/placement" "github.com/nspcc-dev/neofs-node/pkg/services/object_manager/placement"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@ -28,7 +28,7 @@ type streamer struct {
traverser *placement.Traverser traverser *placement.Traverser
rangeTraverser *util.RangeTraverser rangeTraverser *svcutil.RangeTraverser
ch chan []byte ch chan []byte
} }
@ -106,7 +106,7 @@ func (p *streamer) switchToObject(id *object.ID) error {
if p.prm.common.LocalOnly() { if p.prm.common.LocalOnly() {
// use local-only placement builder // use local-only placement builder
builder = util.NewLocalPlacement(builder, p.localAddrSrc) builder = svcutil.NewLocalPlacement(builder, p.localAddrSrc)
} }
// set placement builder // set placement builder
@ -194,7 +194,7 @@ loop:
ch: p.ch, ch: p.ch,
}) })
if err != nil { if err != nil {
// TODO: log error svcutil.LogServiceError(p.log, "RANGE", addr, err)
} }
ln := nextRange.GetLength() ln := nextRange.GetLength()

View file

@ -6,7 +6,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/core/netmap" "github.com/nspcc-dev/neofs-node/pkg/core/netmap"
"github.com/nspcc-dev/neofs-node/pkg/network" "github.com/nspcc-dev/neofs-node/pkg/network"
"github.com/nspcc-dev/neofs-node/pkg/services/object/util" svcutil "github.com/nspcc-dev/neofs-node/pkg/services/object/util"
"github.com/nspcc-dev/neofs-node/pkg/services/object_manager/placement" "github.com/nspcc-dev/neofs-node/pkg/services/object_manager/placement"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@ -60,7 +60,7 @@ func (h *distributedHasher) prepare(ctx context.Context, prm *Prm) error {
if prm.common.LocalOnly() { if prm.common.LocalOnly() {
// use local-only placement builder // use local-only placement builder
builder = util.NewLocalPlacement(builder, h.localAddrSrc) builder = svcutil.NewLocalPlacement(builder, h.localAddrSrc)
} }
// set placement builder // set placement builder
@ -119,7 +119,8 @@ loop:
} }
if err := hasher.hashRange(ctx, prm, w.write); err != nil { if err := hasher.hashRange(ctx, prm, w.write); err != nil {
// TODO: log error svcutil.LogServiceError(h.log, "RANGEHASH", addr, err)
return return
} }
}); err != nil { }); err != nil {

View file

@ -169,7 +169,7 @@ loop:
} }
if err := streamer.stream(p.ctx, p.ch); err != nil { if err := streamer.stream(p.ctx, p.ch); err != nil {
// TODO: log error util.LogServiceError(p.log, "SEARCH", addr, err)
} }
}); err != nil { }); err != nil {
wg.Done() wg.Done()

View file

@ -0,0 +1,16 @@
package util
import (
"github.com/nspcc-dev/neofs-node/pkg/network"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"go.uber.org/zap"
)
// LogServiceError writes debug error message of object service to provided logger.
func LogServiceError(l *logger.Logger, req string, node *network.Address, err error) {
l.Debug("object service error",
zap.Stringer("node", node),
zap.String("request", req),
zap.String("error", err.Error()),
)
}