From 3dbff0a478d60423ccb5a5d84934bd977c50e913 Mon Sep 17 00:00:00 2001 From: Dmitrii Stepanov Date: Thu, 6 Apr 2023 09:45:10 +0300 Subject: [PATCH] [#222] auditsvc: Resolve containedctx linter Resolve containedctx linter for commonCommunicatorPrm type. Signed-off-by: Dmitrii Stepanov --- pkg/innerring/rpc.go | 8 ++++---- pkg/services/audit/auditor/context.go | 7 ++----- pkg/services/audit/auditor/pdp.go | 3 +-- pkg/services/audit/auditor/pop.go | 3 +-- pkg/services/audit/auditor/por.go | 3 +-- 5 files changed, 9 insertions(+), 15 deletions(-) diff --git a/pkg/innerring/rpc.go b/pkg/innerring/rpc.go index 665e94232..c58e0ddc4 100644 --- a/pkg/innerring/rpc.go +++ b/pkg/innerring/rpc.go @@ -131,7 +131,7 @@ func (c *ClientCache) getSG(ctx context.Context, addr oid.Address, nm *netmap.Ne } // GetHeader requests node from the container under audit to return object header by id. -func (c *ClientCache) GetHeader(prm auditor.GetHeaderPrm) (*object.Object, error) { +func (c *ClientCache) GetHeader(ctx context.Context, prm auditor.GetHeaderPrm) (*object.Object, error) { var objAddress oid.Address objAddress.SetContainer(prm.CID) objAddress.SetObject(prm.OID) @@ -148,7 +148,7 @@ func (c *ClientCache) GetHeader(prm auditor.GetHeaderPrm) (*object.Object, error return nil, fmt.Errorf("can't setup remote connection with %s: %w", info.AddressGroup(), err) } - cctx, cancel := context.WithTimeout(prm.Context, c.headTimeout) + cctx, cancel := context.WithTimeout(ctx, c.headTimeout) var obj *object.Object @@ -169,7 +169,7 @@ func (c *ClientCache) GetHeader(prm auditor.GetHeaderPrm) (*object.Object, error // GetRangeHash requests node from the container under audit to return Tillich-Zemor hash of the // payload range of the object with specified identifier. -func (c *ClientCache) GetRangeHash(prm auditor.GetRangeHashPrm) ([]byte, error) { +func (c *ClientCache) GetRangeHash(ctx context.Context, prm auditor.GetRangeHashPrm) ([]byte, error) { var objAddress oid.Address objAddress.SetContainer(prm.CID) objAddress.SetObject(prm.OID) @@ -186,7 +186,7 @@ func (c *ClientCache) GetRangeHash(prm auditor.GetRangeHashPrm) ([]byte, error) return nil, fmt.Errorf("can't setup remote connection with %s: %w", info.AddressGroup(), err) } - cctx, cancel := context.WithTimeout(prm.Context, c.rangeTimeout) + cctx, cancel := context.WithTimeout(ctx, c.rangeTimeout) h, err := frostfsapiclient.HashObjectRange(cctx, cli, objAddress, prm.Range) diff --git a/pkg/services/audit/auditor/context.go b/pkg/services/audit/auditor/context.go index 4a5cbb457..f2778fd65 100644 --- a/pkg/services/audit/auditor/context.go +++ b/pkg/services/audit/auditor/context.go @@ -81,10 +81,7 @@ type ContextPrm struct { pdpWorkerPool, porWorkerPool util.WorkerPool } -// nolint: containedctx type commonCommunicatorPrm struct { - Context context.Context - Node netmap.NodeInfo OID oid.ID @@ -109,11 +106,11 @@ type GetRangeHashPrm struct { // component of communication with container nodes. type ContainerCommunicator interface { // GetHeader must return object header from the container node. - GetHeader(GetHeaderPrm) (*object.Object, error) + GetHeader(context.Context, GetHeaderPrm) (*object.Object, error) // GetRangeHash must return homomorphic Tillich-Zemor hash of payload range of the // object stored in container node. - GetRangeHash(GetRangeHashPrm) ([]byte, error) + GetRangeHash(context.Context, GetRangeHashPrm) ([]byte, error) } // NewContext creates, initializes and returns Context. diff --git a/pkg/services/audit/auditor/pdp.go b/pkg/services/audit/auditor/pdp.go index beb2fdcf8..13b50e498 100644 --- a/pkg/services/audit/auditor/pdp.go +++ b/pkg/services/audit/auditor/pdp.go @@ -118,7 +118,6 @@ func (c *Context) collectHashes(p *gamePair) { rand.Shuffle(len(order), func(i, j int) { order[i], order[j] = order[j], order[i] }) var getRangeHashPrm GetRangeHashPrm - getRangeHashPrm.Context = c.task.AuditContext() getRangeHashPrm.CID = c.task.ContainerID() getRangeHashPrm.OID = p.id getRangeHashPrm.Node = n @@ -138,7 +137,7 @@ func (c *Context) collectHashes(p *gamePair) { getRangeHashPrm.Range = rngs[i] - h, err := c.cnrCom.GetRangeHash(getRangeHashPrm) + h, err := c.cnrCom.GetRangeHash(c.task.AuditContext(), getRangeHashPrm) if err != nil { c.log.Debug("could not get payload range hash", zap.Stringer("id", p.id), diff --git a/pkg/services/audit/auditor/pop.go b/pkg/services/audit/auditor/pop.go index f8a16cb0a..45afa7937 100644 --- a/pkg/services/audit/auditor/pop.go +++ b/pkg/services/audit/auditor/pop.go @@ -49,7 +49,6 @@ func (c *Context) processObjectPlacement(id oid.ID, nodes []netmap.NodeInfo, rep ) var getHeaderPrm GetHeaderPrm - getHeaderPrm.Context = c.task.AuditContext() getHeaderPrm.OID = id getHeaderPrm.CID = c.task.ContainerID() getHeaderPrm.NodeIsRelay = false @@ -58,7 +57,7 @@ func (c *Context) processObjectPlacement(id oid.ID, nodes []netmap.NodeInfo, rep getHeaderPrm.Node = nodes[i] // try to get object header from node - hdr, err := c.cnrCom.GetHeader(getHeaderPrm) + hdr, err := c.cnrCom.GetHeader(c.task.AuditContext(), getHeaderPrm) 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 1922213e5..ff322d6e1 100644 --- a/pkg/services/audit/auditor/por.go +++ b/pkg/services/audit/auditor/por.go @@ -48,7 +48,6 @@ func (c *Context) checkStorageGroupPoR(sgID oid.ID, sg storagegroupSDK.StorageGr ) var getHeaderPrm GetHeaderPrm - getHeaderPrm.Context = c.task.AuditContext() getHeaderPrm.CID = c.task.ContainerID() getHeaderPrm.NodeIsRelay = true @@ -81,7 +80,7 @@ func (c *Context) checkStorageGroupPoR(sgID oid.ID, sg storagegroupSDK.StorageGr getHeaderPrm.Node = flat[j] - hdr, err := c.cnrCom.GetHeader(getHeaderPrm) + hdr, err := c.cnrCom.GetHeader(c.task.AuditContext(), getHeaderPrm) if err != nil { c.log.Debug("can't head object", zap.String("remote_node", netmap.StringifyPublicKey(flat[j])),