forked from TrueCloudLab/frostfs-node
[#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:
parent
8858840751
commit
4c94faac67
1 changed files with 5 additions and 1 deletions
|
@ -321,8 +321,12 @@ var errRelayBootstrap = errors.New("setting netmap status is forbidden in relay
|
||||||
var errNodeMaintenance = errors.New("node is in maintenance mode")
|
var errNodeMaintenance = errors.New("node is in maintenance mode")
|
||||||
|
|
||||||
func (c *cfg) SetNetmapStatus(st control.NetmapStatus) error {
|
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)
|
return c.cfgObject.cfgLocalStorage.localStorage.BlockExecution(errNodeMaintenance)
|
||||||
|
case control.NetmapStatus_ONLINE, control.NetmapStatus_OFFLINE:
|
||||||
}
|
}
|
||||||
|
|
||||||
err := c.cfgObject.cfgLocalStorage.localStorage.ResumeExecution()
|
err := c.cfgObject.cfgLocalStorage.localStorage.ResumeExecution()
|
||||||
|
|
Loading…
Reference in a new issue