[#51] add address to logs
All checks were successful
DCO / DCO (pull_request) Successful in 30s
Code generation / Generate proto (pull_request) Successful in 39s
Tests and linters / Lint (pull_request) Successful in 1m50s
Tests and linters / Tests (pull_request) Successful in 50s

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 593dd77d84
commit 5f110ec850
3 changed files with 33 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"
@ -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

@ -3197,6 +3197,10 @@ func (p *Pool) GetSplitInfo(ctx context.Context, cnrID cid.ID, objID oid.ID, tok
var addr oid.Address
addr.SetContainer(cnrID)
addr.SetObject(objID)
cp, err := p.connection()
if err != nil {
return nil, err
}
var prm PrmObjectHead
prm.SetAddress(addr)
@ -3208,7 +3212,7 @@ func (p *Pool) GetSplitInfo(ctx context.Context, cnrID cid.ID, objID oid.ID, tok
}
prm.MarkRaw()
_, err := p.HeadObject(ctx, prm)
_, err = p.HeadObject(ctx, prm)
var errSplit *object.SplitInfoError
var errECInfo *object.ECInfoError
@ -3217,7 +3221,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 via client %s %w", cp.address(), relations.ErrNoSplitInfo)
default:
return nil, fmt.Errorf("failed to get raw object header: %w", err)
}
@ -3228,6 +3232,10 @@ func (p *Pool) ListChildrenByLinker(ctx context.Context, cnrID cid.ID, objID oid
var addr oid.Address
addr.SetContainer(cnrID)
addr.SetObject(objID)
cp, err := p.connection()
if err != nil {
return nil, err
}
var prm PrmObjectHead
prm.SetAddress(addr)
@ -3240,7 +3248,7 @@ func (p *Pool) ListChildrenByLinker(ctx context.Context, cnrID cid.ID, objID oid
res, err := p.HeadObject(ctx, prm)
if err != nil {
return nil, fmt.Errorf("failed to get linking object's header: %w", err)
return nil, fmt.Errorf("failed to get linking object's header by addr: %s %w", cp.address(), err)
}
return res.Children(), nil
@ -3251,6 +3259,10 @@ func (p *Pool) GetLeftSibling(ctx context.Context, cnrID cid.ID, objID oid.ID, t
var addr oid.Address
addr.SetContainer(cnrID)
addr.SetObject(objID)
cp, err := p.connection()
if err != nil {
return oid.ID{}, err
}
var prm PrmObjectHead
prm.SetAddress(addr)
@ -3268,7 +3280,7 @@ func (p *Pool) GetLeftSibling(ctx context.Context, cnrID cid.ID, objID oid.ID, t
idMember, ok := res.PreviousID()
if !ok {
return oid.ID{}, relations.ErrNoLeftSibling
return oid.ID{}, fmt.Errorf("failed to get sibling via client %s %w", cp.address(), relations.ErrNoLeftSibling)
}
return idMember, nil
}
@ -3287,10 +3299,14 @@ func (p *Pool) FindSiblingBySplitID(ctx context.Context, cnrID cid.ID, splitID *
if tokens.Session != nil {
prm.UseSession(*tokens.Session)
}
cp, err := p.connection()
if err != nil {
return nil, err
}
res, err := p.SearchObjects(ctx, prm)
if err != nil {
return nil, fmt.Errorf("failed to search objects by split ID: %w", err)
return nil, fmt.Errorf("failed to search objects by split ID by addr %s: %w", cp.address(), err)
}
var members []oid.ID
@ -3299,7 +3315,7 @@ func (p *Pool) FindSiblingBySplitID(ctx context.Context, cnrID cid.ID, splitID *
return false
})
if err != nil {
return nil, fmt.Errorf("failed to iterate found objects: %w", err)
return nil, fmt.Errorf("failed to iterate found objects by addr %s: %w", cp.address(), err)
}
return members, nil
@ -3319,10 +3335,14 @@ func (p *Pool) FindSiblingByParentID(ctx context.Context, cnrID cid.ID, objID oi
if tokens.Session != nil {
prm.UseSession(*tokens.Session)
}
cp, err := p.connection()
if err != nil {
return nil, err
}
resSearch, err := p.SearchObjects(ctx, prm)
if err != nil {
return nil, fmt.Errorf("failed to find object children: %w", err)
return nil, fmt.Errorf("failed to find object children by addr %s: %w", cp.address(), err)
}
var res []oid.ID
@ -3331,7 +3351,7 @@ func (p *Pool) FindSiblingByParentID(ctx context.Context, cnrID cid.ID, objID oi
return false
})
if err != nil {
return nil, fmt.Errorf("failed to iterate found objects: %w", err)
return nil, fmt.Errorf("failed to iterate found objects by addr %s: %w", cp.address(), err)
}
return res, nil

View file

@ -657,7 +657,7 @@ func (p *Pool) Close() error {
for _, group := range p.innerPools {
for _, cl := range group.clients {
if closeErr := cl.close(); closeErr != nil {
p.log(zapcore.ErrorLevel, "close client connection", zap.Error(closeErr))
p.log(zapcore.ErrorLevel, "close client connection", zap.Error(closeErr), zap.String("addr", cl.endpoint()))
err = closeErr
}
}
@ -676,7 +676,7 @@ func (p *Pool) closeClientMapConnections() (err error) {
for _, cl := range p.clientMap {
if closeErr := cl.close(); closeErr != nil {
p.log(zapcore.ErrorLevel, "close client connection", zap.Error(closeErr))
p.log(zapcore.ErrorLevel, "close client connection", zap.Error(closeErr), zap.String("addr", cl.endpoint()))
err = closeErr
}
}
@ -962,7 +962,7 @@ LOOP:
treeCl, err = p.getNewTreeClient(ctx, cnrNode)
if err != nil {
finErr = finalError(finErr, err)
p.log(zap.DebugLevel, "failed to create tree client", zap.String("request_id", reqID), zap.Int("remaining attempts", attempts))
p.log(zap.DebugLevel, "failed to create tree client", zap.String("request_id", reqID), zap.Int("remaining attempts", attempts), zap.String("addr", treeCl.endpoint()))
continue
}