From 310a4c3e4d8f7d308160389ae9324e0cf1add808 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Wed, 23 Dec 2020 18:07:10 +0300 Subject: [PATCH] [#275] innerring: Add storage group search timeout Signed-off-by: Alex Vanin --- cmd/neofs-ir/defaults.go | 1 + pkg/innerring/innerring.go | 1 + pkg/innerring/processors/audit/process.go | 4 +--- pkg/innerring/processors/audit/processor.go | 8 ++++++++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cmd/neofs-ir/defaults.go b/cmd/neofs-ir/defaults.go index 780080d2..715dce1e 100644 --- a/cmd/neofs-ir/defaults.go +++ b/cmd/neofs-ir/defaults.go @@ -96,4 +96,5 @@ func defaultConfiguration(cfg *viper.Viper) { cfg.SetDefault("audit.timeout.get", "5s") cfg.SetDefault("audit.timeout.head", "5s") cfg.SetDefault("audit.timeout.rangehash", "5s") + cfg.SetDefault("audit.timeout.search", "10s") } diff --git a/pkg/innerring/innerring.go b/pkg/innerring/innerring.go index a6ff3495..51ea3cb8 100644 --- a/pkg/innerring/innerring.go +++ b/pkg/innerring/innerring.go @@ -242,6 +242,7 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error MorphClient: server.morphClient, IRList: server, ClientCache: clientCache, + RPCSearchTimeout: cfg.GetDuration("audit.timeout.search"), TaskManager: auditTaskManager, Reporter: server, }) diff --git a/pkg/innerring/processors/audit/process.go b/pkg/innerring/processors/audit/process.go index 5bd65998..0e5bc0bb 100644 --- a/pkg/innerring/processors/audit/process.go +++ b/pkg/innerring/processors/audit/process.go @@ -2,7 +2,6 @@ package audit import ( "context" - "time" "github.com/nspcc-dev/neofs-api-go/pkg/client" "github.com/nspcc-dev/neofs-api-go/pkg/container" @@ -134,8 +133,7 @@ func (ap *Processor) findStorageGroups(cid *container.ID, shuffled netmap.Nodes) sgSearchParams.WithContainerID(cid) sgSearchParams.WithSearchFilters(sgFilter) - // fixme: timeout from config - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), ap.searchTimeout) result, err := cli.SearchObject(ctx, sgSearchParams) cancel() diff --git a/pkg/innerring/processors/audit/processor.go b/pkg/innerring/processors/audit/processor.go index d764cea4..8652486b 100644 --- a/pkg/innerring/processors/audit/processor.go +++ b/pkg/innerring/processors/audit/processor.go @@ -2,6 +2,7 @@ package audit import ( "context" + "time" "github.com/nspcc-dev/neo-go/pkg/util" SDKClient "github.com/nspcc-dev/neofs-api-go/pkg/client" @@ -45,6 +46,7 @@ type ( morphClient *client.Client irList Indexer clientCache NeoFSClientCache + searchTimeout time.Duration containerClient *wrapContainer.Wrapper netmapClient *wrapNetmap.Wrapper @@ -63,6 +65,7 @@ type ( MorphClient *client.Client IRList Indexer ClientCache NeoFSClientCache + RPCSearchTimeout time.Duration TaskManager TaskManager Reporter audit.Reporter } @@ -90,6 +93,10 @@ func New(p *Params) (*Processor, error) { return nil, errors.New("ir/audit: global state is not set") case p.ClientCache == nil: return nil, errors.New("ir/audit: neofs RPC client cache is not set") + case p.TaskManager == nil: + return nil, errors.New("ir/audit: audit task manager is not set") + case p.Reporter == nil: + return nil, errors.New("ir/audit: audit result reporter is not set") } pool, err := ants.NewPool(ProcessorPoolSize, ants.WithNonblocking(true)) @@ -117,6 +124,7 @@ func New(p *Params) (*Processor, error) { morphClient: p.MorphClient, irList: p.IRList, clientCache: p.ClientCache, + searchTimeout: p.RPCSearchTimeout, containerClient: containerClient, netmapClient: netmapClient, taskManager: p.TaskManager,