From bd5bf8b1a955bef17e2ba722b62579428433860d Mon Sep 17 00:00:00 2001 From: Dmitrii Stepanov Date: Thu, 5 Oct 2023 11:30:41 +0300 Subject: [PATCH] [#721] netmap: Drop already bootstraped check Because of this check, under certain conditions, the node could be removed from the network map, although the node was functioning normally. Signed-off-by: Dmitrii Stepanov --- cmd/frostfs-node/config.go | 3 +-- cmd/frostfs-node/netmap.go | 25 ++++++------------------- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/cmd/frostfs-node/config.go b/cmd/frostfs-node/config.go index 8286bc7d..60e567c5 100644 --- a/cmd/frostfs-node/config.go +++ b/cmd/frostfs-node/config.go @@ -345,8 +345,7 @@ type internals struct { apiVersion version.Version healthStatus *atomic.Int32 // is node under maintenance - isMaintenance atomic.Bool - alreadyBootstraped bool + isMaintenance atomic.Bool } // starts node's maintenance. diff --git a/cmd/frostfs-node/netmap.go b/cmd/frostfs-node/netmap.go index cc3c0c48..ebe152e4 100644 --- a/cmd/frostfs-node/netmap.go +++ b/cmd/frostfs-node/netmap.go @@ -220,10 +220,6 @@ func bootstrapNode(c *cfg) { c.log.Info(logs.FrostFSNodeNodeIsUnderMaintenanceSkipInitialBootstrap) return } - if c.alreadyBootstraped { - c.log.Info(logs.NetmapNodeAlreadyInCandidateListOnlineSkipInitialBootstrap) - return - } err := c.bootstrap() fatalOnErrDetails("bootstrap error", err) } @@ -256,7 +252,7 @@ func initNetmapState(c *cfg) { fatalOnErrDetails("could not initialize current epoch number", err) var ni *netmapSDK.NodeInfo - ni, c.alreadyBootstraped, err = c.netmapInitLocalNodeState(epoch) + ni, err = c.netmapInitLocalNodeState(epoch) fatalOnErrDetails("could not init network state", err) stateWord := nodeState(ni) @@ -275,13 +271,6 @@ func initNetmapState(c *cfg) { c.handleLocalNodeInfo(ni) } -func sameNodeInfo(a, b *netmapSDK.NodeInfo) bool { - // Suboptimal, but we do this once on the node startup. - rawA := a.Marshal() - rawB := b.Marshal() - return bytes.Equal(rawA, rawB) -} - func nodeState(ni *netmapSDK.NodeInfo) string { if ni != nil { switch { @@ -296,29 +285,27 @@ func nodeState(ni *netmapSDK.NodeInfo) string { return "undefined" } -func (c *cfg) netmapInitLocalNodeState(epoch uint64) (*netmapSDK.NodeInfo, bool, error) { +func (c *cfg) netmapInitLocalNodeState(epoch uint64) (*netmapSDK.NodeInfo, error) { nmNodes, err := c.cfgNetmap.wrapper.GetCandidates() if err != nil { - return nil, false, err + return nil, err } var candidate *netmapSDK.NodeInfo - alreadyBootstraped := false for i := range nmNodes { if bytes.Equal(nmNodes[i].PublicKey(), c.binPublicKey) { candidate = &nmNodes[i] - alreadyBootstraped = candidate.IsOnline() && sameNodeInfo(&c.cfgNodeInfo.localInfo, candidate) break } } node, err := c.netmapLocalNodeState(epoch) if err != nil { - return nil, false, err + return nil, err } if candidate == nil { - return node, false, nil + return node, nil } nmState := nodeState(node) @@ -330,7 +317,7 @@ func (c *cfg) netmapInitLocalNodeState(epoch uint64) (*netmapSDK.NodeInfo, bool, zap.String("netmap", nmState), zap.String("candidate", candidateState)) } - return candidate, alreadyBootstraped, nil + return candidate, nil } func (c *cfg) netmapLocalNodeState(epoch uint64) (*netmapSDK.NodeInfo, error) {