diff --git a/cmd/frostfs-node/attributes.go b/cmd/frostfs-node/attributes.go deleted file mode 100644 index 64c3beba7..000000000 --- a/cmd/frostfs-node/attributes.go +++ /dev/null @@ -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))) -} diff --git a/cmd/frostfs-node/config.go b/cmd/frostfs-node/config.go index 511777566..bfe73dc85 100644 --- a/cmd/frostfs-node/config.go +++ b/cmd/frostfs-node/config.go @@ -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) diff --git a/cmd/frostfs-node/netmap.go b/cmd/frostfs-node/netmap.go index 0e90e7707..99672ed5e 100644 --- a/cmd/frostfs-node/netmap.go +++ b/cmd/frostfs-node/netmap.go @@ -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)