[#249] node: Drop subnet from config

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
feat/multiple-copies-number
Dmitrii Stepanov 2023-04-14 12:11:27 +03:00
parent 05c870f39a
commit d757d881d0
7 changed files with 0 additions and 112 deletions

View File

@ -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 {

View File

@ -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)

View File

@ -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) {

View File

@ -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

View File

@ -34,14 +34,6 @@
"persistent_state": {
"path": "/state"
},
"subnet": {
"exit_zero": true,
"entries": [
"123",
"456",
"789"
]
},
"notification": {
"enabled": true,
"endpoint": "tls://localhost:4222",

View File

@ -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

View File

@ -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.