[#51] add address to logs
Some checks failed
DCO / DCO (pull_request) Successful in 31s
Code generation / Generate proto (pull_request) Successful in 32s
Tests and linters / Tests (pull_request) Failing after 41s
Tests and linters / Lint (pull_request) Successful in 1m25s

Signed-off-by: Pavel Pogodaev <p.pogodaev@yadro.com>
This commit is contained in:
Pavel Pogodaev 2025-01-24 12:41:07 +03:00
parent 2b8329e026
commit 5f90bb7d3b
4 changed files with 13 additions and 12 deletions

View file

@ -2,6 +2,7 @@ package pool
import (
"context"
"fmt"
sdkClient "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
@ -134,7 +135,7 @@ func (it *internalTarget) putAsStream(ctx context.Context, o *object.Object) err
it.res.OID = res.StoredObjectID()
it.res.Epoch = res.StoredEpoch()
}
return err
return fmt.Errorf("put as stream '%s': %w", it.address, err)
}
func (it *internalTarget) tryPutSingle(ctx context.Context, o *object.Object) (bool, error) {
@ -151,7 +152,7 @@ func (it *internalTarget) tryPutSingle(ctx context.Context, o *object.Object) (b
res, err := it.client.ObjectPutSingle(ctx, cliPrm)
if err != nil && status.Code(err) == codes.Unimplemented {
return false, err
return false, fmt.Errorf("address '%s': %w", it.address, err)
}
if err == nil {
@ -166,5 +167,5 @@ func (it *internalTarget) tryPutSingle(ctx context.Context, o *object.Object) (b
}
return true, nil
}
return true, err
return true, fmt.Errorf("try put single '%s': %w", it.address, err)
}

View file

@ -2512,7 +2512,7 @@ func (p *Pool) initCallContext(ctx *callContext, cfg prmCommon, prmCtx prmContex
ctx.sessionObjs = prmCtx.objs
}
return err
return fmt.Errorf("initial call via client '%s' : %w", cp.address(), err)
}
// opens new session or uses cached one.
@ -2598,7 +2598,7 @@ func (p *Pool) PatchObject(ctx context.Context, prm PrmObjectPatch) (ResPatchObj
var ctxCall callContext
if err := p.initCallContext(&ctxCall, prm.prmCommon, prmCtx); err != nil {
return ResPatchObject{}, fmt.Errorf("init call context: %w", err)
return ResPatchObject{}, fmt.Errorf("patch object: %w", err)
}
if ctxCall.sessionDefault {
@ -3217,7 +3217,7 @@ func (p *Pool) GetSplitInfo(ctx context.Context, cnrID cid.ID, objID oid.ID, tok
case errors.As(err, &errSplit):
return errSplit.SplitInfo(), nil
case err == nil || errors.As(err, &errECInfo):
return nil, relations.ErrNoSplitInfo
return nil, fmt.Errorf("failed to get raw object header %w", relations.ErrNoSplitInfo)
default:
return nil, fmt.Errorf("failed to get raw object header: %w", err)
}

View file

@ -49,11 +49,11 @@ func (c *treeClient) dial(ctx context.Context) error {
var err error
c.client, err = c.createClient()
if err != nil {
return err
return fmt.Errorf("couldn't dial '%s': %w", c.address, err)
}
if _, err = rpcapi.Healthcheck(c.client, &tree.HealthcheckRequest{}, rpcclient.WithContext(ctx)); err != nil {
return fmt.Errorf("healthcheck tree service: %w", err)
return fmt.Errorf("healthcheck tree service '%s': %w", c.address, err)
}
c.healthy = true
@ -127,5 +127,5 @@ func (c *treeClient) close() error {
if c.client == nil || c.client.Conn() == nil {
return nil
}
return c.client.Conn().Close()
return fmt.Errorf("address '%s': %w", c.address, c.client.Conn().Close())
}

View file

@ -285,7 +285,7 @@ func (p *Pool) Dial(ctx context.Context) error {
for j, node := range nodes {
clients[j] = newTreeClient(node.Address(), p.dialOptions, p.nodeDialTimeout, p.streamTimeout)
if err := clients[j].dial(ctx); err != nil {
p.log(zap.WarnLevel, "failed to dial tree client", zap.String("address", node.Address()), zap.Error(err))
p.log(zap.WarnLevel, "failed to dial tree client", zap.Error(err))
continue
}
@ -1056,7 +1056,7 @@ func (p *Pool) getNewTreeClient(ctx context.Context, node netmap.NodeInfo) (*tre
newTreeCl := newTreeClient(addr.URIAddr(), p.dialOptions, p.nodeDialTimeout, p.streamTimeout)
if err = newTreeCl.dial(ctx); err != nil {
p.log(zap.WarnLevel, "failed to dial tree client", zap.String("address", addr.URIAddr()), zap.Error(err))
p.log(zap.WarnLevel, "failed to dial tree client", zap.Error(err))
// We have to close connection here after failed `dial()`.
// This is NOT necessary in object pool and regular tree pool without netmap support, because:
@ -1064,7 +1064,7 @@ func (p *Pool) getNewTreeClient(ctx context.Context, node netmap.NodeInfo) (*tre
// - regular tree pool is going to reuse connection by calling `redialIfNecessary()`.
// Tree pool with netmap support does not operate with background goroutine, so we have to close connection immediately.
if err = newTreeCl.close(); err != nil {
p.log(zap.WarnLevel, "failed to close recently dialed tree client", zap.String("address", addr.URIAddr()), zap.Error(err))
p.log(zap.WarnLevel, "failed to close recently dialed tree client", zap.Error(err))
}
return false