From 7a64a70b12106b320001b95b448920e8f761638b Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Wed, 12 May 2021 12:00:59 +0300 Subject: [PATCH] [#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 --- cmd/neofs-node/config.go | 5 ----- cmd/neofs-node/main.go | 4 ---- cmd/neofs-node/netmap.go | 15 --------------- 3 files changed, 24 deletions(-) diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index 950569f5..90541318 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -100,8 +100,6 @@ const ( cfgReBootstrapEnabled = "bootstrap.periodic.enabled" cfgReBootstrapInterval = "bootstrap.periodic.interval" - cfgShutdownOfflineEnabled = "shutdown.offline.enabled" - cfgObjectPutPoolSize = "pool.object.put.size" cfgObjectGetPoolSize = "pool.object.get.size" cfgObjectHeadPoolSize = "pool.object.head.size" @@ -253,8 +251,6 @@ type cfgNetmap struct { reBootstrapEnabled bool reBoostrapTurnedOff *atomic.Bool // managed by control service in runtime reBootstrapInterval uint64 // in epochs - - goOfflineEnabled bool // send `UpdateState(offline)` tx at shutdown } type BootstrapType uint32 @@ -384,7 +380,6 @@ func initCfg(path string) *cfg { reBootstrapInterval: viperCfg.GetUint64(cfgReBootstrapInterval), reBootstrapEnabled: !relayOnly && viperCfg.GetBool(cfgReBootstrapEnabled), reBoostrapTurnedOff: atomic.NewBool(relayOnly), - goOfflineEnabled: viperCfg.GetBool(cfgShutdownOfflineEnabled), }, cfgNodeInfo: cfgNodeInfo{ bootType: StorageNode, diff --git a/cmd/neofs-node/main.go b/cmd/neofs-node/main.go index a277d2e8..50350b1a 100644 --- a/cmd/neofs-node/main.go +++ b/cmd/neofs-node/main.go @@ -89,10 +89,6 @@ func shutdown(c *cfg) { closer() } - if c.cfgNetmap.goOfflineEnabled { - goOffline(c) - } - c.wg.Wait() } diff --git a/cmd/neofs-node/netmap.go b/cmd/neofs-node/netmap.go index 26d17d41..ea803ac2 100644 --- a/cmd/neofs-node/netmap.go +++ b/cmd/neofs-node/netmap.go @@ -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 { if st == control.NetmapStatus_ONLINE { c.cfgNetmap.reBoostrapTurnedOff.Store(false)