From 586f5986bc1401d46a41ef27657c21b47f036649 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 25 Apr 2023 09:35:58 +0300 Subject: [PATCH] [#248] core: Remove storage group Signed-off-by: Evgenii Stratonikov --- pkg/core/object/fmt.go | 40 --------------- pkg/core/object/fmt_test.go | 54 --------------------- pkg/core/storagegroup/storagegroup.go | 70 --------------------------- 3 files changed, 164 deletions(-) delete mode 100644 pkg/core/storagegroup/storagegroup.go diff --git a/pkg/core/object/fmt.go b/pkg/core/object/fmt.go index ef99f30589..946cfc462f 100644 --- a/pkg/core/object/fmt.go +++ b/pkg/core/object/fmt.go @@ -14,7 +14,6 @@ import ( frostfsecdsa "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/crypto/ecdsa" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object" oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id" - "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/storagegroup" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/user" ) @@ -65,8 +64,6 @@ var errNoExpirationEpoch = errors.New("missing expiration epoch attribute") var errTombstoneExpiration = errors.New("tombstone body and header contain different expiration values") -var errEmptySGMembers = errors.New("storage group with empty members list") - func defaultCfg() *cfg { return new(cfg) } @@ -180,7 +177,6 @@ func (v *FormatValidator) checkOwnerKey(id user.ID, key frostfsecdsa.PublicKey) // ContentMeta describes FrostFS meta information that brings object's payload if the object // is one of: // - object.TypeTombstone; -// - object.TypeStorageGroup; // - object.TypeLock. type ContentMeta struct { typ object.Type @@ -196,7 +192,6 @@ func (i ContentMeta) Type() object.Type { // Objects returns objects that the original object's payload affects: // - inhumed objects, if the original object is a Tombstone; // - locked objects, if the original object is a Lock; -// - members of a storage group, if the original object is a Storage group; // - nil, if the original object is a Regular object. func (i ContentMeta) Objects() []oid.ID { return i.objs @@ -213,10 +208,6 @@ func (v *FormatValidator) ValidateContent(o *object.Object) (ContentMeta, error) if err := v.fillAndValidateTombstoneMeta(o, &meta); err != nil { return ContentMeta{}, err } - case object.TypeStorageGroup: - if err := v.fillAndValidateStorageGroupMeta(o, &meta); err != nil { - return ContentMeta{}, err - } case object.TypeLock: if err := v.fillAndValidateLockMeta(o, &meta); err != nil { return ContentMeta{}, err @@ -266,37 +257,6 @@ func (v *FormatValidator) fillAndValidateLockMeta(o *object.Object, meta *Conten return nil } -func (v *FormatValidator) fillAndValidateStorageGroupMeta(o *object.Object, meta *ContentMeta) error { - if len(o.Payload()) == 0 { - return fmt.Errorf("(%T) empty payload in storage group", v) - } - - var sg storagegroup.StorageGroup - - if err := sg.Unmarshal(o.Payload()); err != nil { - return fmt.Errorf("(%T) could not unmarshal storage group content: %w", v, err) - } - - mm := sg.Members() - meta.objs = mm - - lenMM := len(mm) - if lenMM == 0 { - return errEmptySGMembers - } - - uniqueFilter := make(map[oid.ID]struct{}, lenMM) - - for i := 0; i < lenMM; i++ { - if _, alreadySeen := uniqueFilter[mm[i]]; alreadySeen { - return fmt.Errorf("storage group contains non-unique member: %s", mm[i]) - } - - uniqueFilter[mm[i]] = struct{}{} - } - return nil -} - func (v *FormatValidator) fillAndValidateTombstoneMeta(o *object.Object, meta *ContentMeta) error { if len(o.Payload()) == 0 { return fmt.Errorf("(%T) empty payload in tombstone", v) diff --git a/pkg/core/object/fmt_test.go b/pkg/core/object/fmt_test.go index be0602540b..2cf5099ba8 100644 --- a/pkg/core/object/fmt_test.go +++ b/pkg/core/object/fmt_test.go @@ -12,7 +12,6 @@ import ( oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id" oidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test" sessiontest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/session/test" - "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/storagegroup" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/user" "github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/stretchr/testify/require" @@ -167,59 +166,6 @@ func TestFormatValidator_Validate(t *testing.T) { require.Equal(t, object.TypeTombstone, contentGot.Type()) }) - t.Run("storage group content", func(t *testing.T) { - obj := object.New() - obj.SetType(object.TypeStorageGroup) - - t.Run("empty payload", func(t *testing.T) { - _, err := v.ValidateContent(obj) - require.Error(t, err) - }) - - var content storagegroup.StorageGroup - content.SetExpirationEpoch(1) // some non-default value - - t.Run("empty members", func(t *testing.T) { - data, err := content.Marshal() - require.NoError(t, err) - - obj.SetPayload(data) - - _, err = v.ValidateContent(obj) - require.ErrorIs(t, err, errEmptySGMembers) - }) - - t.Run("non-unique members", func(t *testing.T) { - id := oidtest.ID() - - content.SetMembers([]oid.ID{id, id}) - - data, err := content.Marshal() - require.NoError(t, err) - - obj.SetPayload(data) - - _, err = v.ValidateContent(obj) - require.Error(t, err) - }) - - t.Run("correct SG", func(t *testing.T) { - ids := []oid.ID{oidtest.ID(), oidtest.ID()} - content.SetMembers(ids) - - data, err := content.Marshal() - require.NoError(t, err) - - obj.SetPayload(data) - - content, err := v.ValidateContent(obj) - require.NoError(t, err) - - require.EqualValues(t, ids, content.Objects()) - require.Equal(t, object.TypeStorageGroup, content.Type()) - }) - }) - t.Run("expiration", func(t *testing.T) { fn := func(val string) *object.Object { obj := blankValidObject(&ownerKey.PrivateKey) diff --git a/pkg/core/storagegroup/storagegroup.go b/pkg/core/storagegroup/storagegroup.go deleted file mode 100644 index b16e5c61a9..0000000000 --- a/pkg/core/storagegroup/storagegroup.go +++ /dev/null @@ -1,70 +0,0 @@ -package storagegroup - -import ( - "context" - - "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/client" - cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id" - "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap" - oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id" - "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/storagegroup" -) - -// SearchSGPrm groups the parameters which are formed by Processor to search the storage group objects. -type SearchSGPrm struct { - Container cid.ID - - NodeInfo client.NodeInfo -} - -// SearchSGDst groups the target values which Processor expects from SG searching to process. -type SearchSGDst struct { - Objects []oid.ID -} - -// GetSGPrm groups parameter of GetSG operation. -type GetSGPrm struct { - OID oid.ID - CID cid.ID - - NetMap netmap.NetMap - Container [][]netmap.NodeInfo -} - -// SGSource is a storage group information source interface. -type SGSource interface { - // 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(context.Context, *SearchSGDst, SearchSGPrm) error - - // GetSG must return storage group object for the provided CID, OID, - // container and netmap state. - GetSG(context.Context, GetSGPrm) (*storagegroup.StorageGroup, error) -} - -// StorageGroup combines storage group object ID and its structure. -type StorageGroup struct { - id oid.ID - sg storagegroup.StorageGroup -} - -// ID returns object ID of the storage group. -func (s StorageGroup) ID() oid.ID { - return s.id -} - -// SetID sets an object ID of the storage group. -func (s *StorageGroup) SetID(id oid.ID) { - s.id = id -} - -// StorageGroup returns the storage group descriptor. -func (s StorageGroup) StorageGroup() storagegroup.StorageGroup { - return s.sg -} - -// SetStorageGroup sets a storage group descriptor. -func (s *StorageGroup) SetStorageGroup(sg storagegroup.StorageGroup) { - s.sg = sg -}