From d757d881d0d270861cdd191e7ce4deb52545fcbf Mon Sep 17 00:00:00 2001 From: Dmitrii Stepanov Date: Fri, 14 Apr 2023 12:11:27 +0300 Subject: [PATCH] [#249] node: Drop subnet from config Signed-off-by: Dmitrii Stepanov --- cmd/frostfs-node/config/node/config.go | 27 -------------------- cmd/frostfs-node/config/node/config_test.go | 28 --------------------- cmd/frostfs-node/netmap.go | 27 -------------------- config/example/node.env | 2 -- config/example/node.json | 8 ------ config/example/node.yaml | 6 ----- docs/storage-node-configuration.md | 14 ----------- 7 files changed, 112 deletions(-) diff --git a/cmd/frostfs-node/config/node/config.go b/cmd/frostfs-node/config/node/config.go index a2794422e..9dfe8ddf4 100644 --- a/cmd/frostfs-node/config/node/config.go +++ b/cmd/frostfs-node/config/node/config.go @@ -177,33 +177,6 @@ func (p PersistentStateConfig) Path() string { return PersistentStatePathDefault } -// SubnetConfig represents node configuration related to subnets. -type SubnetConfig config.Config - -// Init initializes SubnetConfig from "subnet" sub-section of "node" section -// of the root config. -func (x *SubnetConfig) Init(root config.Config) { - *x = SubnetConfig(*root.Sub(subsection).Sub("subnet")) -} - -// ExitZero returns the value of "exit_zero" config parameter as bool. -// Returns false if the value can not be cast. -func (x SubnetConfig) ExitZero() bool { - return config.BoolSafe((*config.Config)(&x), "exit_zero") -} - -// IterateSubnets casts the value of "entries" config parameter to string slice, -// iterates over all of its elements and passes them to f. -// -// Does nothing if the value can not be cast to string slice. -func (x SubnetConfig) IterateSubnets(f func(string)) { - ids := config.StringSliceSafe((*config.Config)(&x), "entries") - - for i := range ids { - f(ids[i]) - } -} - // Notification returns structure that provides access to "notification" // subsection of "node" section. func Notification(c *config.Config) NotificationConfig { diff --git a/cmd/frostfs-node/config/node/config_test.go b/cmd/frostfs-node/config/node/config_test.go index ff085c506..3a1120491 100644 --- a/cmd/frostfs-node/config/node/config_test.go +++ b/cmd/frostfs-node/config/node/config_test.go @@ -52,20 +52,6 @@ func TestNodeSection(t *testing.T) { require.Equal(t, "", notificationDefaultCertPath) require.Equal(t, "", notificationDefaultKeyPath) require.Equal(t, "", notificationDefaultCAPath) - - var subnetCfg SubnetConfig - - subnetCfg.Init(*empty) - - require.False(t, subnetCfg.ExitZero()) - - called := false - - subnetCfg.IterateSubnets(func(string) { - called = true - }) - - require.False(t, called) }) const path = "../../../../config/example/node" @@ -143,20 +129,6 @@ func TestNodeSection(t *testing.T) { require.Equal(t, "/cert/path", notificationCertPath) require.Equal(t, "/key/path", notificationKeyPath) require.Equal(t, "/ca/path", notificationCAPath) - - var subnetCfg SubnetConfig - - subnetCfg.Init(*c) - - require.True(t, subnetCfg.ExitZero()) - - var ids []string - - subnetCfg.IterateSubnets(func(id string) { - ids = append(ids, id) - }) - - require.Equal(t, []string{"123", "456", "789"}, ids) } configtest.ForEachFileType(path, fileConfigTest) diff --git a/cmd/frostfs-node/netmap.go b/cmd/frostfs-node/netmap.go index b8a25cb8c..58e3cb2f2 100644 --- a/cmd/frostfs-node/netmap.go +++ b/cmd/frostfs-node/netmap.go @@ -7,7 +7,6 @@ import ( "fmt" netmapGRPC "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/netmap/grpc" - nodeconfig "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/node" "git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/netmap" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/metrics" @@ -19,7 +18,6 @@ import ( "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control" netmapService "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/netmap" netmapSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap" - subnetid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/subnet/id" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/version" "go.uber.org/atomic" "go.uber.org/zap" @@ -143,8 +141,6 @@ func initNetmapService(ctx context.Context, c *cfg) { parseAttributes(c) c.cfgNodeInfo.localInfo.SetOffline() - readSubnetCfg(c) - if c.cfgMorph.client == nil { initMorphComponents(ctx, c) } @@ -227,29 +223,6 @@ func addNewEpochNotificationHandlers(c *cfg) { } } -func readSubnetCfg(c *cfg) { - var subnetCfg nodeconfig.SubnetConfig - - subnetCfg.Init(*c.appCfg) - - var ( - id subnetid.ID - err error - ) - - subnetCfg.IterateSubnets(func(idTxt string) { - err = id.DecodeString(idTxt) - fatalOnErrDetails("parse subnet entry", err) - - c.cfgNodeInfo.localInfo.EnterSubnet(id) - }) - - if subnetCfg.ExitZero() { - subnetid.MakeZero(&id) - c.cfgNodeInfo.localInfo.ExitSubnet(id) - } -} - // bootstrapNode adds current node to the Network map. // Must be called after initNetmapService. func bootstrapNode(c *cfg) { diff --git a/config/example/node.env b/config/example/node.env index b3fb4f9f9..77992d995 100644 --- a/config/example/node.env +++ b/config/example/node.env @@ -19,8 +19,6 @@ FROSTFS_NODE_ATTRIBUTE_1="UN-LOCODE:RU MSK" FROSTFS_NODE_RELAY=true FROSTFS_NODE_PERSISTENT_SESSIONS_PATH=/sessions FROSTFS_NODE_PERSISTENT_STATE_PATH=/state -FROSTFS_NODE_SUBNET_EXIT_ZERO=true -FROSTFS_NODE_SUBNET_ENTRIES=123 456 789 FROSTFS_NODE_NOTIFICATION_ENABLED=true FROSTFS_NODE_NOTIFICATION_ENDPOINT=tls://localhost:4222 FROSTFS_NODE_NOTIFICATION_TIMEOUT=6s diff --git a/config/example/node.json b/config/example/node.json index 9e2a0a487..b52eb6d96 100644 --- a/config/example/node.json +++ b/config/example/node.json @@ -34,14 +34,6 @@ "persistent_state": { "path": "/state" }, - "subnet": { - "exit_zero": true, - "entries": [ - "123", - "456", - "789" - ] - }, "notification": { "enabled": true, "endpoint": "tls://localhost:4222", diff --git a/config/example/node.yaml b/config/example/node.yaml index 54d774174..1669e0e86 100644 --- a/config/example/node.yaml +++ b/config/example/node.yaml @@ -29,12 +29,6 @@ node: path: /sessions # path to persistent session tokens file of Storage node (default: in-memory sessions) persistent_state: path: /state # path to persistent state file of Storage node - subnet: - exit_zero: true # toggle entrance to zero subnet (overrides corresponding attribute and occurrence in `entries`) - entries: # list of IDs of subnets to enter in a text format of FrostFS API protocol (overrides corresponding attributes) - - 123 - - 456 - - 789 notification: enabled: true # turn on object notification service endpoint: "tls://localhost:4222" # notification server endpoint diff --git a/docs/storage-node-configuration.md b/docs/storage-node-configuration.md index 306577307..d21725668 100644 --- a/docs/storage-node-configuration.md +++ b/docs/storage-node-configuration.md @@ -122,7 +122,6 @@ contracts: | `balance` | `hash160` | | Balance contract hash. | | `container` | `hash160` | | Container contract hash. | | `netmap` | `hash160` | | Netmap contract hash. | -| `subnet` | `hash160` | | Subnet contract hash. | # `morph` section @@ -300,10 +299,6 @@ node: path: /sessions persistent_state: path: /state - subnet: - exit_zero: false - entries: - - 123 notification: enabled: true endpoint: tls://localhost:4222 @@ -323,7 +318,6 @@ node: | `relay` | `bool` | | Enable relay mode. | | `persistent_sessions` | [Persistent sessions config](#persistent_sessions-subsection) | | Persistent session token store configuration. | | `persistent_state` | [Persistent state config](#persistent_state-subsection) | | Persistent state configuration. | -| `subnet` | [Subnet config](#subnet-subsection) | | Subnet configuration. | | `notification` | [Notification config](#notification-subsection) | | NATS configuration. | @@ -352,14 +346,6 @@ It is used to correctly handle node restarts or crashes. |-----------|----------|------------------------|------------------------| | `path` | `string` | `.frostfs-storage-state` | Path to the database. | -## `subnet` subsection -This is an advanced section, use with caution. - -| Parameter | Type | Default value | Description | -|-------------|------------|---------------|------------------------------------------------------| -| `exit_zero` | `bool` | `false` | Exit from the default subnet. | -| `entries` | `[]uint32` | | List of non-default subnet ID this node belongs to. | - ## `notification` subsection This is an advanced section, use with caution.