forked from TrueCloudLab/frostfs-node
[#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 <alexey@nspcc.ru>
This commit is contained in:
parent
de74fcc38f
commit
e9b3488aab
2 changed files with 10 additions and 1 deletions
|
@ -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{
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue