forked from TrueCloudLab/frostfs-node
[#249] node: Drop subnet from config
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
05c870f39a
commit
d757d881d0
7 changed files with 0 additions and 112 deletions
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue