[#51] add address to logs
Signed-off-by: Pavel Pogodaev <p.pogodaev@yadro.com>
This commit is contained in:
parent
2b8329e026
commit
62fd8d003b
4 changed files with 28 additions and 14 deletions
|
@ -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)
|
||||
}
|
||||
|
|
23
pool/pool.go
23
pool/pool.go
|
@ -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 {
|
||||
|
@ -3197,6 +3197,7 @@ 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, _ := p.connection()
|
||||
|
||||
var prm PrmObjectHead
|
||||
prm.SetAddress(addr)
|
||||
|
@ -3217,7 +3218,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)
|
||||
}
|
||||
|
@ -3251,6 +3252,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 +3273,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("address '%s' %w", cp.address(), relations.ErrNoLeftSibling)
|
||||
}
|
||||
return idMember, nil
|
||||
}
|
||||
|
@ -3287,6 +3292,10 @@ 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 {
|
||||
|
@ -3299,7 +3308,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,6 +3328,10 @@ 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 {
|
||||
|
@ -3331,7 +3344,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
|
||||
|
|
|
@ -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())
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue