Small fixes for netmap status transitions #1110
2 changed files with 24 additions and 23 deletions
|
@ -388,8 +388,9 @@ func (c *cfg) startMaintenance() {
|
||||||
|
|
||||||
// stops node's maintenance.
|
// stops node's maintenance.
|
||||||
func (c *internals) stopMaintenance() {
|
func (c *internals) stopMaintenance() {
|
||||||
c.isMaintenance.Store(false)
|
if c.isMaintenance.CompareAndSwap(true, false) {
|
||||||
c.log.Info(logs.FrostFSNodeStoppedLocalNodesMaintenance)
|
c.log.Info(logs.FrostFSNodeStoppedLocalNodesMaintenance)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsMaintenance checks if storage node is under maintenance.
|
// IsMaintenance checks if storage node is under maintenance.
|
||||||
|
@ -1157,13 +1158,25 @@ func (c *cfg) LocalNodeInfo() (*netmapV2.NodeInfo, error) {
|
||||||
return &res, nil
|
return &res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleLocalNodeInfo rewrites local node info from the FrostFS network map.
|
// setContractNodeInfo rewrites local node info from the FrostFS network map.
|
||||||
// Called with nil when storage node is outside the FrostFS network map
|
// Called with nil when storage node is outside the FrostFS network map
|
||||||
// (before entering the network and after leaving it).
|
// (before entering the network and after leaving it).
|
||||||
func (c *cfg) handleLocalNodeInfo(ni *netmap.NodeInfo) {
|
func (c *cfg) setContractNodeInfo(ni *netmap.NodeInfo) {
|
||||||
c.cfgNetmap.state.setNodeInfo(ni)
|
c.cfgNetmap.state.setNodeInfo(ni)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *cfg) updateContractNodeInfo(epoch uint64) {
|
||||||
|
ni, err := c.netmapLocalNodeState(epoch)
|
||||||
|
if err != nil {
|
||||||
|
c.log.Error(logs.FrostFSNodeCouldNotUpdateNodeStateOnNewEpoch,
|
||||||
|
zap.Uint64("epoch", epoch),
|
||||||
|
zap.String("error", err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.setContractNodeInfo(ni)
|
||||||
|
}
|
||||||
|
|
||||||
// bootstrapWithState calls "addPeer" method of the Sidechain Netmap contract
|
// bootstrapWithState calls "addPeer" method of the Sidechain Netmap contract
|
||||||
// with the binary-encoded information from the current node's configuration.
|
// with the binary-encoded information from the current node's configuration.
|
||||||
// The state is set using the provided setter which MUST NOT be nil.
|
// The state is set using the provided setter which MUST NOT be nil.
|
||||||
|
|
|
@ -31,7 +31,7 @@ type networkState struct {
|
||||||
|
|
||||||
controlNetStatus atomic.Int32 // control.NetmapStatus
|
controlNetStatus atomic.Int32 // control.NetmapStatus
|
||||||
|
|
||||||
nodeInfo atomic.Value // *netmapSDK.NodeInfo
|
nodeInfo atomic.Value // netmapSDK.NodeInfo
|
||||||
|
|
||||||
metrics *metrics.NodeMetrics
|
metrics *metrics.NodeMetrics
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,11 @@ func addNewEpochNotificationHandlers(c *cfg) {
|
||||||
c.cfgNetmap.state.setCurrentEpoch(ev.(netmapEvent.NewEpoch).EpochNumber())
|
c.cfgNetmap.state.setCurrentEpoch(ev.(netmapEvent.NewEpoch).EpochNumber())
|
||||||
})
|
})
|
||||||
|
|
||||||
addNewEpochAsyncNotificationHandler(c, func(_ event.Event) {
|
addNewEpochAsyncNotificationHandler(c, func(ev event.Event) {
|
||||||
|
e := ev.(netmapEvent.NewEpoch).EpochNumber()
|
||||||
|
|
||||||
|
c.updateContractNodeInfo(e)
|
||||||
|
|
||||||
if !c.needBootstrap() || c.cfgNetmap.reBoostrapTurnedOff.Load() { // fixes #470
|
if !c.needBootstrap() || c.cfgNetmap.reBoostrapTurnedOff.Load() { // fixes #470
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -186,22 +190,6 @@ func addNewEpochNotificationHandlers(c *cfg) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
addNewEpochAsyncNotificationHandler(c, func(ev event.Event) {
|
|
||||||
e := ev.(netmapEvent.NewEpoch).EpochNumber()
|
|
||||||
|
|
||||||
ni, err := c.netmapLocalNodeState(e)
|
|
||||||
if err != nil {
|
|
||||||
c.log.Error(logs.FrostFSNodeCouldNotUpdateNodeStateOnNewEpoch,
|
|
||||||
zap.Uint64("epoch", e),
|
|
||||||
zap.String("error", err.Error()),
|
|
||||||
)
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
c.handleLocalNodeInfo(ni)
|
|
||||||
})
|
|
||||||
|
|
||||||
if c.cfgMorph.notaryEnabled {
|
if c.cfgMorph.notaryEnabled {
|
||||||
addNewEpochAsyncNotificationHandler(c, func(_ event.Event) {
|
addNewEpochAsyncNotificationHandler(c, func(_ event.Event) {
|
||||||
_, err := makeNotaryDeposit(c)
|
_, err := makeNotaryDeposit(c)
|
||||||
|
@ -270,7 +258,7 @@ func initNetmapState(c *cfg) {
|
||||||
|
|
||||||
c.cfgNetmap.state.setCurrentEpoch(epoch)
|
c.cfgNetmap.state.setCurrentEpoch(epoch)
|
||||||
c.cfgNetmap.startEpoch = epoch
|
c.cfgNetmap.startEpoch = epoch
|
||||||
c.handleLocalNodeInfo(ni)
|
c.setContractNodeInfo(ni)
|
||||||
}
|
}
|
||||||
|
|
||||||
func nodeState(ni *netmapSDK.NodeInfo) string {
|
func nodeState(ni *netmapSDK.NodeInfo) string {
|
||||||
|
|
Loading…
Add table
Reference in a new issue