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

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 a262a0038f
commit 87bb55f992
4 changed files with 15 additions and 10 deletions

View file

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

View file

@ -1646,7 +1646,7 @@ func (p *Pool) GetSplitInfo(ctx context.Context, cnrID cid.ID, objID oid.ID, tok
case errors.As(err, &errSplit): case errors.As(err, &errSplit):
return errSplit.SplitInfo(), nil return errSplit.SplitInfo(), nil
case err == nil || errors.As(err, &errECInfo): 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: default:
return nil, fmt.Errorf("failed to get raw object header: %w", err) 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 var err error
c.client, err = c.createClient() c.client, err = c.createClient()
if err != nil { 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 { 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 c.healthy = true
@ -127,5 +127,9 @@ func (c *treeClient) close() error {
if c.client == nil || c.client.Conn() == nil { if c.client == nil || c.client.Conn() == nil {
return nil return nil
} }
return c.client.Conn().Close() err := c.client.Conn().Close()
if err != nil {
return fmt.Errorf("address '%s': %w", c.address, err)
}
return nil
} }

View file

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