[#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 <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-11-09 18:54:03 +03:00 committed by Alex Vanin
parent 29644e9bc2
commit 6b1ce99c35

View file

@ -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
}