From 7864959d0cfdc6bc275a8db692c2474084d583e2 Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Thu, 19 May 2022 22:39:43 +0300 Subject: [PATCH] [#1402] ir: Move `GetSG` interface `auditor` does not need to request SG: processor will fetch that info before audit context initialization. Signed-off-by: Pavel Karpy --- pkg/innerring/processors/audit/processor.go | 19 ++++++++++++++++++- pkg/innerring/rpc.go | 4 ++-- pkg/services/audit/auditor/context.go | 17 ++--------------- pkg/services/audit/auditor/por.go | 5 +++-- 4 files changed, 25 insertions(+), 20 deletions(-) diff --git a/pkg/innerring/processors/audit/processor.go b/pkg/innerring/processors/audit/processor.go index f2491abe7..cdcad0636 100644 --- a/pkg/innerring/processors/audit/processor.go +++ b/pkg/innerring/processors/audit/processor.go @@ -13,7 +13,9 @@ import ( "github.com/nspcc-dev/neofs-node/pkg/morph/event" "github.com/nspcc-dev/neofs-node/pkg/services/audit" cid "github.com/nspcc-dev/neofs-sdk-go/container/id" + "github.com/nspcc-dev/neofs-sdk-go/netmap" oid "github.com/nspcc-dev/neofs-sdk-go/object/id" + storagegroupSDK "github.com/nspcc-dev/neofs-sdk-go/storagegroup" "github.com/panjf2000/ants/v2" "go.uber.org/zap" ) @@ -97,12 +99,27 @@ func (x *SearchSGDst) WriteIDList(ids []oid.ID) { x.ids = ids } +// GetSGPrm groups parameter of GetSG operation. +type GetSGPrm struct { + Context context.Context + + OID oid.ID + CID cid.ID + + NetMap netmap.NetMap + Container [][]netmap.NodeInfo +} + // SGSource is a storage group information source interface. type SGSource interface { - // Lists storage group objects in the container. Formed list must be written to destination. + // ListSG must list storage group objects in the container. Formed list must be written to destination. // // Must return any error encountered which did not allow to form the list. ListSG(*SearchSGDst, SearchSGPrm) error + + // GetSG must return storage group object for the provided CID, OID, + // container and netmap state. + GetSG(GetSGPrm) (*storagegroupSDK.StorageGroup, error) } type epochAuditReporter struct { diff --git a/pkg/innerring/rpc.go b/pkg/innerring/rpc.go index 92bc9ae73..bc7928154 100644 --- a/pkg/innerring/rpc.go +++ b/pkg/innerring/rpc.go @@ -62,12 +62,12 @@ func (c *ClientCache) Get(info clientcore.NodeInfo) (clientcore.Client, error) { // Returns storage groups structure from received object. // // Returns an error of type apistatus.ObjectNotFound if storage group is missing. -func (c *ClientCache) GetSG(prm auditor.GetSGPrm) (*storagegroup.StorageGroup, error) { +func (c *ClientCache) GetSG(prm auditproc.GetSGPrm) (*storagegroup.StorageGroup, error) { var sgAddress oid.Address sgAddress.SetContainer(prm.CID) sgAddress.SetObject(prm.OID) - return c.getSG(prm.Context, sgAddress, prm.NetMap, prm.Container) + return c.getSG(prm.Context, sgAddress, &prm.NetMap, prm.Container) } func (c *ClientCache) getSG(ctx context.Context, addr oid.Address, nm *netmap.NetMap, cn [][]netmap.NodeInfo) (*storagegroup.StorageGroup, error) { diff --git a/pkg/services/audit/auditor/context.go b/pkg/services/audit/auditor/context.go index 87c545214..0028644ee 100644 --- a/pkg/services/audit/auditor/context.go +++ b/pkg/services/audit/auditor/context.go @@ -13,7 +13,6 @@ import ( "github.com/nspcc-dev/neofs-sdk-go/netmap" "github.com/nspcc-dev/neofs-sdk-go/object" oid "github.com/nspcc-dev/neofs-sdk-go/object/id" - "github.com/nspcc-dev/neofs-sdk-go/storagegroup" "go.uber.org/atomic" "go.uber.org/zap" ) @@ -85,24 +84,16 @@ type ContextPrm struct { type commonCommunicatorPrm struct { Context context.Context + Node netmap.NodeInfo + OID oid.ID CID cid.ID } -// GetSGPrm groups parameter of GetSG operation. -type GetSGPrm struct { - commonCommunicatorPrm - - NetMap *netmap.NetMap - Container [][]netmap.NodeInfo -} - // GetHeaderPrm groups parameter of GetHeader operation. type GetHeaderPrm struct { commonCommunicatorPrm - Node netmap.NodeInfo - NodeIsRelay bool } @@ -110,16 +101,12 @@ type GetHeaderPrm struct { type GetRangeHashPrm struct { commonCommunicatorPrm - Node netmap.NodeInfo Range *object.Range } // ContainerCommunicator is an interface of // component of communication with container nodes. type ContainerCommunicator interface { - // GetSG must return storage group structure stored in object from container. - GetSG(GetSGPrm) (*storagegroup.StorageGroup, error) - // GetHeader must return object header from the container node. GetHeader(GetHeaderPrm) (*object.Object, error) diff --git a/pkg/services/audit/auditor/por.go b/pkg/services/audit/auditor/por.go index 625cc4bb0..04232e3d0 100644 --- a/pkg/services/audit/auditor/por.go +++ b/pkg/services/audit/auditor/por.go @@ -5,6 +5,7 @@ import ( "encoding/hex" "sync" + "github.com/nspcc-dev/neofs-node/pkg/innerring/processors/audit" "github.com/nspcc-dev/neofs-node/pkg/services/object_manager/placement" "github.com/nspcc-dev/neofs-node/pkg/util/rand" oid "github.com/nspcc-dev/neofs-sdk-go/object/id" @@ -36,12 +37,12 @@ func (c *Context) executePoR() { } func (c *Context) checkStorageGroupPoR(ind int, sg oid.ID) { - var getSgPrm GetSGPrm + var getSgPrm audit.GetSGPrm getSgPrm.Context = c.task.AuditContext() getSgPrm.CID = c.task.ContainerID() getSgPrm.OID = sg - getSgPrm.NetMap = c.task.NetworkMap() + getSgPrm.NetMap = *c.task.NetworkMap() getSgPrm.Container = c.task.ContainerNodes() storageGroup, err := c.cnrCom.GetSG(getSgPrm) // get storage group