From 9273a89f615a4f7cf8607de45250a7cf4ceaa0d6 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Wed, 23 Dec 2020 17:57:50 +0300 Subject: [PATCH] [#276] service/audit: Use random nodes for object.Head in PoR Since PoR audit check uses object.Head with large TTL values to make real proof of retrievability, we may use random remote nodes. Signed-off-by: Alex Vanin --- pkg/services/audit/auditor/por.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/services/audit/auditor/por.go b/pkg/services/audit/auditor/por.go index d783ded4e..59d29f647 100644 --- a/pkg/services/audit/auditor/por.go +++ b/pkg/services/audit/auditor/por.go @@ -5,6 +5,7 @@ import ( "github.com/nspcc-dev/neofs-api-go/pkg/object" "github.com/nspcc-dev/neofs-node/pkg/services/object_manager/placement" + "github.com/nspcc-dev/neofs-node/pkg/util/rand" "github.com/nspcc-dev/tzhash/tz" "go.uber.org/zap" ) @@ -44,13 +45,22 @@ func (c *Context) checkStorageGroupPoR(ind int, sg *object.ID) { continue } - for _, node := range placement.FlattenNodes(objectPlacement) { + flat := placement.FlattenNodes(objectPlacement) + + crand := rand.New() // math/rand with cryptographic source + crand.Shuffle(len(flat), func(i, j int) { + flat[i], flat[j] = flat[j], flat[i] + }) + + for _, node := range flat { hdr, err := c.cnrCom.GetHeader(c.task, node, members[i], true) if err != nil { c.log.Debug("can't head object", zap.String("remote_node", node.Address()), zap.Stringer("oid", members[i])) + // todo: count all fails and successes for audit report + continue }