From c41d9c3fbe7219eab0902722c4b8de129fbe7782 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Thu, 2 Jun 2022 17:19:56 +0300 Subject: [PATCH] [#1474] neofs-node/config: Remove "shard_num" from the "grpc" section Signed-off-by: Evgenii Stratonikov --- cmd/neofs-node/config/engine/config.go | 30 +++++++++++++++----------- config/example/node.env | 1 - config/example/node.json | 1 - config/example/node.yaml | 1 - 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/cmd/neofs-node/config/engine/config.go b/cmd/neofs-node/config/engine/config.go index 77699f3a13..a5375efb04 100644 --- a/cmd/neofs-node/config/engine/config.go +++ b/cmd/neofs-node/config/engine/config.go @@ -15,36 +15,40 @@ const ( ShardPoolSizeDefault = 20 ) -// IterateShards iterates over subsections ["0":"N") (N - "shard_num" value) -// of "shard" subsection of "storage" section of c, wrap them into -// shardconfig.Config and passes to f. +// IterateShards iterates over subsections of "shard" subsection of "storage" section of c, +// wrap them into shardconfig.Config and passes to f. +// +// Section names are expected to be consecutive integer numbers, starting from 0. // // Panics if N is not a positive number while shards are required. func IterateShards(c *config.Config, required bool, f func(*shardconfig.Config)) { c = c.Sub(subsection) - num := config.Uint(c, "shard_num") - if num == 0 { - if required { - panic("no shard configured") - } - - return - } - def := c.Sub("default") c = c.Sub("shard") - for i := uint64(0); i < num; i++ { + i := uint64(0) + for ; ; i++ { si := strconv.FormatUint(i, 10) sc := shardconfig.From( c.Sub(si), ) + + // Path for the blobstor can't be present in the default section, because different shards + // must have different paths, so if it is missing, the shard is not here. + // At the same time checking for "blobstor" section doesn't work proper + // with configuration via the environment. + if (*config.Config)(sc).Value("blobstor.path") == nil { + break + } (*config.Config)(sc).SetDefault(def) f(sc) } + if i == 0 && required { + panic("no shard configured") + } } // ShardPoolSize returns the value of "shard_pool_size" config parameter from "storage" section. diff --git a/config/example/node.env b/config/example/node.env index 70ba0d607c..5ce451cb3c 100644 --- a/config/example/node.env +++ b/config/example/node.env @@ -74,7 +74,6 @@ 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 diff --git a/config/example/node.json b/config/example/node.json index 6fee13f487..114fe83150 100644 --- a/config/example/node.json +++ b/config/example/node.json @@ -120,7 +120,6 @@ }, "storage": { "shard_pool_size": 15, - "shard_num": 2, "shard_ro_error_threshold": 100, "shard": { "0": { diff --git a/config/example/node.yaml b/config/example/node.yaml index 223290868e..797d085530 100644 --- a/config/example/node.yaml +++ b/config/example/node.yaml @@ -103,7 +103,6 @@ object: 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