From 98034005f1bb6af378620bf4e0fdc0a38b5f63b7 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Fri, 28 Oct 2022 11:08:49 +0400 Subject: [PATCH] [#1900] node: Fix loosing the "maintenance" status In previous implementation node lost maintenance status after successful switching to it. For example, after some period of time node sent bootstrap requests with the "online" state instead of "maintenance". Make `startMaintenance` method to set maintenance status in the `networkState`. Signed-off-by: Leonard Lyubich --- CHANGELOG.md | 1 + cmd/neofs-node/config.go | 3 ++- cmd/neofs-node/netmap.go | 9 ++++++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7534810b..953e182d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ Changelog for NeoFS Node - Make it possible to use `shard.ContainerSize` in read-only mode (#1975) - Storage node now starts if at least one gRPC enpoint is available (#1893) - Missing object relatives in object removal session opened by NeoFS CLI (#1978) +- Bringing a node back online during maintenance (#1900) ### Removed ### Updated diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index 6c632a6e1..7ecdad335 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -312,8 +312,9 @@ type internals struct { } // starts node's maintenance. -func (c *internals) startMaintenance() { +func (c *cfg) startMaintenance() { c.isMaintenance.Store(true) + c.cfgNetmap.state.setControlNetmapStatus(control.NetmapStatus_MAINTENANCE) c.log.Info("started local node's maintenance") } diff --git a/cmd/neofs-node/netmap.go b/cmd/neofs-node/netmap.go index 3c12faf84..080a47e11 100644 --- a/cmd/neofs-node/netmap.go +++ b/cmd/neofs-node/netmap.go @@ -84,7 +84,14 @@ func (s *networkState) setNodeInfo(ni *netmapSDK.NodeInfo) { } } - s.controlNetStatus.Store(ctrlNetSt) + s.setControlNetmapStatus(ctrlNetSt) +} + +// sets the current node state to the given value. Subsequent cfg.bootstrap +// calls will process this value to decide what status node should set in the +// network. +func (s *networkState) setControlNetmapStatus(st control.NetmapStatus) { + s.controlNetStatus.Store(st) } func (s *networkState) controlNetmapStatus() (res control.NetmapStatus) {