From 73a71a71b06adb053933e7d7eab117ceb3406784 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Mon, 26 Jun 2023 14:43:25 +0300 Subject: [PATCH] [#1] node: Use a proper validation of a substorage type Signed-off-by: Evgenii Stratonikov --- .../config/engine/shard/blobstor/config.go | 13 ++++--------- cmd/frostfs-node/validate.go | 6 +----- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/cmd/frostfs-node/config/engine/shard/blobstor/config.go b/cmd/frostfs-node/config/engine/shard/blobstor/config.go index a6e34e80f..f8b2e2e9b 100644 --- a/cmd/frostfs-node/config/engine/shard/blobstor/config.go +++ b/cmd/frostfs-node/config/engine/shard/blobstor/config.go @@ -5,8 +5,6 @@ import ( "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config" "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/engine/shard/blobstor/storage" - "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/blobovniczatree" - "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/fstree" ) // Config is a wrapper over the config section @@ -25,14 +23,11 @@ func (x *Config) Storages() []*storage.Config { typ := config.String( (*config.Config)(x), strconv.Itoa(i)+".type") - switch typ { - case "": + if typ == "" { return ss - case fstree.Type, blobovniczatree.Type: - sub := storage.From((*config.Config)(x).Sub(strconv.Itoa(i))) - ss = append(ss, sub) - default: - panic("invalid type") } + + sub := storage.From((*config.Config)(x).Sub(strconv.Itoa(i))) + ss = append(ss, sub) } } diff --git a/cmd/frostfs-node/validate.go b/cmd/frostfs-node/validate.go index 3896fd6be..e07afb2ca 100644 --- a/cmd/frostfs-node/validate.go +++ b/cmd/frostfs-node/validate.go @@ -51,17 +51,13 @@ func validateConfig(c *config.Config) error { blobstor := sc.BlobStor().Storages() if len(blobstor) != 2 { - // TODO (@fyrcik): remove after #1522 return fmt.Errorf("blobstor section must have 2 components, got: %d", len(blobstor)) } for i := range blobstor { switch blobstor[i].Type() { case fstree.Type, blobovniczatree.Type: default: - // FIXME #1764 (@fyrchik): this line is currently unreachable, - // because we panic in `sc.BlobStor().Storages()`. - return fmt.Errorf("unexpected storage type: %s (shard %d)", - blobstor[i].Type(), shardNum) + return fmt.Errorf("unexpected storage type: %s (shard %d)", blobstor[i].Type(), shardNum) } if blobstor[i].Perm()&0600 != 0600 { return fmt.Errorf("invalid permissions for blobstor component: %s, "+