[#248] core: Remove storage group

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
pull/278/head
Evgenii Stratonikov 2023-04-25 09:35:58 +03:00
parent f1ea8fec93
commit 586f5986bc
3 changed files with 0 additions and 164 deletions

View File

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

View File

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

View File

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