From 6b1ce99c352cff231aae97399e698d53afff9b94 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Tue, 9 Nov 2021 18:54:03 +0300 Subject: [PATCH] [#922] node: Block data ops of storage engine via Control API There is a need to block execution of local object storage operations if node is put into maintenance mode (resume if the node is taken out of maintenance mode). Call `BlockExecution` method if `ControlService.SetNetmapStatus` was called with `MAINTENANCE` status. Call `ResumeExecution` if it was called with another status. Signed-off-by: Leonard Lyubich --- cmd/neofs-node/netmap.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cmd/neofs-node/netmap.go b/cmd/neofs-node/netmap.go index 88c372b29..eed30d9a4 100644 --- a/cmd/neofs-node/netmap.go +++ b/cmd/neofs-node/netmap.go @@ -252,7 +252,20 @@ func addNewEpochAsyncNotificationHandler(c *cfg, h event.Handler) { var errRelayBootstrap = errors.New("setting netmap status is forbidden in relay mode") +var errNodeMaintenance = errors.New("node is in maintenance mode") + func (c *cfg) SetNetmapStatus(st control.NetmapStatus) error { + if st == control.NetmapStatus_MAINTENANCE { + return c.cfgObject.cfgLocalStorage.localStorage.BlockExecution(errNodeMaintenance) + } + + err := c.cfgObject.cfgLocalStorage.localStorage.ResumeExecution() + if err != nil { + c.log.Error("failed to resume local object operations", + zap.String("error", err.Error()), + ) + } + if !c.needBootstrap() { return errRelayBootstrap }