forked from TrueCloudLab/frostfs-node
[#367] cmd/neofs-node: Don't update local node info for bootstrap
At startup, update only node info status. Leave all other attributes from node configuration, so user can update them. Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
3775d61ccb
commit
9618c3e268
2 changed files with 33 additions and 15 deletions
|
@ -657,28 +657,26 @@ func (c *cfg) LocalNodeInfo() (*netmapV2.NodeInfo, error) {
|
||||||
return ni.ToV2(), nil
|
return ni.ToV2(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handleLocalNodeInfo rewrites local node info
|
||||||
func (c *cfg) handleLocalNodeInfo(ni *netmap.NodeInfo) {
|
func (c *cfg) handleLocalNodeInfo(ni *netmap.NodeInfo) {
|
||||||
c.cfgNodeInfo.infoMtx.Lock()
|
c.cfgNodeInfo.infoMtx.Lock()
|
||||||
|
|
||||||
var nmState netmap.NodeState
|
|
||||||
|
|
||||||
if ni != nil {
|
if ni != nil {
|
||||||
c.cfgNodeInfo.info = *ni
|
c.cfgNodeInfo.info = *ni
|
||||||
nmState = ni.State()
|
|
||||||
} else {
|
|
||||||
nmState = netmap.NodeStateOffline
|
|
||||||
c.cfgNodeInfo.info.SetState(nmState)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch nmState {
|
c.updateStatusWithoutLock(ni)
|
||||||
default:
|
|
||||||
c.setNetmapStatus(control.NetmapStatus_STATUS_UNDEFINED)
|
c.cfgNodeInfo.infoMtx.Unlock()
|
||||||
case netmap.NodeStateOnline:
|
|
||||||
c.setNetmapStatus(control.NetmapStatus_ONLINE)
|
|
||||||
case netmap.NodeStateOffline:
|
|
||||||
c.setNetmapStatus(control.NetmapStatus_OFFLINE)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handleNodeInfoStatus updates node info status without rewriting whole local
|
||||||
|
// node info status
|
||||||
|
func (c *cfg) handleNodeInfoStatus(ni *netmap.NodeInfo) {
|
||||||
|
c.cfgNodeInfo.infoMtx.Lock()
|
||||||
|
|
||||||
|
c.updateStatusWithoutLock(ni)
|
||||||
|
|
||||||
c.cfgNodeInfo.infoMtx.Unlock()
|
c.cfgNodeInfo.infoMtx.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -695,3 +693,23 @@ func (c *cfg) toOnlineLocalNodeInfo() *netmap.NodeInfo {
|
||||||
|
|
||||||
return &ni
|
return &ni
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *cfg) updateStatusWithoutLock(ni *netmap.NodeInfo) {
|
||||||
|
var nmState netmap.NodeState
|
||||||
|
|
||||||
|
if ni != nil {
|
||||||
|
nmState = ni.State()
|
||||||
|
} else {
|
||||||
|
nmState = netmap.NodeStateOffline
|
||||||
|
c.cfgNodeInfo.info.SetState(nmState)
|
||||||
|
}
|
||||||
|
|
||||||
|
switch nmState {
|
||||||
|
default:
|
||||||
|
c.setNetmapStatus(control.NetmapStatus_STATUS_UNDEFINED)
|
||||||
|
case netmap.NodeStateOnline:
|
||||||
|
c.setNetmapStatus(control.NetmapStatus_ONLINE)
|
||||||
|
case netmap.NodeStateOffline:
|
||||||
|
c.setNetmapStatus(control.NetmapStatus_OFFLINE)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ func initState(c *cfg) {
|
||||||
ni, err := c.netmapLocalNodeState(epoch)
|
ni, err := c.netmapLocalNodeState(epoch)
|
||||||
fatalOnErr(errors.Wrap(err, "could not init network state"))
|
fatalOnErr(errors.Wrap(err, "could not init network state"))
|
||||||
|
|
||||||
c.handleLocalNodeInfo(ni)
|
c.handleNodeInfoStatus(ni)
|
||||||
|
|
||||||
c.log.Info("initial network state",
|
c.log.Info("initial network state",
|
||||||
zap.Uint64("epoch", epoch),
|
zap.Uint64("epoch", epoch),
|
||||||
|
|
Loading…
Reference in a new issue