From e9b3488aab165964a44faa69ca09aeff73f88bcd Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Wed, 21 Apr 2021 16:26:04 +0300 Subject: [PATCH] [#490] cmd/neofs-node: Do not send rebootstrap after node went offline Control service turns storage node to online and offline modes. We can't reuse `cfgNetmap.reBootstrapEnabled` because it represents configuration value while control service manages state in runtime. Signed-off-by: Alex Vanin --- cmd/neofs-node/config.go | 4 +++- cmd/neofs-node/netmap.go | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index 8347cfbe..2258f85d 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -262,7 +262,8 @@ type cfgNetmap struct { state *networkState reBootstrapEnabled bool - reBootstrapInterval uint64 // in epochs + reBoostrapTurnedOff *atomic.Bool // managed by control service in runtime + reBootstrapInterval uint64 // in epochs goOfflineEnabled bool // send `UpdateState(offline)` tx at shutdown } @@ -377,6 +378,7 @@ func initCfg(path string) *cfg { workerPool: netmapWorkerPool, reBootstrapInterval: viperCfg.GetUint64(cfgReBootstrapInterval), reBootstrapEnabled: viperCfg.GetBool(cfgReBootstrapEnabled), + reBoostrapTurnedOff: atomic.NewBool(false), goOfflineEnabled: viperCfg.GetBool(cfgShutdownOfflineEnabled), }, cfgNodeInfo: cfgNodeInfo{ diff --git a/cmd/neofs-node/netmap.go b/cmd/neofs-node/netmap.go index 2333a648..26d17d41 100644 --- a/cmd/neofs-node/netmap.go +++ b/cmd/neofs-node/netmap.go @@ -75,6 +75,10 @@ func initNetmapService(c *cfg) { if c.cfgNetmap.reBootstrapEnabled { addNewEpochAsyncNotificationHandler(c, func(ev event.Event) { + if c.cfgNetmap.reBoostrapTurnedOff.Load() { // fixes #470 + return + } + n := ev.(netmapEvent.NewEpoch).EpochNumber() if n%c.cfgNetmap.reBootstrapInterval == 0 { @@ -202,6 +206,7 @@ func goOffline(c *cfg) { func (c *cfg) SetNetmapStatus(st control.NetmapStatus) error { if st == control.NetmapStatus_ONLINE { + c.cfgNetmap.reBoostrapTurnedOff.Store(false) return c.cfgNetmap.wrapper.AddPeer(c.toOnlineLocalNodeInfo()) } @@ -211,6 +216,8 @@ func (c *cfg) SetNetmapStatus(st control.NetmapStatus) error { apiState = netmapSDK.NodeStateOffline } + c.cfgNetmap.reBoostrapTurnedOff.Store(true) + return c.cfgNetmap.wrapper.UpdatePeerState( crypto.MarshalPublicKey(&c.key.PublicKey), apiState,