forked from TrueCloudLab/frostfs-node
[#761] cmd/node: Do not perform bootstrap procedure in relay mode
Storage node should not try to register itself in network in relay mode. Implement `needBootstrap` method which checks if node need to bootstrap. Call `bootstrap` method in `bootstrapNode` function only on true return. Skip re-bootstrap logic in new epoch event handler on false return. Return an error if `ControlService.SetNetmapStatus` is called on relay node. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
05d5b724a9
commit
7a5729ea2b
2 changed files with 17 additions and 3 deletions
|
@ -443,3 +443,8 @@ func (c *cfg) bootstrap() error {
|
||||||
|
|
||||||
return c.cfgNetmap.wrapper.AddPeer(&ni)
|
return c.cfgNetmap.wrapper.AddPeer(&ni)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// needBootstrap checks if local node should be registered in network on bootup.
|
||||||
|
func (c *cfg) needBootstrap() bool {
|
||||||
|
return c.cfgNetmap.needBootstrap
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"errors"
|
||||||
|
|
||||||
netmapSDK "github.com/nspcc-dev/neofs-api-go/pkg/netmap"
|
netmapSDK "github.com/nspcc-dev/neofs-api-go/pkg/netmap"
|
||||||
netmapV2 "github.com/nspcc-dev/neofs-api-go/v2/netmap"
|
netmapV2 "github.com/nspcc-dev/neofs-api-go/v2/netmap"
|
||||||
|
@ -113,7 +114,7 @@ func initNetmapService(c *cfg) {
|
||||||
})
|
})
|
||||||
|
|
||||||
addNewEpochAsyncNotificationHandler(c, func(ev event.Event) {
|
addNewEpochAsyncNotificationHandler(c, func(ev event.Event) {
|
||||||
if c.cfgNetmap.reBoostrapTurnedOff.Load() { // fixes #470
|
if !c.needBootstrap() || c.cfgNetmap.reBoostrapTurnedOff.Load() { // fixes #470
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,8 +150,10 @@ func initNetmapService(c *cfg) {
|
||||||
func bootstrapNode(c *cfg) {
|
func bootstrapNode(c *cfg) {
|
||||||
initState(c)
|
initState(c)
|
||||||
|
|
||||||
err := c.bootstrap()
|
if c.needBootstrap() {
|
||||||
fatalOnErrDetails("bootstrap error", err)
|
err := c.bootstrap()
|
||||||
|
fatalOnErrDetails("bootstrap error", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func addNetmapNotificationHandler(c *cfg, sTyp string, h event.Handler) {
|
func addNetmapNotificationHandler(c *cfg, sTyp string, h event.Handler) {
|
||||||
|
@ -228,7 +231,13 @@ func addNewEpochAsyncNotificationHandler(c *cfg, h event.Handler) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var errRelayBootstrap = errors.New("setting netmap status is forbidden in relay mode")
|
||||||
|
|
||||||
func (c *cfg) SetNetmapStatus(st control.NetmapStatus) error {
|
func (c *cfg) SetNetmapStatus(st control.NetmapStatus) error {
|
||||||
|
if !c.needBootstrap() {
|
||||||
|
return errRelayBootstrap
|
||||||
|
}
|
||||||
|
|
||||||
if st == control.NetmapStatus_ONLINE {
|
if st == control.NetmapStatus_ONLINE {
|
||||||
c.cfgNetmap.reBoostrapTurnedOff.Store(false)
|
c.cfgNetmap.reBoostrapTurnedOff.Store(false)
|
||||||
return c.bootstrap()
|
return c.bootstrap()
|
||||||
|
|
Loading…
Reference in a new issue