diff --git a/cmd/neofs-node/config/engine/config.go b/cmd/neofs-node/config/engine/config.go index 77699f3a..a5375efb 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 70ba0d60..5ce451cb 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 6fee13f4..114fe831 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 22329086..797d0855 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