From e44033d488dfda052c686dcf9cda6f6907ebf273 Mon Sep 17 00:00:00 2001 From: Andrey Butusov Date: Fri, 22 Nov 2024 12:27:22 +0300 Subject: [PATCH] node: use SDK funcs for get and set node attributes Use `GetAttributes` and `SetAttributes` from SDK instead of api-go `netmap.Attribute`. Signed-off-by: Andrey Butusov --- cmd/neofs-node/attributes.go | 9 --------- cmd/neofs-node/netmap.go | 22 +++++----------------- 2 files changed, 5 insertions(+), 26 deletions(-) diff --git a/cmd/neofs-node/attributes.go b/cmd/neofs-node/attributes.go index 988cfc9ce3..5d0199d357 100644 --- a/cmd/neofs-node/attributes.go +++ b/cmd/neofs-node/attributes.go @@ -4,7 +4,6 @@ import ( "fmt" "github.com/nspcc-dev/locode-db/pkg/locodedb" - netmapV2 "github.com/nspcc-dev/neofs-api-go/v2/netmap" nodeconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/node" "github.com/nspcc-dev/neofs-node/pkg/util/attributes" "go.uber.org/zap" @@ -118,11 +117,3 @@ func nodeAttrsEqual(arr1, arr2 [][2]string) bool { return true } - -func nodeAttrsToSlice(attrs []netmapV2.Attribute) [][2]string { - res := make([][2]string, len(attrs)) - for i := range attrs { - res[i] = [2]string{attrs[i].GetKey(), attrs[i].GetValue()} - } - return res -} diff --git a/cmd/neofs-node/netmap.go b/cmd/neofs-node/netmap.go index 4ac11d7b8d..4fefe0ac3a 100644 --- a/cmd/neofs-node/netmap.go +++ b/cmd/neofs-node/netmap.go @@ -6,7 +6,6 @@ import ( "fmt" "sync/atomic" - netmapV2 "github.com/nspcc-dev/neofs-api-go/v2/netmap" netmapGRPC "github.com/nspcc-dev/neofs-api-go/v2/netmap/grpc" "github.com/nspcc-dev/neofs-node/pkg/core/netmap" "github.com/nspcc-dev/neofs-node/pkg/metrics" @@ -457,33 +456,22 @@ func (n *netInfo) Dump(ver version.Version) (*netmapSDK.NetworkInfo, error) { func (c *cfg) reloadNodeAttributes() error { c.cfgNodeInfo.localInfoLock.Lock() - // TODO(@End-rey): after updating SDK, rewrite with w/o api netmap. See #3005, neofs-sdk-go#635. - var ni2 netmapV2.NodeInfo - c.cfgNodeInfo.localInfo.WriteToV2(&ni2) + oldAttrs := c.cfgNodeInfo.localInfo.GetAttributes() - oldAttrs := ni2.GetAttributes() + c.cfgNodeInfo.localInfo.SetAttributes(nil) - ni2.SetAttributes(nil) - - err := c.cfgNodeInfo.localInfo.ReadFromV2(ni2) - if err != nil { - c.cfgNodeInfo.localInfoLock.Unlock() - return err - } - - err = writeSystemAttributes(c) + err := writeSystemAttributes(c) if err != nil { c.cfgNodeInfo.localInfoLock.Unlock() return err } parseAttributes(c) - c.cfgNodeInfo.localInfo.WriteToV2(&ni2) + newAttrs := c.cfgNodeInfo.localInfo.GetAttributes() - newAttrs := ni2.GetAttributes() c.cfgNodeInfo.localInfoLock.Unlock() - if nodeAttrsEqual(nodeAttrsToSlice(oldAttrs), nodeAttrsToSlice(newAttrs)) { + if nodeAttrsEqual(oldAttrs, newAttrs) { return nil }