From 26db7093e3373674c50439edc8ab3f5d046c28a9 Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Wed, 9 Aug 2023 18:20:59 +0300 Subject: [PATCH] node: Announce version via the attributes It is done automatically but can be overwritten if `Version` attribute is provided via the application configuration. Closes #2455. Signed-off-by: Pavel Karpy --- CHANGELOG.md | 1 + cmd/neofs-node/config.go | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08a197f034..38fbe909bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ Changelog for NeoFS Node - Stored payload metric per container (#2116) - Stored payload metric per shard (#2023) - Histogram metrics for RPC and engine operations (#2351) +- SN's version is announced via the attributes automatically but can be overwritten explicitly (#2455) ### Fixed - `neo-go` RPC connection loss handling (#1337) diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index 4391ae0e20..5644ef7b20 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -532,6 +532,11 @@ var persistateSideChainLastBlockKey = []byte("side_chain_last_processed_block") func initCfg(appCfg *config.Config) *cfg { c := &cfg{} + // attaching version to the node's attributes; do not + // move it anywhere below reading the other attributes + // since a user should be able to overwrite it. + writeAppVersion(c) + err := c.readConfig(appCfg) if err != nil { panic(fmt.Errorf("config reading: %w", err)) @@ -963,3 +968,9 @@ func (c *cfg) configWatcher(ctx context.Context) { } } } + +// writeAppVersion writes app version as defined at compilation +// step to the node's attributes. +func writeAppVersion(c *cfg) { + c.cfgNodeInfo.localInfo.SetAttribute("Version", misc.Version) +}