forked from TrueCloudLab/frostfs-node
[#1532] node: Allow to omit metabase.path if shard is disabled
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
af3d6368b0
commit
892542d6e3
5 changed files with 43 additions and 4 deletions
|
@ -41,6 +41,10 @@ func IterateShards(c *config.Config, required bool, f func(*shardconfig.Config)
|
|||
c.Sub(si),
|
||||
)
|
||||
|
||||
if sc.Mode() == mode.Disabled {
|
||||
continue
|
||||
}
|
||||
|
||||
// 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
|
||||
|
@ -50,10 +54,6 @@ func IterateShards(c *config.Config, required bool, f func(*shardconfig.Config)
|
|||
}
|
||||
(*config.Config)(sc).SetDefault(def)
|
||||
|
||||
if sc.Mode() == mode.Disabled {
|
||||
continue
|
||||
}
|
||||
|
||||
if err := f(sc); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -18,6 +18,22 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestIterateShards(t *testing.T) {
|
||||
fileConfigTest := func(c *config.Config) {
|
||||
var res []string
|
||||
require.NoError(t,
|
||||
engineconfig.IterateShards(c, false, func(sc *shardconfig.Config) error {
|
||||
res = append(res, sc.Metabase().Path())
|
||||
return nil
|
||||
}))
|
||||
require.Equal(t, []string{"abc", "xyz"}, res)
|
||||
}
|
||||
|
||||
const cfgDir = "./testdata/shards"
|
||||
configtest.ForEachFileType(cfgDir, fileConfigTest)
|
||||
configtest.ForEnvFileType(t, cfgDir, fileConfigTest)
|
||||
}
|
||||
|
||||
func TestEngineSection(t *testing.T) {
|
||||
t.Run("defaults", func(t *testing.T) {
|
||||
empty := configtest.EmptyConfig()
|
||||
|
|
3
cmd/frostfs-node/config/engine/testdata/shards.env
vendored
Normal file
3
cmd/frostfs-node/config/engine/testdata/shards.env
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
FROSTFS_STORAGE_SHARD_0_METABASE_PATH=abc
|
||||
FROSTFS_STORAGE_SHARD_1_MODE=disabled
|
||||
FROSTFS_STORAGE_SHARD_2_METABASE_PATH=xyz
|
13
cmd/frostfs-node/config/engine/testdata/shards.json
vendored
Normal file
13
cmd/frostfs-node/config/engine/testdata/shards.json
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"storage.shard": {
|
||||
"0": {
|
||||
"metabase.path": "abc"
|
||||
},
|
||||
"1": {
|
||||
"mode": "disabled"
|
||||
},
|
||||
"2": {
|
||||
"metabase.path": "xyz"
|
||||
}
|
||||
}
|
||||
}
|
7
cmd/frostfs-node/config/engine/testdata/shards.yaml
vendored
Normal file
7
cmd/frostfs-node/config/engine/testdata/shards.yaml
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
storage.shard:
|
||||
0:
|
||||
metabase.path: abc
|
||||
1:
|
||||
mode: disabled
|
||||
2:
|
||||
metabase.path: xyz
|
Loading…
Reference in a new issue