[#1681] node: Block only Object service ops under maintenance

In previous implementation node blocked any operation of local object
storage in maintenance mode. There is a need to perform some storage
operations like data evacuation or restoration.

Do not call block storage engine in maintenance mode. Make all Object
service operations to return `apistatus.NodeUnderMaintenance` error from
each local op.

Signed-off-by: Leonard Lyubich <ctulhurider@gmail.com>
This commit is contained in:
Leonard Lyubich 2022-10-04 17:01:16 +04:00 committed by fyrchik
parent 082602b668
commit 713aea06fa
8 changed files with 86 additions and 31 deletions

View file

@ -253,18 +253,18 @@ func initObjectService(c *cfg) {
c.workers = append(c.workers, pol)
var os putsvc.ObjectStorage
var os putsvc.ObjectStorage = engineWithoutNotifications{
e: ls,
state: c,
}
if c.cfgNotifications.enabled {
os = engineWithNotifications{
e: ls,
base: os,
nw: c.cfgNotifications.nw,
ns: c.cfgNetmap.state,
defaultTopic: c.cfgNotifications.defaultTopic,
}
} else {
os = engineWithoutNotifications{
e: ls,
}
}
sPut := putsvc.NewService(
@ -291,7 +291,7 @@ func initObjectService(c *cfg) {
sSearch := searchsvc.New(
searchsvc.WithLogger(c.log),
searchsvc.WithLocalStorageEngine(ls),
searchsvc.WithLocalStorageEngine(ls, c),
searchsvc.WithClientConstructor(coreConstructor),
searchsvc.WithTraverserGenerator(
traverseGen.WithTraverseOptions(
@ -318,6 +318,7 @@ func initObjectService(c *cfg) {
),
getsvc.WithNetMapSource(c.netMapSource),
getsvc.WithKeyStorage(keyStorage),
getsvc.WithNodeState(c),
)
*c.cfgObject.getSvc = *sGet // need smth better
@ -552,15 +553,15 @@ func (c *reputationClientConstructor) Get(info coreclient.NodeInfo) (coreclient.
}
type engineWithNotifications struct {
e *engine.StorageEngine
nw notificationWriter
ns netmap.State
base putsvc.ObjectStorage
nw notificationWriter
ns netmap.State
defaultTopic string
}
func (e engineWithNotifications) Put(o *objectSDK.Object) error {
if err := engine.Put(e.e, o); err != nil {
if err := e.base.Put(o); err != nil {
return err
}
@ -582,8 +583,16 @@ func (e engineWithNotifications) Put(o *objectSDK.Object) error {
type engineWithoutNotifications struct {
e *engine.StorageEngine
state util.NodeState
}
func (e engineWithoutNotifications) Put(o *objectSDK.Object) error {
if e.state.IsMaintenance() {
var st apistatus.NodeUnderMaintenance
return st
}
return engine.Put(e.e, o)
}