[#1640] config: Start node configuration from node info initialization
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
1bcaa1af1f
commit
ddc80bc91b
3 changed files with 22 additions and 32 deletions
|
@ -1,14 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
nodeconfig "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/node"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/attributes"
|
||||
)
|
||||
|
||||
func parseAttributes(c *cfg) {
|
||||
if nodeconfig.Relay(c.appCfg) {
|
||||
return
|
||||
}
|
||||
|
||||
fatalOnErr(attributes.ReadNodeAttributes(&c.cfgNodeInfo.localInfo, nodeconfig.Attributes(c.appCfg)))
|
||||
}
|
|
@ -64,6 +64,7 @@ import (
|
|||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/tree"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/util/response"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/attributes"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/sdnotify"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/state"
|
||||
|
@ -684,18 +685,24 @@ func initCfg(appCfg *config.Config) *cfg {
|
|||
},
|
||||
}
|
||||
|
||||
relayOnly := nodeconfig.Relay(appCfg)
|
||||
key := nodeconfig.Key(appCfg)
|
||||
attrs := nodeconfig.Attributes(appCfg)
|
||||
netAddr := nodeconfig.BootstrapAddresses(appCfg)
|
||||
if relayOnly {
|
||||
attrs = []string{}
|
||||
netAddr = network.AddressGroup{}
|
||||
}
|
||||
initLocalNodeInfo(c, key, netAddr, attrs)
|
||||
|
||||
err := c.readConfig(appCfg)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("config reading: %w", err))
|
||||
}
|
||||
|
||||
key := nodeconfig.Key(appCfg)
|
||||
|
||||
relayOnly := nodeconfig.Relay(appCfg)
|
||||
|
||||
netState := newNetworkState()
|
||||
|
||||
c.shared = initShared(appCfg, key, netState, relayOnly)
|
||||
c.shared = initShared(appCfg, key, netState, netAddr)
|
||||
|
||||
netState.metrics = c.metricsCollector
|
||||
|
||||
|
@ -738,6 +745,15 @@ func initCfg(appCfg *config.Config) *cfg {
|
|||
return c
|
||||
}
|
||||
|
||||
func initLocalNodeInfo(c *cfg, key *keys.PrivateKey, netAddr network.AddressGroup, attrs []string) {
|
||||
if len(netAddr) > 0 {
|
||||
network.WriteToNodeInfo(netAddr, &c.cfgNodeInfo.localInfo)
|
||||
}
|
||||
c.cfgNodeInfo.localInfo.SetPublicKey(key.PublicKey().Bytes())
|
||||
fatalOnErr(attributes.ReadNodeAttributes(&c.cfgNodeInfo.localInfo, attrs))
|
||||
c.cfgNodeInfo.localInfo.SetStatus(netmap.Offline)
|
||||
}
|
||||
|
||||
func initInternals(appCfg *config.Config, log *logger.Logger) internals {
|
||||
var healthStatus atomic.Int32
|
||||
healthStatus.Store(int32(control.HealthStatus_HEALTH_STATUS_UNDEFINED))
|
||||
|
@ -765,13 +781,7 @@ func initSdNotify(appCfg *config.Config) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func initShared(appCfg *config.Config, key *keys.PrivateKey, netState *networkState, relayOnly bool) shared {
|
||||
var netAddr network.AddressGroup
|
||||
|
||||
if !relayOnly {
|
||||
netAddr = nodeconfig.BootstrapAddresses(appCfg)
|
||||
}
|
||||
|
||||
func initShared(appCfg *config.Config, key *keys.PrivateKey, netState *networkState, netAddr network.AddressGroup) shared {
|
||||
persistate, err := state.NewPersistentStorage(nodeconfig.PersistentState(appCfg).Path())
|
||||
fatalOnErr(err)
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ import (
|
|||
nmClient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/netmap"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/event"
|
||||
netmapEvent "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/event/netmap"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/network"
|
||||
netmapTransportGRPC "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/network/transport/netmap/grpc"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control"
|
||||
netmapService "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/netmap"
|
||||
|
@ -138,11 +137,6 @@ func (c *cfg) addressNum() int {
|
|||
}
|
||||
|
||||
func initNetmapService(ctx context.Context, c *cfg) {
|
||||
network.WriteToNodeInfo(c.localAddr, &c.cfgNodeInfo.localInfo)
|
||||
c.cfgNodeInfo.localInfo.SetPublicKey(c.key.PublicKey().Bytes())
|
||||
parseAttributes(c)
|
||||
c.cfgNodeInfo.localInfo.SetStatus(netmapSDK.Offline)
|
||||
|
||||
c.initMorphComponents(ctx)
|
||||
|
||||
initNetmapState(ctx, c)
|
||||
|
|
Loading…
Add table
Reference in a new issue