[#1797] node/control: Verify states in SetNetmapStatus RPC server

In previous implementation storage node interpreted all status values
sent in `SetNetmapStatus` RPC as `OFFLINE` except `ONLINE` and
`MAINTENANCE`. This could lead to incorrect processing of new values,
and also didn't allow detection of problems with sending garbage values.

Make implementation of `NodeState` interface used by Control API server
to deny requests with statuses other than protocol-declared enum.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2022-09-19 16:41:04 +04:00 committed by fyrchik
parent 8858840751
commit 4c94faac67

View file

@ -321,8 +321,12 @@ var errRelayBootstrap = errors.New("setting netmap status is forbidden in relay
var errNodeMaintenance = errors.New("node is in maintenance mode")
func (c *cfg) SetNetmapStatus(st control.NetmapStatus) error {
if st == control.NetmapStatus_MAINTENANCE {
switch st {
default:
return fmt.Errorf("unsupported status %v", st)
case control.NetmapStatus_MAINTENANCE:
return c.cfgObject.cfgLocalStorage.localStorage.BlockExecution(errNodeMaintenance)
case control.NetmapStatus_ONLINE, control.NetmapStatus_OFFLINE:
}
err := c.cfgObject.cfgLocalStorage.localStorage.ResumeExecution()