forked from TrueCloudLab/frostfs-node
[#492] node: Never go offline on application shutdown
Application can be shut down often, it is undesirable to send status changes on a transaction every time. Control API should be used before shutdown for this purpose. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
10308101df
commit
7a64a70b12
3 changed files with 0 additions and 24 deletions
|
@ -100,8 +100,6 @@ const (
|
||||||
cfgReBootstrapEnabled = "bootstrap.periodic.enabled"
|
cfgReBootstrapEnabled = "bootstrap.periodic.enabled"
|
||||||
cfgReBootstrapInterval = "bootstrap.periodic.interval"
|
cfgReBootstrapInterval = "bootstrap.periodic.interval"
|
||||||
|
|
||||||
cfgShutdownOfflineEnabled = "shutdown.offline.enabled"
|
|
||||||
|
|
||||||
cfgObjectPutPoolSize = "pool.object.put.size"
|
cfgObjectPutPoolSize = "pool.object.put.size"
|
||||||
cfgObjectGetPoolSize = "pool.object.get.size"
|
cfgObjectGetPoolSize = "pool.object.get.size"
|
||||||
cfgObjectHeadPoolSize = "pool.object.head.size"
|
cfgObjectHeadPoolSize = "pool.object.head.size"
|
||||||
|
@ -253,8 +251,6 @@ type cfgNetmap struct {
|
||||||
reBootstrapEnabled bool
|
reBootstrapEnabled bool
|
||||||
reBoostrapTurnedOff *atomic.Bool // managed by control service in runtime
|
reBoostrapTurnedOff *atomic.Bool // managed by control service in runtime
|
||||||
reBootstrapInterval uint64 // in epochs
|
reBootstrapInterval uint64 // in epochs
|
||||||
|
|
||||||
goOfflineEnabled bool // send `UpdateState(offline)` tx at shutdown
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type BootstrapType uint32
|
type BootstrapType uint32
|
||||||
|
@ -384,7 +380,6 @@ func initCfg(path string) *cfg {
|
||||||
reBootstrapInterval: viperCfg.GetUint64(cfgReBootstrapInterval),
|
reBootstrapInterval: viperCfg.GetUint64(cfgReBootstrapInterval),
|
||||||
reBootstrapEnabled: !relayOnly && viperCfg.GetBool(cfgReBootstrapEnabled),
|
reBootstrapEnabled: !relayOnly && viperCfg.GetBool(cfgReBootstrapEnabled),
|
||||||
reBoostrapTurnedOff: atomic.NewBool(relayOnly),
|
reBoostrapTurnedOff: atomic.NewBool(relayOnly),
|
||||||
goOfflineEnabled: viperCfg.GetBool(cfgShutdownOfflineEnabled),
|
|
||||||
},
|
},
|
||||||
cfgNodeInfo: cfgNodeInfo{
|
cfgNodeInfo: cfgNodeInfo{
|
||||||
bootType: StorageNode,
|
bootType: StorageNode,
|
||||||
|
|
|
@ -89,10 +89,6 @@ func shutdown(c *cfg) {
|
||||||
closer()
|
closer()
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.cfgNetmap.goOfflineEnabled {
|
|
||||||
goOffline(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
c.wg.Wait()
|
c.wg.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -189,21 +189,6 @@ func addNewEpochAsyncNotificationHandler(c *cfg, h event.Handler) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func goOffline(c *cfg) {
|
|
||||||
err := c.cfgNetmap.wrapper.UpdatePeerState(
|
|
||||||
crypto.MarshalPublicKey(&c.key.PublicKey),
|
|
||||||
netmapSDK.NodeStateOffline,
|
|
||||||
)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
c.log.Error("could not go offline",
|
|
||||||
zap.String("error", err.Error()),
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
c.log.Info("request to go offline successfully sent")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *cfg) SetNetmapStatus(st control.NetmapStatus) error {
|
func (c *cfg) SetNetmapStatus(st control.NetmapStatus) error {
|
||||||
if st == control.NetmapStatus_ONLINE {
|
if st == control.NetmapStatus_ONLINE {
|
||||||
c.cfgNetmap.reBoostrapTurnedOff.Store(false)
|
c.cfgNetmap.reBoostrapTurnedOff.Store(false)
|
||||||
|
|
Loading…
Reference in a new issue