[#1532] node: Allow to omit metabase.path if shard is disabled
All checks were successful
Tests and linters / Run gofumpt (push) Successful in 2m15s
Vulncheck / Vulncheck (push) Successful in 2m44s
Build / Build Components (push) Successful in 3m9s
Tests and linters / Staticcheck (push) Successful in 3m10s
Pre-commit hooks / Pre-commit (push) Successful in 3m38s
Tests and linters / gopls check (push) Successful in 4m14s
Tests and linters / Tests (push) Successful in 4m27s
Tests and linters / Lint (push) Successful in 4m34s
Tests and linters / Tests with -race (push) Successful in 4m51s
All checks were successful
Tests and linters / Run gofumpt (push) Successful in 2m15s
Vulncheck / Vulncheck (push) Successful in 2m44s
Build / Build Components (push) Successful in 3m9s
Tests and linters / Staticcheck (push) Successful in 3m10s
Pre-commit hooks / Pre-commit (push) Successful in 3m38s
Tests and linters / gopls check (push) Successful in 4m14s
Tests and linters / Tests (push) Successful in 4m27s
Tests and linters / Lint (push) Successful in 4m34s
Tests and linters / Tests with -race (push) Successful in 4m51s
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
432042c534
commit
47dfd8840c
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),
|
c.Sub(si),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if sc.Mode() == mode.Disabled {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// Path for the blobstor can't be present in the default section, because different shards
|
// 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.
|
// 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
|
// 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)
|
(*config.Config)(sc).SetDefault(def)
|
||||||
|
|
||||||
if sc.Mode() == mode.Disabled {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := f(sc); err != nil {
|
if err := f(sc); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,22 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"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) {
|
func TestEngineSection(t *testing.T) {
|
||||||
t.Run("defaults", func(t *testing.T) {
|
t.Run("defaults", func(t *testing.T) {
|
||||||
empty := configtest.EmptyConfig()
|
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