[#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 <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2020-12-23 17:57:50 +03:00 committed by Alex Vanin
parent 10b548275a
commit 9273a89f61

View file

@ -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
}