From 1cd8562db83b89134c1e4e17085c9713a911c97b Mon Sep 17 00:00:00 2001 From: Dmitrii Stepanov Date: Wed, 15 May 2024 16:11:51 +0300 Subject: [PATCH] [#1129] policer: Refactor shortage Drop override inside method. Signed-off-by: Dmitrii Stepanov --- pkg/services/policer/check.go | 21 ++++++++++----------- pkg/services/policer/ec.go | 4 +--- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/pkg/services/policer/check.go b/pkg/services/policer/check.go index 04456fb2..7120ba0b 100644 --- a/pkg/services/policer/check.go +++ b/pkg/services/policer/check.go @@ -64,7 +64,16 @@ func (p *Policer) processRepContainerObject(ctx context.Context, objInfo objectc default: } - p.processRepNodes(ctx, c, objInfo, nn[i], policy.ReplicaDescriptor(i).NumberOfObjects(), checkedNodes) + shortage := policy.ReplicaDescriptor(i).NumberOfObjects() + if objInfo.Type == objectSDK.TypeLock || objInfo.Type == objectSDK.TypeTombstone || objInfo.IsLinkingObject { + // all nodes of a container must store the `LOCK`, `TOMBSTONE` and linking objects + // for correct object removal protection: + // - `LOCK`, `TOMBSTONE` and linking objects are broadcast on their PUT requests; + // - `LOCK` object removal is a prohibited action in the GC. + shortage = uint32(len(nn[i])) + } + + p.processRepNodes(ctx, c, objInfo, nn[i], shortage, checkedNodes) } if !c.needLocalCopy && c.removeLocalCopy { @@ -89,19 +98,9 @@ func (p *Policer) processRepNodes(ctx context.Context, requirements *placementRe nodes []netmap.NodeInfo, shortage uint32, checkedNodes nodeCache, ) { addr := objInfo.Address - typ := objInfo.Type // Number of copies that are stored on maintenance nodes. var uncheckedCopies int - - if typ == objectSDK.TypeLock || typ == objectSDK.TypeTombstone || objInfo.IsLinkingObject { - // all nodes of a container must store the `LOCK`, `TOMBSTONE` and linking objects - // for correct object removal protection: - // - `LOCK`, `TOMBSTONE` and linking objects are broadcast on their PUT requests; - // - `LOCK` object removal is a prohibited action in the GC. - shortage = uint32(len(nodes)) - } - for i := 0; shortage > 0 && i < len(nodes); i++ { select { case <-ctx.Done(): diff --git a/pkg/services/policer/ec.go b/pkg/services/policer/ec.go index 6eca3bc0..fbd389d7 100644 --- a/pkg/services/policer/ec.go +++ b/pkg/services/policer/ec.go @@ -52,9 +52,7 @@ func (p *Policer) processECContainerRepObject(ctx context.Context, objInfo objec default: } - rd := policy.ReplicaDescriptor(0) - // processNodes replaces rd.GetECDataCount() + rd.GetECParityCount() for len(nn[0]) for locks, tomstones and linking objects. - p.processRepNodes(ctx, c, objInfo, nn[0], rd.GetECDataCount()+rd.GetECParityCount(), checkedNodes) + p.processRepNodes(ctx, c, objInfo, nn[0], uint32(len(nn[0])), checkedNodes) if !c.needLocalCopy && c.removeLocalCopy { p.log.Info(logs.PolicerRedundantLocalObjectCopyDetected,