Skip to content

Commit

Permalink
[nspcc-dev#1797] node/control: Verify states in SetNetmapStatus RPC…
Browse files Browse the repository at this point in the history
… 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>
  • Loading branch information
Leonard Lyubich committed Sep 19, 2022
1 parent 4cb67c4 commit db61157
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmd/neofs-node/netmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,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 %d", 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()
Expand Down

0 comments on commit db61157

Please sign in to comment.