From 0903b2af931102867a89e1f36164c885a2709e0c Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 19 Sep 2022 20:12:20 +0400 Subject: [PATCH] [#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 --- pkg/morph/client/netmap/update_state.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/morph/client/netmap/update_state.go b/pkg/morph/client/netmap/update_state.go index 44a404d0..04c9c69c 100644 --- a/pkg/morph/client/netmap/update_state.go +++ b/pkg/morph/client/netmap/update_state.go @@ -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{}