From e99e25b52f2fdc271926f43fef05e1ed0996c27c Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Fri, 7 Oct 2022 13:33:37 +0400 Subject: [PATCH] [#1680] replicator: Consider nodes under maintenance as OK Nodes under maintenance SHOULD not respond to object requests. Based on this, storage node's Policer SHOULD consider such nodes as problem ones. However, to prevent spam with the new replicas, on the contrary, Policer should consider them normal. Make `Policer.processNodes` to exclude elements if `IsMaintenance()` with shortage decreasing. Signed-off-by: Leonard Lyubich --- CHANGELOG.md | 1 + pkg/services/policer/check.go | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67249c581..990489f9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ Changelog for NeoFS Node - Allow to evacuate shard data with `EvacuateShard` control RPC (#1800) - Flush write-cache when moving shard to DEGRADED mode (#1825) - Make `morph.cache_ttl` default value equal to morph block time (#1846) +- Policer marks nodes under maintenance as OK without requests (#1680) ### Fixed - Description of command `netmap nodeinfo` (#1821) diff --git a/pkg/services/policer/check.go b/pkg/services/policer/check.go index e303219a0..2bd31e272 100644 --- a/pkg/services/policer/check.go +++ b/pkg/services/policer/check.go @@ -2,6 +2,7 @@ package policer import ( "context" + "encoding/hex" "github.com/nspcc-dev/neofs-node/pkg/core/container" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine" @@ -142,6 +143,18 @@ func (p *Policer) processNodes(ctx *processPlacementContext, addr oid.Address, nodes []netmap.NodeInfo, shortage uint32, checkedNodes *nodeCache) { prm := new(headsvc.RemoteHeadPrm).WithObjectAddress(addr) + handleMaintenance := func(node netmap.NodeInfo) { + // consider remote nodes under maintenance as problem OK. Such + // nodes MAY not respond with object, however, this is how we + // prevent spam with new replicas. + checkedNodes.submitReplicaHolder(node) + shortage-- + + p.log.Debug("consider node under maintenance as OK", + zap.String("node", hex.EncodeToString(node.PublicKey())), + ) + } + for i := 0; shortage > 0 && i < len(nodes); i++ { select { case <-ctx.Done(): @@ -153,6 +166,8 @@ func (p *Policer) processNodes(ctx *processPlacementContext, addr oid.Address, ctx.needLocalCopy = true shortage-- + } else if nodes[i].IsMaintenance() { + handleMaintenance(nodes[i]) } else { if status := checkedNodes.processStatus(nodes[i]); status >= 0 { if status == 0 {