forked from TrueCloudLab/frostfs-node
[#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:
parent
6b99f2a0df
commit
0903b2af93
1 changed files with 10 additions and 0 deletions
|
@ -11,6 +11,7 @@ import (
|
||||||
const (
|
const (
|
||||||
stateOffline int8 = iota
|
stateOffline int8 = iota
|
||||||
stateOnline
|
stateOnline
|
||||||
|
stateMaintenance
|
||||||
)
|
)
|
||||||
|
|
||||||
// UpdatePeerPrm groups parameters of UpdatePeerState operation.
|
// UpdatePeerPrm groups parameters of UpdatePeerState operation.
|
||||||
|
@ -34,6 +35,13 @@ func (u *UpdatePeerPrm) SetOnline() {
|
||||||
u.state = stateOnline
|
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.
|
// UpdatePeerState changes peer status through Netmap contract call.
|
||||||
func (c *Client) UpdatePeerState(p UpdatePeerPrm) error {
|
func (c *Client) UpdatePeerState(p UpdatePeerPrm) error {
|
||||||
method := updateStateMethod
|
method := updateStateMethod
|
||||||
|
@ -54,6 +62,8 @@ func (c *Client) UpdatePeerState(p UpdatePeerPrm) error {
|
||||||
// already set above
|
// already set above
|
||||||
case stateOnline:
|
case stateOnline:
|
||||||
state = netmap.OnlineState
|
state = netmap.OnlineState
|
||||||
|
case stateMaintenance:
|
||||||
|
state = netmap.OfflineState + 1 // FIXME: use named constant after neofs-contract#269
|
||||||
}
|
}
|
||||||
|
|
||||||
prm := client.InvokePrm{}
|
prm := client.InvokePrm{}
|
||||||
|
|
Loading…
Reference in a new issue