[#1680] morph/netmap: Allow to set MAINTENANCE state

After recent changes in NeoFS protocol storage nodes can be in
`MAINTENANCE` state. There is a need to support this state in
`UpdateState` operation.

Add `UpdatePeerPrm.SetMaintenance` method which makes node to be
switched into `MAINTENANCE` mode after the `UpdatePeerState` operation.

New functionality is going to be used in Storage node application for
Control API serving.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2022-09-19 20:12:20 +04:00 committed by fyrchik
parent 6b99f2a0df
commit 0903b2af93

View file

@ -11,6 +11,7 @@ import (
const (
stateOffline int8 = iota
stateOnline
stateMaintenance
)
// UpdatePeerPrm groups parameters of UpdatePeerState operation.
@ -34,6 +35,13 @@ func (u *UpdatePeerPrm) SetOnline() {
u.state = stateOnline
}
// SetMaintenance marks node to be switched into "maintenance" state.
//
// Zero UpdatePeerPrm marks node as "offline".
func (u *UpdatePeerPrm) SetMaintenance() {
u.state = stateMaintenance
}
// UpdatePeerState changes peer status through Netmap contract call.
func (c *Client) UpdatePeerState(p UpdatePeerPrm) error {
method := updateStateMethod
@ -54,6 +62,8 @@ func (c *Client) UpdatePeerState(p UpdatePeerPrm) error {
// already set above
case stateOnline:
state = netmap.OnlineState
case stateMaintenance:
state = netmap.OfflineState + 1 // FIXME: use named constant after neofs-contract#269
}
prm := client.InvokePrm{}