diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index d6bb11774c..c95ed37522 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -331,6 +331,7 @@ func initLocalStorage(c *cfg) { engineOpts := []engine.Option{ engine.WithLogger(c.log), engine.WithShardPoolSize(engineconfig.ShardPoolSize(c.appCfg)), + engine.WithErrorThreshold(engineconfig.ShardErrorThreshold(c.appCfg)), } if c.metricsCollector != nil { engineOpts = append(engineOpts, engine.WithMetrics(c.metricsCollector)) diff --git a/cmd/neofs-node/config/engine/config.go b/cmd/neofs-node/config/engine/config.go index 2dd03a7b34..15cf14dd42 100644 --- a/cmd/neofs-node/config/engine/config.go +++ b/cmd/neofs-node/config/engine/config.go @@ -58,3 +58,10 @@ func ShardPoolSize(c *config.Config) uint32 { return ShardPoolSizeDefault } + +// ShardErrorThreshold returns value of "shard_ro_error_threshold" config parameter from "storage" section. +// +// Returns 0 if the value is missing. +func ShardErrorThreshold(c *config.Config) uint32 { + return config.Uint32Safe(c.Sub(subsection), "shard_ro_error_threshold") +} diff --git a/cmd/neofs-node/config/engine/config_test.go b/cmd/neofs-node/config/engine/config_test.go index 3f95de485e..9e7aef07b1 100644 --- a/cmd/neofs-node/config/engine/config_test.go +++ b/cmd/neofs-node/config/engine/config_test.go @@ -31,6 +31,7 @@ func TestEngineSection(t *testing.T) { require.False(t, handlerCalled) + require.EqualValues(t, 0, engineconfig.ShardErrorThreshold(empty)) require.EqualValues(t, engineconfig.ShardPoolSizeDefault, engineconfig.ShardPoolSize(empty)) require.EqualValues(t, shard.ModeReadWrite, shardconfig.From(empty).Mode()) }) @@ -40,6 +41,7 @@ func TestEngineSection(t *testing.T) { var fileConfigTest = func(c *config.Config) { num := 0 + require.EqualValues(t, 100, engineconfig.ShardErrorThreshold(c)) require.EqualValues(t, 15, engineconfig.ShardPoolSize(c)) engineconfig.IterateShards(c, true, func(sc *shardconfig.Config) { diff --git a/config/example/node.env b/config/example/node.env index 110b4c8636..6eb0b10350 100644 --- a/config/example/node.env +++ b/config/example/node.env @@ -70,6 +70,7 @@ NEOFS_OBJECT_PUT_POOL_SIZE_REMOTE=100 # Storage engine section NEOFS_STORAGE_SHARD_POOL_SIZE=15 NEOFS_STORAGE_SHARD_NUM=2 +NEOFS_STORAGE_SHARD_RO_ERROR_THRESHOLD=100 ## 0 shard ### Flag to refill Metabase from BlobStor NEOFS_STORAGE_SHARD_0_RESYNC_METABASE=false diff --git a/config/example/node.json b/config/example/node.json index 10537c1ae1..4a49cddd95 100644 --- a/config/example/node.json +++ b/config/example/node.json @@ -115,6 +115,7 @@ "storage": { "shard_pool_size": 15, "shard_num": 2, + "shard_ro_error_threshold": 100, "shard": { "0": { "mode": "read-only", diff --git a/config/example/node.yaml b/config/example/node.yaml index 7dda3d5c68..48820481df 100644 --- a/config/example/node.yaml +++ b/config/example/node.yaml @@ -99,6 +99,7 @@ storage: # note: shard configuration can be omitted for relay node (see `node.relay`) shard_pool_size: 15 # size of per-shard worker pools used for PUT operations shard_num: 2 # total number of shards + shard_ro_error_threshold: 100 # amount of errors to occur before shard is made read-only (default: 0, ignore errors) default: # section with the default shard parameters resync_metabase: true # sync metabase with blobstor on start, expensive, leave false until complete understanding