From 10b548275a0881600e7a56b06892da28fd6dbc8e Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Wed, 23 Dec 2020 17:47:00 +0300 Subject: [PATCH] [#276] innerring: Use Head with TTL in PoR Signed-off-by: Alex Vanin --- pkg/innerring/rpc.go | 14 +++++++++++--- pkg/services/audit/auditor/context.go | 2 +- pkg/services/audit/auditor/pop.go | 2 +- pkg/services/audit/auditor/por.go | 2 +- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/pkg/innerring/rpc.go b/pkg/innerring/rpc.go index 44890a349e..dbf4d54e49 100644 --- a/pkg/innerring/rpc.go +++ b/pkg/innerring/rpc.go @@ -114,13 +114,21 @@ func (c *ClientCache) GetSG(task *audit.Task, id *object.ID) (*storagegroup.Stor } // GetHeader requests node from the container under audit to return object header by id. -func (c *ClientCache) GetHeader(task *audit.Task, node *netmap.Node, id *object.ID) (*object.Object, error) { +func (c *ClientCache) GetHeader(task *audit.Task, node *netmap.Node, id *object.ID, relay bool) (*object.Object, error) { + raw := true + ttl := uint32(1) + + if relay { + ttl = 10 // todo: instead of hardcode value we can set TTL based on container length + raw = false + } + objAddress := new(object.Address) objAddress.SetContainerID(task.ContainerID()) objAddress.SetObjectID(id) headParams := new(client.ObjectHeaderParams) - headParams.WithRawFlag(true) + headParams.WithRawFlag(raw) headParams.WithMainFields() headParams.WithAddress(objAddress) @@ -135,7 +143,7 @@ func (c *ClientCache) GetHeader(task *audit.Task, node *netmap.Node, id *object. } cctx, cancel := context.WithTimeout(task.AuditContext(), c.headTimeout) - head, err := cli.GetObjectHeader(cctx, headParams, client.WithTTL(1)) + head, err := cli.GetObjectHeader(cctx, headParams, client.WithTTL(ttl)) cancel() diff --git a/pkg/services/audit/auditor/context.go b/pkg/services/audit/auditor/context.go index eaef4ad90e..282c17f997 100644 --- a/pkg/services/audit/auditor/context.go +++ b/pkg/services/audit/auditor/context.go @@ -83,7 +83,7 @@ type ContainerCommunicator interface { GetSG(*audit.Task, *object.ID) (*storagegroup.StorageGroup, error) // Must return object header from the container node. - GetHeader(*audit.Task, *netmap.Node, *object.ID) (*object.Object, error) + GetHeader(*audit.Task, *netmap.Node, *object.ID, bool) (*object.Object, error) // Must return homomorphic Tillich-Zemor hash of payload range of the // object stored in container node. diff --git a/pkg/services/audit/auditor/pop.go b/pkg/services/audit/auditor/pop.go index c46351d1ad..bad3e9e6f8 100644 --- a/pkg/services/audit/auditor/pop.go +++ b/pkg/services/audit/auditor/pop.go @@ -50,7 +50,7 @@ func (c *Context) processObjectPlacement(id *object.ID, nodes netmap.Nodes, repl for i := 0; ok < replicas && i < len(nodes); i++ { // try to get object header from node - hdr, err := c.cnrCom.GetHeader(c.task, nodes[i], id) + hdr, err := c.cnrCom.GetHeader(c.task, nodes[i], id, false) if err != nil { c.log.Debug("could not get object header from candidate", zap.Stringer("id", id), diff --git a/pkg/services/audit/auditor/por.go b/pkg/services/audit/auditor/por.go index 82ade8e636..d783ded4ea 100644 --- a/pkg/services/audit/auditor/por.go +++ b/pkg/services/audit/auditor/por.go @@ -45,7 +45,7 @@ func (c *Context) checkStorageGroupPoR(ind int, sg *object.ID) { } for _, node := range placement.FlattenNodes(objectPlacement) { - hdr, err := c.cnrCom.GetHeader(c.task, node, members[i]) + 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()),