From 9b241e4a1705c226b82682574bdbe3a43951e2e2 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Wed, 5 Oct 2022 14:40:37 +0300 Subject: [PATCH] [#1840] neofs-node: Allow to use `mode: disabled` in config Currently, when removing shard special care must be taken with respect to shard numbering. `mode: disabled` allows to leave shard configuration in place while also ignoring it during initialization. This makes disk replacement much more convenient. Signed-off-by: Evgenii Stratonikov --- CHANGELOG.md | 7 ++++++- cmd/neofs-node/config/engine/config.go | 9 ++++++++- cmd/neofs-node/config/engine/shard/config.go | 2 ++ pkg/local_object_storage/shard/mode/mode.go | 9 +++++++++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51dabb1d1..5c8dfc6e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ Changelog for NeoFS Node - Validate policy before container creation (#1704) - `--timeout` flag in `neofs-cli` subcommands (#1837) - `container nodes` command to output list of nodes for container, grouped by replica (#1704) +- Configuration flag to ignore shard in `neofs-node` (#1840) ### Changed - Allow to evacuate shard data with `EvacuateShard` control RPC (#1800) @@ -40,7 +41,7 @@ Changelog for NeoFS Node ### Updated -### Updating from v0.32.0 +### Updating from v0.32.0 Replace using the `control netmap-snapshot` command with `netmap snapshot` one in NeoFS CLI. Node can now specify additional addresses in `ExternalAddr` attribute. To allow a node to dial other nodes external address, use `apiclient.allow_external` config setting. @@ -56,6 +57,10 @@ When issuing an object session token for root (virtual, "big") objects, additionally include all members of the split-chain. If session context includes root object only, it is not spread to physical ("small") objects. +`neofs-node` configuration now supports `mode: disabled` flag for a shard. +This can be used to temporarily ignore shards without completely removing them +from the config file. + ## [0.32.0] - 2022-09-14 - Pungdo (풍도, 楓島) ### Added diff --git a/cmd/neofs-node/config/engine/config.go b/cmd/neofs-node/config/engine/config.go index 0fc9e01eb..86f6b70c4 100644 --- a/cmd/neofs-node/config/engine/config.go +++ b/cmd/neofs-node/config/engine/config.go @@ -6,6 +6,7 @@ import ( "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config" shardconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/engine/shard" + "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard/mode" ) const ( @@ -31,6 +32,7 @@ func IterateShards(c *config.Config, required bool, f func(*shardconfig.Config) c = c.Sub("shard") def := c.Sub("default") + alive := 0 i := uint64(0) for ; ; i++ { si := strconv.FormatUint(i, 10) @@ -48,11 +50,16 @@ 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 } + alive++ } - if i == 0 && required { + if alive == 0 && required { return ErrNoShardConfigured } return nil diff --git a/cmd/neofs-node/config/engine/shard/config.go b/cmd/neofs-node/config/engine/shard/config.go index ab1641ae2..610ebdf1e 100644 --- a/cmd/neofs-node/config/engine/shard/config.go +++ b/cmd/neofs-node/config/engine/shard/config.go @@ -128,6 +128,8 @@ func (x *Config) Mode() (m mode.Mode) { m = mode.Degraded case "degraded-read-only": m = mode.DegradedReadOnly + case "disabled": + m = mode.Disabled default: panic(fmt.Sprintf("unknown shard mode: %s", s)) } diff --git a/pkg/local_object_storage/shard/mode/mode.go b/pkg/local_object_storage/shard/mode/mode.go index b06920d2e..65b2b5c89 100644 --- a/pkg/local_object_storage/shard/mode/mode.go +++ b/pkg/local_object_storage/shard/mode/mode.go @@ -1,5 +1,7 @@ package mode +import "math" + // Mode represents enumeration of Shard work modes. type Mode uint32 @@ -12,6 +14,11 @@ const ( // after a certain number of errors is encountered. It is the same as // `mode.Degraded` but also is read-only. DegradedReadOnly = Degraded | ReadOnly + + // Disabled mode is a mode where a shard is disabled. + // An existing shard can't have this mode, but it can be used in + // the configuration or control service commands. + Disabled = math.MaxUint32 ) const ( @@ -36,6 +43,8 @@ func (m Mode) String() string { return "DEGRADED_READ_WRITE" case DegradedReadOnly: return "DEGRADED_READ_ONLY" + case Disabled: + return "DISABLED" } }