forked from TrueCloudLab/frostfs-node
[#xxx] Upgrade NeoFS SDK Go with changed container sessions
After recent changes in NeoFS SDK Go library session tokens aren't embedded into `container.Container` and `eacl.Table` structures. Group value, session token and signature in a structure for container and eACL. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
633b4e7d2d
commit
b67974a8d3
26 changed files with 152 additions and 168 deletions
|
@ -10,9 +10,7 @@ import (
|
|||
cntClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/container"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/services/object/acl/eacl"
|
||||
putsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/put"
|
||||
containerSDK "github.com/nspcc-dev/neofs-sdk-go/container"
|
||||
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
||||
eaclSDK "github.com/nspcc-dev/neofs-sdk-go/eacl"
|
||||
netmapSDK "github.com/nspcc-dev/neofs-sdk-go/netmap"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/user"
|
||||
)
|
||||
|
@ -147,13 +145,13 @@ func newCachedContainerStorage(v container.Source) *ttlContainerStorage {
|
|||
|
||||
// Get returns container value from the cache. If value is missing in the cache
|
||||
// or expired, then it returns value from side chain and updates the cache.
|
||||
func (s *ttlContainerStorage) Get(cnr cid.ID) (*containerSDK.Container, error) {
|
||||
func (s *ttlContainerStorage) Get(cnr cid.ID) (*container.Container, error) {
|
||||
val, err := (*ttlNetCache)(s).get(cnr.EncodeToString())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return val.(*containerSDK.Container), nil
|
||||
return val.(*container.Container), nil
|
||||
}
|
||||
|
||||
type ttlEACLStorage ttlNetCache
|
||||
|
@ -180,13 +178,13 @@ func newCachedEACLStorage(v eacl.Source) *ttlEACLStorage {
|
|||
|
||||
// GetEACL returns eACL value from the cache. If value is missing in the cache
|
||||
// or expired, then it returns value from side chain and updates cache.
|
||||
func (s *ttlEACLStorage) GetEACL(cnr cid.ID) (*eaclSDK.Table, error) {
|
||||
func (s *ttlEACLStorage) GetEACL(cnr cid.ID) (*container.EACL, error) {
|
||||
val, err := (*ttlNetCache)(s).get(cnr.EncodeToString())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return val.(*eaclSDK.Table), nil
|
||||
return val.(*container.EACL), nil
|
||||
}
|
||||
|
||||
// InvalidateEACL removes cached eACL value.
|
||||
|
|
|
@ -30,7 +30,6 @@ import (
|
|||
apiClient "github.com/nspcc-dev/neofs-sdk-go/client"
|
||||
containerSDK "github.com/nspcc-dev/neofs-sdk-go/container"
|
||||
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
||||
eaclSDK "github.com/nspcc-dev/neofs-sdk-go/eacl"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/netmap"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/user"
|
||||
"go.uber.org/zap"
|
||||
|
@ -355,7 +354,7 @@ func (l *loadPlacementBuilder) buildPlacement(epoch uint64, idCnr cid.ID) ([][]n
|
|||
return nil, nil, err
|
||||
}
|
||||
|
||||
policy := cnr.PlacementPolicy()
|
||||
policy := cnr.Value.PlacementPolicy()
|
||||
if policy == nil {
|
||||
return nil, nil, errors.New("missing placement policy in container")
|
||||
}
|
||||
|
@ -566,11 +565,11 @@ type morphContainerReader struct {
|
|||
}
|
||||
}
|
||||
|
||||
func (x *morphContainerReader) Get(id cid.ID) (*containerSDK.Container, error) {
|
||||
func (x *morphContainerReader) Get(id cid.ID) (*containerCore.Container, error) {
|
||||
return x.get.Get(id)
|
||||
}
|
||||
|
||||
func (x *morphContainerReader) GetEACL(id cid.ID) (*eaclSDK.Table, error) {
|
||||
func (x *morphContainerReader) GetEACL(id cid.ID) (*containerCore.EACL, error) {
|
||||
return x.eacl.GetEACL(id)
|
||||
}
|
||||
|
||||
|
@ -586,13 +585,13 @@ type morphContainerWriter struct {
|
|||
lists *ttlContainerLister
|
||||
}
|
||||
|
||||
func (m morphContainerWriter) Put(cnr *containerSDK.Container) (*cid.ID, error) {
|
||||
func (m morphContainerWriter) Put(cnr containerCore.Container) (*cid.ID, error) {
|
||||
containerID, err := cntClient.Put(m.neoClient, cnr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
idOwner := cnr.OwnerID()
|
||||
idOwner := cnr.Value.OwnerID()
|
||||
if idOwner == nil {
|
||||
return nil, errors.New("missing container owner")
|
||||
}
|
||||
|
@ -608,14 +607,14 @@ func (m morphContainerWriter) Delete(witness containerCore.RemovalWitness) error
|
|||
return cntClient.Delete(m.neoClient, witness)
|
||||
}
|
||||
|
||||
func (m morphContainerWriter) PutEACL(table *eaclSDK.Table) error {
|
||||
err := cntClient.PutEACL(m.neoClient, table)
|
||||
func (m morphContainerWriter) PutEACL(eaclInfo containerCore.EACL) error {
|
||||
err := cntClient.PutEACL(m.neoClient, eaclInfo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if m.cacheEnabled {
|
||||
id, _ := table.CID()
|
||||
id, _ := eaclInfo.Value.CID()
|
||||
m.eacls.InvalidateEACL(id)
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
policerconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/policer"
|
||||
replicatorconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/replicator"
|
||||
coreclient "github.com/nspcc-dev/neofs-node/pkg/core/client"
|
||||
containercore "github.com/nspcc-dev/neofs-node/pkg/core/container"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/core/netmap"
|
||||
objectCore "github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine"
|
||||
|
@ -402,29 +403,23 @@ type morphEACLFetcher struct {
|
|||
w *cntClient.Client
|
||||
}
|
||||
|
||||
func (s *morphEACLFetcher) GetEACL(cnr cid.ID) (*eaclSDK.Table, error) {
|
||||
table, err := s.w.GetEACL(cnr)
|
||||
func (s *morphEACLFetcher) GetEACL(cnr cid.ID) (*containercore.EACL, error) {
|
||||
eaclInfo, err := s.w.GetEACL(cnr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
sig := table.Signature()
|
||||
if sig == nil {
|
||||
// TODO(@cthulhu-rider): #1387 use "const" error
|
||||
return nil, errors.New("missing signature")
|
||||
}
|
||||
|
||||
binTable, err := table.Marshal()
|
||||
binTable, err := eaclInfo.Value.Marshal()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("marshal eACL table: %w", err)
|
||||
}
|
||||
|
||||
if !sig.Verify(binTable) {
|
||||
if !eaclInfo.Signature.Verify(binTable) {
|
||||
// TODO(@cthulhu-rider): #1387 use "const" error
|
||||
return nil, errors.New("invalid signature of the eACL table")
|
||||
}
|
||||
|
||||
return table, nil
|
||||
return eaclInfo, nil
|
||||
}
|
||||
|
||||
type reputationClientConstructor struct {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue