forked from TrueCloudLab/frostfs-node
[#1613] morph: Add tracing for morph queries to neo-go
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
This commit is contained in:
parent
4de5fca547
commit
9b113c3156
120 changed files with 623 additions and 562 deletions
|
@ -127,7 +127,7 @@ func awaitSetNetmapStatus(cmd *cobra.Command, pk *ecdsa.PrivateKey, cli *client.
|
||||||
var resp *control.GetNetmapStatusResponse
|
var resp *control.GetNetmapStatusResponse
|
||||||
var err error
|
var err error
|
||||||
err = cli.ExecRaw(func(client *rawclient.Client) error {
|
err = cli.ExecRaw(func(client *rawclient.Client) error {
|
||||||
resp, err = control.GetNetmapStatus(client, req)
|
resp, err = control.GetNetmapStatus(cmd.Context(), client, req)
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
commonCmd.ExitOnErr(cmd, "failed to get current netmap status: %w", err)
|
commonCmd.ExitOnErr(cmd, "failed to get current netmap status: %w", err)
|
||||||
|
|
|
@ -320,7 +320,7 @@ func getReplicaRequiredPlacement(cmd *cobra.Command, objects []phyObject, placem
|
||||||
}
|
}
|
||||||
placementBuilder := placement.NewNetworkMapBuilder(netmap)
|
placementBuilder := placement.NewNetworkMapBuilder(netmap)
|
||||||
for _, object := range objects {
|
for _, object := range objects {
|
||||||
placement, err := placementBuilder.BuildPlacement(object.containerID, &object.objectID, placementPolicy)
|
placement, err := placementBuilder.BuildPlacement(cmd.Context(), object.containerID, &object.objectID, placementPolicy)
|
||||||
commonCmd.ExitOnErr(cmd, "failed to get required placement for object: %w", err)
|
commonCmd.ExitOnErr(cmd, "failed to get required placement for object: %w", err)
|
||||||
for repIdx, rep := range placement {
|
for repIdx, rep := range placement {
|
||||||
numOfReplicas := placementPolicy.ReplicaDescriptor(repIdx).NumberOfObjects()
|
numOfReplicas := placementPolicy.ReplicaDescriptor(repIdx).NumberOfObjects()
|
||||||
|
@ -358,7 +358,7 @@ func getECRequiredPlacementInternal(cmd *cobra.Command, object phyObject, placem
|
||||||
placementObjectID = object.ecHeader.parent
|
placementObjectID = object.ecHeader.parent
|
||||||
}
|
}
|
||||||
placementBuilder := placement.NewNetworkMapBuilder(netmap)
|
placementBuilder := placement.NewNetworkMapBuilder(netmap)
|
||||||
placement, err := placementBuilder.BuildPlacement(object.containerID, &placementObjectID, placementPolicy)
|
placement, err := placementBuilder.BuildPlacement(cmd.Context(), object.containerID, &placementObjectID, placementPolicy)
|
||||||
commonCmd.ExitOnErr(cmd, "failed to get required placement: %w", err)
|
commonCmd.ExitOnErr(cmd, "failed to get required placement: %w", err)
|
||||||
|
|
||||||
for _, vector := range placement {
|
for _, vector := range placement {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -16,7 +17,7 @@ import (
|
||||||
"github.com/hashicorp/golang-lru/v2/expirable"
|
"github.com/hashicorp/golang-lru/v2/expirable"
|
||||||
)
|
)
|
||||||
|
|
||||||
type netValueReader[K any, V any] func(K) (V, error)
|
type netValueReader[K any, V any] func(ctx context.Context, cid K) (V, error)
|
||||||
|
|
||||||
type valueWithError[V any] struct {
|
type valueWithError[V any] struct {
|
||||||
v V
|
v V
|
||||||
|
@ -49,7 +50,7 @@ func newNetworkTTLCache[K comparable, V any](sz int, ttl time.Duration, netRdr n
|
||||||
// updates the value from the network on cache miss or by TTL.
|
// updates the value from the network on cache miss or by TTL.
|
||||||
//
|
//
|
||||||
// returned value should not be modified.
|
// returned value should not be modified.
|
||||||
func (c *ttlNetCache[K, V]) get(key K) (V, error) {
|
func (c *ttlNetCache[K, V]) get(ctx context.Context, key K) (V, error) {
|
||||||
hit := false
|
hit := false
|
||||||
startedAt := time.Now()
|
startedAt := time.Now()
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -71,7 +72,7 @@ func (c *ttlNetCache[K, V]) get(key K) (V, error) {
|
||||||
return val.v, val.e
|
return val.v, val.e
|
||||||
}
|
}
|
||||||
|
|
||||||
v, err := c.netRdr(key)
|
v, err := c.netRdr(ctx, key)
|
||||||
|
|
||||||
c.cache.Add(key, &valueWithError[V]{
|
c.cache.Add(key, &valueWithError[V]{
|
||||||
v: v,
|
v: v,
|
||||||
|
@ -135,7 +136,7 @@ func newNetworkLRUCache(sz int, netRdr netValueReader[uint64, *netmapSDK.NetMap]
|
||||||
// updates the value from the network on cache miss.
|
// updates the value from the network on cache miss.
|
||||||
//
|
//
|
||||||
// returned value should not be modified.
|
// returned value should not be modified.
|
||||||
func (c *lruNetCache) get(key uint64) (*netmapSDK.NetMap, error) {
|
func (c *lruNetCache) get(ctx context.Context, key uint64) (*netmapSDK.NetMap, error) {
|
||||||
hit := false
|
hit := false
|
||||||
startedAt := time.Now()
|
startedAt := time.Now()
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -148,7 +149,7 @@ func (c *lruNetCache) get(key uint64) (*netmapSDK.NetMap, error) {
|
||||||
return val, nil
|
return val, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
val, err := c.netRdr(key)
|
val, err := c.netRdr(ctx, key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -166,11 +167,11 @@ type ttlContainerStorage struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func newCachedContainerStorage(v container.Source, ttl time.Duration, containerCacheSize uint32) ttlContainerStorage {
|
func newCachedContainerStorage(v container.Source, ttl time.Duration, containerCacheSize uint32) ttlContainerStorage {
|
||||||
lruCnrCache := newNetworkTTLCache(int(containerCacheSize), ttl, func(id cid.ID) (*container.Container, error) {
|
lruCnrCache := newNetworkTTLCache(int(containerCacheSize), ttl, func(ctx context.Context, id cid.ID) (*container.Container, error) {
|
||||||
return v.Get(id)
|
return v.Get(ctx, id)
|
||||||
}, metrics.NewCacheMetrics("container"))
|
}, metrics.NewCacheMetrics("container"))
|
||||||
lruDelInfoCache := newNetworkTTLCache(int(containerCacheSize), ttl, func(id cid.ID) (*container.DelInfo, error) {
|
lruDelInfoCache := newNetworkTTLCache(int(containerCacheSize), ttl, func(ctx context.Context, id cid.ID) (*container.DelInfo, error) {
|
||||||
return v.DeletionInfo(id)
|
return v.DeletionInfo(ctx, id)
|
||||||
}, metrics.NewCacheMetrics("container_deletion_info"))
|
}, metrics.NewCacheMetrics("container_deletion_info"))
|
||||||
|
|
||||||
return ttlContainerStorage{
|
return ttlContainerStorage{
|
||||||
|
@ -188,12 +189,12 @@ func (s ttlContainerStorage) handleRemoval(cnr cid.ID) {
|
||||||
|
|
||||||
// Get returns container value from the cache. If value is missing in the cache
|
// 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.
|
// or expired, then it returns value from side chain and updates the cache.
|
||||||
func (s ttlContainerStorage) Get(cnr cid.ID) (*container.Container, error) {
|
func (s ttlContainerStorage) Get(ctx context.Context, cnr cid.ID) (*container.Container, error) {
|
||||||
return s.containerCache.get(cnr)
|
return s.containerCache.get(ctx, cnr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s ttlContainerStorage) DeletionInfo(cnr cid.ID) (*container.DelInfo, error) {
|
func (s ttlContainerStorage) DeletionInfo(ctx context.Context, cnr cid.ID) (*container.DelInfo, error) {
|
||||||
return s.delInfoCache.get(cnr)
|
return s.delInfoCache.get(ctx, cnr)
|
||||||
}
|
}
|
||||||
|
|
||||||
type lruNetmapSource struct {
|
type lruNetmapSource struct {
|
||||||
|
@ -205,8 +206,8 @@ type lruNetmapSource struct {
|
||||||
func newCachedNetmapStorage(s netmap.State, v netmap.Source) netmap.Source {
|
func newCachedNetmapStorage(s netmap.State, v netmap.Source) netmap.Source {
|
||||||
const netmapCacheSize = 10
|
const netmapCacheSize = 10
|
||||||
|
|
||||||
lruNetmapCache := newNetworkLRUCache(netmapCacheSize, func(key uint64) (*netmapSDK.NetMap, error) {
|
lruNetmapCache := newNetworkLRUCache(netmapCacheSize, func(ctx context.Context, key uint64) (*netmapSDK.NetMap, error) {
|
||||||
return v.GetNetMapByEpoch(key)
|
return v.GetNetMapByEpoch(ctx, key)
|
||||||
}, metrics.NewCacheMetrics("netmap"))
|
}, metrics.NewCacheMetrics("netmap"))
|
||||||
|
|
||||||
return &lruNetmapSource{
|
return &lruNetmapSource{
|
||||||
|
@ -215,16 +216,16 @@ func newCachedNetmapStorage(s netmap.State, v netmap.Source) netmap.Source {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *lruNetmapSource) GetNetMap(diff uint64) (*netmapSDK.NetMap, error) {
|
func (s *lruNetmapSource) GetNetMap(ctx context.Context, diff uint64) (*netmapSDK.NetMap, error) {
|
||||||
return s.getNetMapByEpoch(s.netState.CurrentEpoch() - diff)
|
return s.getNetMapByEpoch(ctx, s.netState.CurrentEpoch()-diff)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *lruNetmapSource) GetNetMapByEpoch(epoch uint64) (*netmapSDK.NetMap, error) {
|
func (s *lruNetmapSource) GetNetMapByEpoch(ctx context.Context, epoch uint64) (*netmapSDK.NetMap, error) {
|
||||||
return s.getNetMapByEpoch(epoch)
|
return s.getNetMapByEpoch(ctx, epoch)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *lruNetmapSource) getNetMapByEpoch(epoch uint64) (*netmapSDK.NetMap, error) {
|
func (s *lruNetmapSource) getNetMapByEpoch(ctx context.Context, epoch uint64) (*netmapSDK.NetMap, error) {
|
||||||
val, err := s.cache.get(epoch)
|
val, err := s.cache.get(ctx, epoch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -232,7 +233,7 @@ func (s *lruNetmapSource) getNetMapByEpoch(epoch uint64) (*netmapSDK.NetMap, err
|
||||||
return val, nil
|
return val, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *lruNetmapSource) Epoch() (uint64, error) {
|
func (s *lruNetmapSource) Epoch(_ context.Context) (uint64, error) {
|
||||||
return s.netState.CurrentEpoch(), nil
|
return s.netState.CurrentEpoch(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,7 +241,10 @@ type cachedIRFetcher struct {
|
||||||
*ttlNetCache[struct{}, [][]byte]
|
*ttlNetCache[struct{}, [][]byte]
|
||||||
}
|
}
|
||||||
|
|
||||||
func newCachedIRFetcher(f interface{ InnerRingKeys() ([][]byte, error) }) cachedIRFetcher {
|
func newCachedIRFetcher(f interface {
|
||||||
|
InnerRingKeys(ctx context.Context) ([][]byte, error)
|
||||||
|
},
|
||||||
|
) cachedIRFetcher {
|
||||||
const (
|
const (
|
||||||
irFetcherCacheSize = 1 // we intend to store only one value
|
irFetcherCacheSize = 1 // we intend to store only one value
|
||||||
|
|
||||||
|
@ -254,8 +258,8 @@ func newCachedIRFetcher(f interface{ InnerRingKeys() ([][]byte, error) }) cached
|
||||||
)
|
)
|
||||||
|
|
||||||
irFetcherCache := newNetworkTTLCache(irFetcherCacheSize, irFetcherCacheTTL,
|
irFetcherCache := newNetworkTTLCache(irFetcherCacheSize, irFetcherCacheTTL,
|
||||||
func(_ struct{}) ([][]byte, error) {
|
func(ctx context.Context, _ struct{}) ([][]byte, error) {
|
||||||
return f.InnerRingKeys()
|
return f.InnerRingKeys(ctx)
|
||||||
}, metrics.NewCacheMetrics("ir_keys"),
|
}, metrics.NewCacheMetrics("ir_keys"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -265,8 +269,8 @@ func newCachedIRFetcher(f interface{ InnerRingKeys() ([][]byte, error) }) cached
|
||||||
// InnerRingKeys returns cached list of Inner Ring keys. If keys are missing in
|
// InnerRingKeys returns cached list of Inner Ring keys. If keys are missing in
|
||||||
// the cache or expired, then it returns keys from side chain and updates
|
// the cache or expired, then it returns keys from side chain and updates
|
||||||
// the cache.
|
// the cache.
|
||||||
func (f cachedIRFetcher) InnerRingKeys() ([][]byte, error) {
|
func (f cachedIRFetcher) InnerRingKeys(ctx context.Context) ([][]byte, error) {
|
||||||
val, err := f.get(struct{}{})
|
val, err := f.get(ctx, struct{}{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -289,7 +293,7 @@ func newCachedMaxObjectSizeSource(src objectwriter.MaxSizeSource) objectwriter.M
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ttlMaxObjectSizeCache) MaxObjectSize() uint64 {
|
func (c *ttlMaxObjectSizeCache) MaxObjectSize(ctx context.Context) uint64 {
|
||||||
const ttl = time.Second * 30
|
const ttl = time.Second * 30
|
||||||
|
|
||||||
hit := false
|
hit := false
|
||||||
|
@ -311,7 +315,7 @@ func (c *ttlMaxObjectSizeCache) MaxObjectSize() uint64 {
|
||||||
c.mtx.Lock()
|
c.mtx.Lock()
|
||||||
size = c.lastSize
|
size = c.lastSize
|
||||||
if !c.lastUpdated.After(prevUpdated) {
|
if !c.lastUpdated.After(prevUpdated) {
|
||||||
size = c.src.MaxObjectSize()
|
size = c.src.MaxObjectSize(ctx)
|
||||||
c.lastSize = size
|
c.lastSize = size
|
||||||
c.lastUpdated = time.Now()
|
c.lastUpdated = time.Now()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
@ -17,7 +18,7 @@ func TestTTLNetCache(t *testing.T) {
|
||||||
t.Run("Test Add and Get", func(t *testing.T) {
|
t.Run("Test Add and Get", func(t *testing.T) {
|
||||||
ti := time.Now()
|
ti := time.Now()
|
||||||
cache.set(key, ti, nil)
|
cache.set(key, ti, nil)
|
||||||
val, err := cache.get(key)
|
val, err := cache.get(context.Background(), key)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, ti, val)
|
require.Equal(t, ti, val)
|
||||||
})
|
})
|
||||||
|
@ -26,7 +27,7 @@ func TestTTLNetCache(t *testing.T) {
|
||||||
ti := time.Now()
|
ti := time.Now()
|
||||||
cache.set(key, ti, nil)
|
cache.set(key, ti, nil)
|
||||||
time.Sleep(2 * ttlDuration)
|
time.Sleep(2 * ttlDuration)
|
||||||
val, err := cache.get(key)
|
val, err := cache.get(context.Background(), key)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NotEqual(t, val, ti)
|
require.NotEqual(t, val, ti)
|
||||||
})
|
})
|
||||||
|
@ -35,20 +36,20 @@ func TestTTLNetCache(t *testing.T) {
|
||||||
ti := time.Now()
|
ti := time.Now()
|
||||||
cache.set(key, ti, nil)
|
cache.set(key, ti, nil)
|
||||||
cache.remove(key)
|
cache.remove(key)
|
||||||
val, err := cache.get(key)
|
val, err := cache.get(context.Background(), key)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NotEqual(t, val, ti)
|
require.NotEqual(t, val, ti)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("Test Cache Error", func(t *testing.T) {
|
t.Run("Test Cache Error", func(t *testing.T) {
|
||||||
cache.set("error", time.Now(), errors.New("mock error"))
|
cache.set("error", time.Now(), errors.New("mock error"))
|
||||||
_, err := cache.get("error")
|
_, err := cache.get(context.Background(), "error")
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
require.Equal(t, "mock error", err.Error())
|
require.Equal(t, "mock error", err.Error())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func testNetValueReader(key string) (time.Time, error) {
|
func testNetValueReader(_ context.Context, key string) (time.Time, error) {
|
||||||
if key == "error" {
|
if key == "error" {
|
||||||
return time.Now(), errors.New("mock error")
|
return time.Now(), errors.New("mock error")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1205,7 +1205,7 @@ func (c *cfg) setContractNodeInfo(ni *netmap.NodeInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *cfg) updateContractNodeInfo(ctx context.Context, epoch uint64) {
|
func (c *cfg) updateContractNodeInfo(ctx context.Context, epoch uint64) {
|
||||||
ni, err := c.netmapLocalNodeState(epoch)
|
ni, err := c.netmapLocalNodeState(ctx, epoch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.log.Error(ctx, logs.FrostFSNodeCouldNotUpdateNodeStateOnNewEpoch,
|
c.log.Error(ctx, logs.FrostFSNodeCouldNotUpdateNodeStateOnNewEpoch,
|
||||||
zap.Uint64("epoch", epoch),
|
zap.Uint64("epoch", epoch),
|
||||||
|
|
|
@ -100,7 +100,7 @@ func configureEACLAndContainerSources(c *cfg, client *cntClient.Client, cnrSrc c
|
||||||
// TODO: use owner directly from the event after neofs-contract#256 will become resolved
|
// TODO: use owner directly from the event after neofs-contract#256 will become resolved
|
||||||
// but don't forget about the profit of reading the new container and caching it:
|
// but don't forget about the profit of reading the new container and caching it:
|
||||||
// creation success are most commonly tracked by polling GET op.
|
// creation success are most commonly tracked by polling GET op.
|
||||||
cnr, err := cnrSrc.Get(ev.ID)
|
cnr, err := cnrSrc.Get(ctx, ev.ID)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
containerCache.containerCache.set(ev.ID, cnr, nil)
|
containerCache.containerCache.set(ev.ID, cnr, nil)
|
||||||
} else {
|
} else {
|
||||||
|
@ -221,25 +221,25 @@ type morphContainerReader struct {
|
||||||
src containerCore.Source
|
src containerCore.Source
|
||||||
|
|
||||||
lister interface {
|
lister interface {
|
||||||
ContainersOf(*user.ID) ([]cid.ID, error)
|
ContainersOf(context.Context, *user.ID) ([]cid.ID, error)
|
||||||
IterateContainersOf(*user.ID, func(cid.ID) error) error
|
IterateContainersOf(context.Context, *user.ID, func(cid.ID) error) error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *morphContainerReader) Get(id cid.ID) (*containerCore.Container, error) {
|
func (x *morphContainerReader) Get(ctx context.Context, id cid.ID) (*containerCore.Container, error) {
|
||||||
return x.src.Get(id)
|
return x.src.Get(ctx, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *morphContainerReader) DeletionInfo(id cid.ID) (*containerCore.DelInfo, error) {
|
func (x *morphContainerReader) DeletionInfo(ctx context.Context, id cid.ID) (*containerCore.DelInfo, error) {
|
||||||
return x.src.DeletionInfo(id)
|
return x.src.DeletionInfo(ctx, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *morphContainerReader) ContainersOf(id *user.ID) ([]cid.ID, error) {
|
func (x *morphContainerReader) ContainersOf(ctx context.Context, id *user.ID) ([]cid.ID, error) {
|
||||||
return x.lister.ContainersOf(id)
|
return x.lister.ContainersOf(ctx, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *morphContainerReader) IterateContainersOf(id *user.ID, processCID func(cid.ID) error) error {
|
func (x *morphContainerReader) IterateContainersOf(ctx context.Context, id *user.ID, processCID func(cid.ID) error) error {
|
||||||
return x.lister.IterateContainersOf(id, processCID)
|
return x.lister.IterateContainersOf(ctx, id, processCID)
|
||||||
}
|
}
|
||||||
|
|
||||||
type morphContainerWriter struct {
|
type morphContainerWriter struct {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -42,7 +43,7 @@ func newMorphFrostfsIDCache(subjProvider frostfsidcore.SubjectProvider, size int
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *morphFrostfsIDCache) GetSubject(addr util.Uint160) (*client.Subject, error) {
|
func (m *morphFrostfsIDCache) GetSubject(ctx context.Context, addr util.Uint160) (*client.Subject, error) {
|
||||||
hit := false
|
hit := false
|
||||||
startedAt := time.Now()
|
startedAt := time.Now()
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -55,7 +56,7 @@ func (m *morphFrostfsIDCache) GetSubject(addr util.Uint160) (*client.Subject, er
|
||||||
return result.subject, result.err
|
return result.subject, result.err
|
||||||
}
|
}
|
||||||
|
|
||||||
subj, err := m.subjProvider.GetSubject(addr)
|
subj, err := m.subjProvider.GetSubject(ctx, addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if m.isCacheableError(err) {
|
if m.isCacheableError(err) {
|
||||||
m.subjCache.Add(addr, subjectWithError{
|
m.subjCache.Add(addr, subjectWithError{
|
||||||
|
@ -69,7 +70,7 @@ func (m *morphFrostfsIDCache) GetSubject(addr util.Uint160) (*client.Subject, er
|
||||||
return subj, nil
|
return subj, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *morphFrostfsIDCache) GetSubjectExtended(addr util.Uint160) (*client.SubjectExtended, error) {
|
func (m *morphFrostfsIDCache) GetSubjectExtended(ctx context.Context, addr util.Uint160) (*client.SubjectExtended, error) {
|
||||||
hit := false
|
hit := false
|
||||||
startedAt := time.Now()
|
startedAt := time.Now()
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -82,7 +83,7 @@ func (m *morphFrostfsIDCache) GetSubjectExtended(addr util.Uint160) (*client.Sub
|
||||||
return result.subject, result.err
|
return result.subject, result.err
|
||||||
}
|
}
|
||||||
|
|
||||||
subjExt, err := m.subjProvider.GetSubjectExtended(addr)
|
subjExt, err := m.subjProvider.GetSubjectExtended(ctx, addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if m.isCacheableError(err) {
|
if m.isCacheableError(err) {
|
||||||
m.subjExtCache.Add(addr, subjectExtWithError{
|
m.subjExtCache.Add(addr, subjectExtWithError{
|
||||||
|
|
|
@ -239,7 +239,7 @@ func setNetmapNotificationParser(c *cfg, sTyp string, p event.NotificationParser
|
||||||
// initNetmapState inits current Network map state.
|
// initNetmapState inits current Network map state.
|
||||||
// Must be called after Morph components initialization.
|
// Must be called after Morph components initialization.
|
||||||
func initNetmapState(ctx context.Context, c *cfg) {
|
func initNetmapState(ctx context.Context, c *cfg) {
|
||||||
epoch, err := c.cfgNetmap.wrapper.Epoch()
|
epoch, err := c.cfgNetmap.wrapper.Epoch(ctx)
|
||||||
fatalOnErrDetails("could not initialize current epoch number", err)
|
fatalOnErrDetails("could not initialize current epoch number", err)
|
||||||
|
|
||||||
var ni *netmapSDK.NodeInfo
|
var ni *netmapSDK.NodeInfo
|
||||||
|
@ -278,7 +278,7 @@ func nodeState(ni *netmapSDK.NodeInfo) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *cfg) netmapInitLocalNodeState(ctx context.Context, epoch uint64) (*netmapSDK.NodeInfo, error) {
|
func (c *cfg) netmapInitLocalNodeState(ctx context.Context, epoch uint64) (*netmapSDK.NodeInfo, error) {
|
||||||
nmNodes, err := c.cfgNetmap.wrapper.GetCandidates()
|
nmNodes, err := c.cfgNetmap.wrapper.GetCandidates(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -291,7 +291,7 @@ func (c *cfg) netmapInitLocalNodeState(ctx context.Context, epoch uint64) (*netm
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
node, err := c.netmapLocalNodeState(epoch)
|
node, err := c.netmapLocalNodeState(ctx, epoch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -312,9 +312,9 @@ func (c *cfg) netmapInitLocalNodeState(ctx context.Context, epoch uint64) (*netm
|
||||||
return candidate, nil
|
return candidate, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *cfg) netmapLocalNodeState(epoch uint64) (*netmapSDK.NodeInfo, error) {
|
func (c *cfg) netmapLocalNodeState(ctx context.Context, epoch uint64) (*netmapSDK.NodeInfo, error) {
|
||||||
// calculate current network state
|
// calculate current network state
|
||||||
nm, err := c.cfgNetmap.wrapper.GetNetMapByEpoch(epoch)
|
nm, err := c.cfgNetmap.wrapper.GetNetMapByEpoch(ctx, epoch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -376,8 +376,8 @@ func (c *cfg) SetNetmapStatus(ctx context.Context, st control.NetmapStatus) erro
|
||||||
return c.updateNetMapState(ctx, func(*nmClient.UpdatePeerPrm) {})
|
return c.updateNetMapState(ctx, func(*nmClient.UpdatePeerPrm) {})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *cfg) GetNetmapStatus() (control.NetmapStatus, uint64, error) {
|
func (c *cfg) GetNetmapStatus(ctx context.Context) (control.NetmapStatus, uint64, error) {
|
||||||
epoch, err := c.netMapSource.Epoch()
|
epoch, err := c.netMapSource.Epoch(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return control.NetmapStatus_STATUS_UNDEFINED, 0, fmt.Errorf("failed to get current epoch: %w", err)
|
return control.NetmapStatus_STATUS_UNDEFINED, 0, fmt.Errorf("failed to get current epoch: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -390,7 +390,7 @@ func (c *cfg) ForceMaintenance(ctx context.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *cfg) setMaintenanceStatus(ctx context.Context, force bool) error {
|
func (c *cfg) setMaintenanceStatus(ctx context.Context, force bool) error {
|
||||||
netSettings, err := c.cfgNetmap.wrapper.ReadNetworkConfiguration()
|
netSettings, err := c.cfgNetmap.wrapper.ReadNetworkConfiguration(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("read network settings to check maintenance allowance: %w", err)
|
err = fmt.Errorf("read network settings to check maintenance allowance: %w", err)
|
||||||
} else if !netSettings.MaintenanceModeAllowed {
|
} else if !netSettings.MaintenanceModeAllowed {
|
||||||
|
@ -438,7 +438,7 @@ type netInfo struct {
|
||||||
msPerBlockRdr func() (int64, error)
|
msPerBlockRdr func() (int64, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *netInfo) Dump(ver version.Version) (*netmapSDK.NetworkInfo, error) {
|
func (n *netInfo) Dump(ctx context.Context, ver version.Version) (*netmapSDK.NetworkInfo, error) {
|
||||||
magic, err := n.magic.MagicNumber()
|
magic, err := n.magic.MagicNumber()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -448,7 +448,7 @@ func (n *netInfo) Dump(ver version.Version) (*netmapSDK.NetworkInfo, error) {
|
||||||
ni.SetCurrentEpoch(n.netState.CurrentEpoch())
|
ni.SetCurrentEpoch(n.netState.CurrentEpoch())
|
||||||
ni.SetMagicNumber(magic)
|
ni.SetMagicNumber(magic)
|
||||||
|
|
||||||
netInfoMorph, err := n.morphClientNetMap.ReadNetworkConfiguration()
|
netInfoMorph, err := n.morphClientNetMap.ReadNetworkConfiguration(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("read network configuration using netmap contract client: %w", err)
|
return nil, fmt.Errorf("read network configuration using netmap contract client: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,10 +54,10 @@ type objectSvc struct {
|
||||||
patch *patchsvc.Service
|
patch *patchsvc.Service
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *cfg) MaxObjectSize() uint64 {
|
func (c *cfg) MaxObjectSize(ctx context.Context) uint64 {
|
||||||
sz, err := c.cfgNetmap.wrapper.MaxObjectSize()
|
sz, err := c.cfgNetmap.wrapper.MaxObjectSize(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.log.Error(context.Background(), logs.FrostFSNodeCouldNotGetMaxObjectSizeValue,
|
c.log.Error(ctx, logs.FrostFSNodeCouldNotGetMaxObjectSizeValue,
|
||||||
zap.Error(err),
|
zap.Error(err),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -122,8 +122,8 @@ type innerRingFetcherWithNotary struct {
|
||||||
sidechain *morphClient.Client
|
sidechain *morphClient.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fn *innerRingFetcherWithNotary) InnerRingKeys() ([][]byte, error) {
|
func (fn *innerRingFetcherWithNotary) InnerRingKeys(ctx context.Context) ([][]byte, error) {
|
||||||
keys, err := fn.sidechain.NeoFSAlphabetList()
|
keys, err := fn.sidechain.NeoFSAlphabetList(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("can't get inner ring keys from alphabet role: %w", err)
|
return nil, fmt.Errorf("can't get inner ring keys from alphabet role: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,16 +29,16 @@ type cnrSource struct {
|
||||||
cli *containerClient.Client
|
cli *containerClient.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c cnrSource) Get(id cid.ID) (*container.Container, error) {
|
func (c cnrSource) Get(ctx context.Context, id cid.ID) (*container.Container, error) {
|
||||||
return c.src.Get(id)
|
return c.src.Get(ctx, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c cnrSource) DeletionInfo(cid cid.ID) (*container.DelInfo, error) {
|
func (c cnrSource) DeletionInfo(ctx context.Context, cid cid.ID) (*container.DelInfo, error) {
|
||||||
return c.src.DeletionInfo(cid)
|
return c.src.DeletionInfo(ctx, cid)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c cnrSource) List() ([]cid.ID, error) {
|
func (c cnrSource) List(ctx context.Context) ([]cid.ID, error) {
|
||||||
return c.cli.ContainersOf(nil)
|
return c.cli.ContainersOf(ctx, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func initTreeService(c *cfg) {
|
func initTreeService(c *cfg) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package request
|
package request
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -12,9 +13,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// FormFrostfsIDRequestProperties forms frostfsid specific request properties like user-claim tags and group ID.
|
// FormFrostfsIDRequestProperties forms frostfsid specific request properties like user-claim tags and group ID.
|
||||||
func FormFrostfsIDRequestProperties(frostFSIDClient frostfsidcore.SubjectProvider, pk *keys.PublicKey) (map[string]string, error) {
|
func FormFrostfsIDRequestProperties(ctx context.Context, frostFSIDClient frostfsidcore.SubjectProvider, pk *keys.PublicKey) (map[string]string, error) {
|
||||||
reqProps := make(map[string]string)
|
reqProps := make(map[string]string)
|
||||||
subj, err := frostFSIDClient.GetSubjectExtended(pk.GetScriptHash())
|
subj, err := frostFSIDClient.GetSubjectExtended(ctx, pk.GetScriptHash())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !strings.Contains(err.Error(), frostfsidcore.SubjectNotFoundErrorMessage) {
|
if !strings.Contains(err.Error(), frostfsidcore.SubjectNotFoundErrorMessage) {
|
||||||
return nil, fmt.Errorf("get subject error: %w", err)
|
return nil, fmt.Errorf("get subject error: %w", err)
|
||||||
|
@ -36,8 +37,8 @@ func FormFrostfsIDRequestProperties(frostFSIDClient frostfsidcore.SubjectProvide
|
||||||
}
|
}
|
||||||
|
|
||||||
// Groups return the actor's group ids from frostfsid contract.
|
// Groups return the actor's group ids from frostfsid contract.
|
||||||
func Groups(frostFSIDClient frostfsidcore.SubjectProvider, pk *keys.PublicKey) ([]string, error) {
|
func Groups(ctx context.Context, frostFSIDClient frostfsidcore.SubjectProvider, pk *keys.PublicKey) ([]string, error) {
|
||||||
subj, err := frostFSIDClient.GetSubjectExtended(pk.GetScriptHash())
|
subj, err := frostFSIDClient.GetSubjectExtended(ctx, pk.GetScriptHash())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !strings.Contains(err.Error(), frostfsidcore.SubjectNotFoundErrorMessage) {
|
if !strings.Contains(err.Error(), frostfsidcore.SubjectNotFoundErrorMessage) {
|
||||||
return nil, fmt.Errorf("get subject error: %w", err)
|
return nil, fmt.Errorf("get subject error: %w", err)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package container
|
package container
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
utilSync "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/sync"
|
utilSync "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/sync"
|
||||||
|
@ -19,7 +20,7 @@ type infoValue struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type InfoProvider interface {
|
type InfoProvider interface {
|
||||||
Info(id cid.ID) (Info, error)
|
Info(ctx context.Context, id cid.ID) (Info, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type infoProvider struct {
|
type infoProvider struct {
|
||||||
|
@ -43,13 +44,13 @@ func NewInfoProvider(sourceFactory func() (Source, error)) InfoProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *infoProvider) Info(id cid.ID) (Info, error) {
|
func (r *infoProvider) Info(ctx context.Context, id cid.ID) (Info, error) {
|
||||||
v, found := r.tryGetFromCache(id)
|
v, found := r.tryGetFromCache(id)
|
||||||
if found {
|
if found {
|
||||||
return v.info, v.err
|
return v.info, v.err
|
||||||
}
|
}
|
||||||
|
|
||||||
return r.getFromSource(id)
|
return r.getFromSource(ctx, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *infoProvider) tryGetFromCache(id cid.ID) (infoValue, bool) {
|
func (r *infoProvider) tryGetFromCache(id cid.ID) (infoValue, bool) {
|
||||||
|
@ -60,7 +61,7 @@ func (r *infoProvider) tryGetFromCache(id cid.ID) (infoValue, bool) {
|
||||||
return value, found
|
return value, found
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *infoProvider) getFromSource(id cid.ID) (Info, error) {
|
func (r *infoProvider) getFromSource(ctx context.Context, id cid.ID) (Info, error) {
|
||||||
r.kl.Lock(id)
|
r.kl.Lock(id)
|
||||||
defer r.kl.Unlock(id)
|
defer r.kl.Unlock(id)
|
||||||
|
|
||||||
|
@ -75,11 +76,11 @@ func (r *infoProvider) getFromSource(id cid.ID) (Info, error) {
|
||||||
return Info{}, r.sourceErr
|
return Info{}, r.sourceErr
|
||||||
}
|
}
|
||||||
|
|
||||||
cnr, err := r.source.Get(id)
|
cnr, err := r.source.Get(ctx, id)
|
||||||
var civ infoValue
|
var civ infoValue
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if client.IsErrContainerNotFound(err) {
|
if client.IsErrContainerNotFound(err) {
|
||||||
removed, err := WasRemoved(r.source, id)
|
removed, err := WasRemoved(ctx, r.source, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
civ.err = err
|
civ.err = err
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package container
|
package container
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container"
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container"
|
||||||
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||||
frostfscrypto "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/crypto"
|
frostfscrypto "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/crypto"
|
||||||
|
@ -41,9 +43,9 @@ type Source interface {
|
||||||
//
|
//
|
||||||
// Implementations must not retain the container pointer and modify
|
// Implementations must not retain the container pointer and modify
|
||||||
// the container through it.
|
// the container through it.
|
||||||
Get(cid.ID) (*Container, error)
|
Get(ctx context.Context, cid cid.ID) (*Container, error)
|
||||||
|
|
||||||
DeletionInfo(cid.ID) (*DelInfo, error)
|
DeletionInfo(ctx context.Context, cid cid.ID) (*DelInfo, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// EACL groups information about the FrostFS container's extended ACL stored in
|
// EACL groups information about the FrostFS container's extended ACL stored in
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package container
|
package container
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
||||||
|
@ -10,8 +11,8 @@ import (
|
||||||
|
|
||||||
// WasRemoved checks whether the container ever existed or
|
// WasRemoved checks whether the container ever existed or
|
||||||
// it just has not been created yet at the current epoch.
|
// it just has not been created yet at the current epoch.
|
||||||
func WasRemoved(s Source, cid cid.ID) (bool, error) {
|
func WasRemoved(ctx context.Context, s Source, cid cid.ID) (bool, error) {
|
||||||
_, err := s.DeletionInfo(cid)
|
_, err := s.DeletionInfo(ctx, cid)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package frostfsid
|
package frostfsid
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-contract/frostfsid/client"
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/frostfsid/client"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
)
|
)
|
||||||
|
@ -11,6 +13,6 @@ const (
|
||||||
|
|
||||||
// SubjectProvider interface provides methods to get subject from FrostfsID contract.
|
// SubjectProvider interface provides methods to get subject from FrostfsID contract.
|
||||||
type SubjectProvider interface {
|
type SubjectProvider interface {
|
||||||
GetSubject(util.Uint160) (*client.Subject, error)
|
GetSubject(ctx context.Context, addr util.Uint160) (*client.Subject, error)
|
||||||
GetSubjectExtended(util.Uint160) (*client.SubjectExtended, error)
|
GetSubjectExtended(ctx context.Context, addr util.Uint160) (*client.SubjectExtended, error)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package netmap
|
package netmap
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap"
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -16,7 +18,7 @@ type Source interface {
|
||||||
//
|
//
|
||||||
// Implementations must not retain the network map pointer and modify
|
// Implementations must not retain the network map pointer and modify
|
||||||
// the network map through it.
|
// the network map through it.
|
||||||
GetNetMap(diff uint64) (*netmap.NetMap, error)
|
GetNetMap(ctx context.Context, diff uint64) (*netmap.NetMap, error)
|
||||||
|
|
||||||
// GetNetMapByEpoch reads network map by the epoch number from the storage.
|
// GetNetMapByEpoch reads network map by the epoch number from the storage.
|
||||||
// It returns the pointer to the requested network map and any error encountered.
|
// It returns the pointer to the requested network map and any error encountered.
|
||||||
|
@ -25,21 +27,21 @@ type Source interface {
|
||||||
//
|
//
|
||||||
// Implementations must not retain the network map pointer and modify
|
// Implementations must not retain the network map pointer and modify
|
||||||
// the network map through it.
|
// the network map through it.
|
||||||
GetNetMapByEpoch(epoch uint64) (*netmap.NetMap, error)
|
GetNetMapByEpoch(ctx context.Context, epoch uint64) (*netmap.NetMap, error)
|
||||||
|
|
||||||
// Epoch reads the current epoch from the storage.
|
// Epoch reads the current epoch from the storage.
|
||||||
// It returns thw number of the current epoch and any error encountered.
|
// It returns thw number of the current epoch and any error encountered.
|
||||||
//
|
//
|
||||||
// Must return exactly one non-default value.
|
// Must return exactly one non-default value.
|
||||||
Epoch() (uint64, error)
|
Epoch(ctx context.Context) (uint64, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetLatestNetworkMap requests and returns the latest network map from the storage.
|
// GetLatestNetworkMap requests and returns the latest network map from the storage.
|
||||||
func GetLatestNetworkMap(src Source) (*netmap.NetMap, error) {
|
func GetLatestNetworkMap(ctx context.Context, src Source) (*netmap.NetMap, error) {
|
||||||
return src.GetNetMap(0)
|
return src.GetNetMap(ctx, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPreviousNetworkMap requests and returns previous from the latest network map from the storage.
|
// GetPreviousNetworkMap requests and returns previous from the latest network map from the storage.
|
||||||
func GetPreviousNetworkMap(src Source) (*netmap.NetMap, error) {
|
func GetPreviousNetworkMap(ctx context.Context, src Source) (*netmap.NetMap, error) {
|
||||||
return src.GetNetMap(1)
|
return src.GetNetMap(ctx, 1)
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,7 +199,7 @@ func (v *FormatValidator) isIROrContainerNode(ctx context.Context, obj *objectSD
|
||||||
cnrIDBin := make([]byte, sha256.Size)
|
cnrIDBin := make([]byte, sha256.Size)
|
||||||
cnrID.Encode(cnrIDBin)
|
cnrID.Encode(cnrIDBin)
|
||||||
|
|
||||||
cnr, err := v.containers.Get(cnrID)
|
cnr, err := v.containers.Get(ctx, cnrID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return acl.RoleOthers, fmt.Errorf("failed to get container (id=%s): %w", cnrID.EncodeToString(), err)
|
return acl.RoleOthers, fmt.Errorf("failed to get container (id=%s): %w", cnrID.EncodeToString(), err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -578,7 +578,7 @@ type testIRSource struct {
|
||||||
irNodes [][]byte
|
irNodes [][]byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *testIRSource) InnerRingKeys() ([][]byte, error) {
|
func (s *testIRSource) InnerRingKeys(_ context.Context) ([][]byte, error) {
|
||||||
return s.irNodes, nil
|
return s.irNodes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -586,14 +586,14 @@ type testContainerSource struct {
|
||||||
containers map[cid.ID]*container.Container
|
containers map[cid.ID]*container.Container
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *testContainerSource) Get(cnrID cid.ID) (*container.Container, error) {
|
func (s *testContainerSource) Get(ctx context.Context, cnrID cid.ID) (*container.Container, error) {
|
||||||
if cnr, found := s.containers[cnrID]; found {
|
if cnr, found := s.containers[cnrID]; found {
|
||||||
return cnr, nil
|
return cnr, nil
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("container not found")
|
return nil, fmt.Errorf("container not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *testContainerSource) DeletionInfo(cid.ID) (*container.DelInfo, error) {
|
func (s *testContainerSource) DeletionInfo(context.Context, cid.ID) (*container.DelInfo, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -602,20 +602,20 @@ type testNetmapSource struct {
|
||||||
currentEpoch uint64
|
currentEpoch uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *testNetmapSource) GetNetMap(diff uint64) (*netmap.NetMap, error) {
|
func (s *testNetmapSource) GetNetMap(ctx context.Context, diff uint64) (*netmap.NetMap, error) {
|
||||||
if diff >= s.currentEpoch {
|
if diff >= s.currentEpoch {
|
||||||
return nil, fmt.Errorf("invalid diff")
|
return nil, fmt.Errorf("invalid diff")
|
||||||
}
|
}
|
||||||
return s.GetNetMapByEpoch(s.currentEpoch - diff)
|
return s.GetNetMapByEpoch(ctx, s.currentEpoch-diff)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *testNetmapSource) GetNetMapByEpoch(epoch uint64) (*netmap.NetMap, error) {
|
func (s *testNetmapSource) GetNetMapByEpoch(ctx context.Context, epoch uint64) (*netmap.NetMap, error) {
|
||||||
if nm, found := s.netmaps[epoch]; found {
|
if nm, found := s.netmaps[epoch]; found {
|
||||||
return nm, nil
|
return nm, nil
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("netmap not found")
|
return nil, fmt.Errorf("netmap not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *testNetmapSource) Epoch() (uint64, error) {
|
func (s *testNetmapSource) Epoch(ctx context.Context) (uint64, error) {
|
||||||
return s.currentEpoch, nil
|
return s.currentEpoch, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type InnerRing interface {
|
type InnerRing interface {
|
||||||
InnerRingKeys() ([][]byte, error)
|
InnerRingKeys(ctx context.Context) ([][]byte, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type SenderClassifier struct {
|
type SenderClassifier struct {
|
||||||
|
@ -63,7 +63,7 @@ func (c SenderClassifier) Classify(
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c SenderClassifier) IsInnerRingOrContainerNode(ctx context.Context, ownerKeyInBytes []byte, idCnr cid.ID, cnr container.Container) (*ClassifyResult, error) {
|
func (c SenderClassifier) IsInnerRingOrContainerNode(ctx context.Context, ownerKeyInBytes []byte, idCnr cid.ID, cnr container.Container) (*ClassifyResult, error) {
|
||||||
isInnerRingNode, err := c.isInnerRingKey(ownerKeyInBytes)
|
isInnerRingNode, err := c.isInnerRingKey(ctx, ownerKeyInBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// do not throw error, try best case matching
|
// do not throw error, try best case matching
|
||||||
c.log.Debug(ctx, logs.V2CantCheckIfRequestFromInnerRing,
|
c.log.Debug(ctx, logs.V2CantCheckIfRequestFromInnerRing,
|
||||||
|
@ -78,7 +78,7 @@ func (c SenderClassifier) IsInnerRingOrContainerNode(ctx context.Context, ownerK
|
||||||
binCnr := make([]byte, sha256.Size)
|
binCnr := make([]byte, sha256.Size)
|
||||||
idCnr.Encode(binCnr)
|
idCnr.Encode(binCnr)
|
||||||
|
|
||||||
isContainerNode, err := c.isContainerKey(ownerKeyInBytes, binCnr, cnr)
|
isContainerNode, err := c.isContainerKey(ctx, ownerKeyInBytes, binCnr, cnr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// error might happen if request has `RoleOther` key and placement
|
// error might happen if request has `RoleOther` key and placement
|
||||||
// is not possible for previous epoch, so
|
// is not possible for previous epoch, so
|
||||||
|
@ -99,8 +99,8 @@ func (c SenderClassifier) IsInnerRingOrContainerNode(ctx context.Context, ownerK
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c SenderClassifier) isInnerRingKey(owner []byte) (bool, error) {
|
func (c SenderClassifier) isInnerRingKey(ctx context.Context, owner []byte) (bool, error) {
|
||||||
innerRingKeys, err := c.innerRing.InnerRingKeys()
|
innerRingKeys, err := c.innerRing.InnerRingKeys(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
@ -116,10 +116,11 @@ func (c SenderClassifier) isInnerRingKey(owner []byte) (bool, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c SenderClassifier) isContainerKey(
|
func (c SenderClassifier) isContainerKey(
|
||||||
|
ctx context.Context,
|
||||||
owner, idCnr []byte,
|
owner, idCnr []byte,
|
||||||
cnr container.Container,
|
cnr container.Container,
|
||||||
) (bool, error) {
|
) (bool, error) {
|
||||||
nm, err := core.GetLatestNetworkMap(c.netmap) // first check current netmap
|
nm, err := core.GetLatestNetworkMap(ctx, c.netmap) // first check current netmap
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
@ -133,7 +134,7 @@ func (c SenderClassifier) isContainerKey(
|
||||||
|
|
||||||
// then check previous netmap, this can happen in-between epoch change
|
// then check previous netmap, this can happen in-between epoch change
|
||||||
// when node migrates data from last epoch container
|
// when node migrates data from last epoch container
|
||||||
nm, err = core.GetPreviousNetworkMap(c.netmap)
|
nm, err = core.GetPreviousNetworkMap(ctx, c.netmap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package innerring
|
package innerring
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
||||||
nmClient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/netmap"
|
nmClient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/netmap"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
|
@ -47,12 +49,12 @@ type IrFetcherWithoutNotary struct {
|
||||||
|
|
||||||
// InnerRingKeys fetches list of innerring keys from NeoFSAlphabet
|
// InnerRingKeys fetches list of innerring keys from NeoFSAlphabet
|
||||||
// role in the sidechain.
|
// role in the sidechain.
|
||||||
func (fN IrFetcherWithNotary) InnerRingKeys() (keys.PublicKeys, error) {
|
func (fN IrFetcherWithNotary) InnerRingKeys(ctx context.Context) (keys.PublicKeys, error) {
|
||||||
return fN.cli.NeoFSAlphabetList()
|
return fN.cli.NeoFSAlphabetList(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
// InnerRingKeys fetches list of innerring keys from netmap contract
|
// InnerRingKeys fetches list of innerring keys from netmap contract
|
||||||
// in the sidechain.
|
// in the sidechain.
|
||||||
func (f IrFetcherWithoutNotary) InnerRingKeys() (keys.PublicKeys, error) {
|
func (f IrFetcherWithoutNotary) InnerRingKeys(ctx context.Context) (keys.PublicKeys, error) {
|
||||||
return f.nm.GetInnerRingList()
|
return f.nm.GetInnerRingList(ctx)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package innerring
|
package innerring
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
@ -10,7 +11,7 @@ import (
|
||||||
|
|
||||||
type (
|
type (
|
||||||
irFetcher interface {
|
irFetcher interface {
|
||||||
InnerRingKeys() (keys.PublicKeys, error)
|
InnerRingKeys(ctx context.Context) (keys.PublicKeys, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
committeeFetcher interface {
|
committeeFetcher interface {
|
||||||
|
@ -45,7 +46,7 @@ func newInnerRingIndexer(comf committeeFetcher, irf irFetcher, key *keys.PublicK
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *innerRingIndexer) update() (ind indexes, err error) {
|
func (s *innerRingIndexer) update(ctx context.Context) (ind indexes, err error) {
|
||||||
s.RLock()
|
s.RLock()
|
||||||
|
|
||||||
if time.Since(s.lastAccess) < s.timeout {
|
if time.Since(s.lastAccess) < s.timeout {
|
||||||
|
@ -62,7 +63,7 @@ func (s *innerRingIndexer) update() (ind indexes, err error) {
|
||||||
return s.ind, nil
|
return s.ind, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
innerRing, err := s.irFetcher.InnerRingKeys()
|
innerRing, err := s.irFetcher.InnerRingKeys(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return indexes{}, err
|
return indexes{}, err
|
||||||
}
|
}
|
||||||
|
@ -81,8 +82,8 @@ func (s *innerRingIndexer) update() (ind indexes, err error) {
|
||||||
return s.ind, nil
|
return s.ind, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *innerRingIndexer) InnerRingIndex() (int32, error) {
|
func (s *innerRingIndexer) InnerRingIndex(ctx context.Context) (int32, error) {
|
||||||
ind, err := s.update()
|
ind, err := s.update(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, fmt.Errorf("can't update index state: %w", err)
|
return 0, fmt.Errorf("can't update index state: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -90,8 +91,8 @@ func (s *innerRingIndexer) InnerRingIndex() (int32, error) {
|
||||||
return ind.innerRingIndex, nil
|
return ind.innerRingIndex, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *innerRingIndexer) InnerRingSize() (int32, error) {
|
func (s *innerRingIndexer) InnerRingSize(ctx context.Context) (int32, error) {
|
||||||
ind, err := s.update()
|
ind, err := s.update(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, fmt.Errorf("can't update index state: %w", err)
|
return 0, fmt.Errorf("can't update index state: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -99,8 +100,8 @@ func (s *innerRingIndexer) InnerRingSize() (int32, error) {
|
||||||
return ind.innerRingSize, nil
|
return ind.innerRingSize, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *innerRingIndexer) AlphabetIndex() (int32, error) {
|
func (s *innerRingIndexer) AlphabetIndex(ctx context.Context) (int32, error) {
|
||||||
ind, err := s.update()
|
ind, err := s.update(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, fmt.Errorf("can't update index state: %w", err)
|
return 0, fmt.Errorf("can't update index state: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package innerring
|
package innerring
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -37,15 +38,15 @@ func TestIndexerReturnsIndexes(t *testing.T) {
|
||||||
|
|
||||||
indexer := newInnerRingIndexer(cf, irf, key, time.Second)
|
indexer := newInnerRingIndexer(cf, irf, key, time.Second)
|
||||||
|
|
||||||
idx, err := indexer.AlphabetIndex()
|
idx, err := indexer.AlphabetIndex(context.Background())
|
||||||
require.NoError(t, err, "failed to get alphabet index")
|
require.NoError(t, err, "failed to get alphabet index")
|
||||||
require.Equal(t, int32(1), idx, "invalid alphabet index")
|
require.Equal(t, int32(1), idx, "invalid alphabet index")
|
||||||
|
|
||||||
idx, err = indexer.InnerRingIndex()
|
idx, err = indexer.InnerRingIndex(context.Background())
|
||||||
require.NoError(t, err, "failed to get IR index")
|
require.NoError(t, err, "failed to get IR index")
|
||||||
require.Equal(t, int32(2), idx, "invalid IR index")
|
require.Equal(t, int32(2), idx, "invalid IR index")
|
||||||
|
|
||||||
size, err := indexer.InnerRingSize()
|
size, err := indexer.InnerRingSize(context.Background())
|
||||||
require.NoError(t, err, "failed to get IR size")
|
require.NoError(t, err, "failed to get IR size")
|
||||||
require.Equal(t, int32(3), size, "invalid IR size")
|
require.Equal(t, int32(3), size, "invalid IR size")
|
||||||
})
|
})
|
||||||
|
@ -56,11 +57,11 @@ func TestIndexerReturnsIndexes(t *testing.T) {
|
||||||
|
|
||||||
indexer := newInnerRingIndexer(cf, irf, key, time.Second)
|
indexer := newInnerRingIndexer(cf, irf, key, time.Second)
|
||||||
|
|
||||||
idx, err := indexer.AlphabetIndex()
|
idx, err := indexer.AlphabetIndex(context.Background())
|
||||||
require.NoError(t, err, "failed to get alphabet index")
|
require.NoError(t, err, "failed to get alphabet index")
|
||||||
require.Equal(t, int32(-1), idx, "invalid alphabet index")
|
require.Equal(t, int32(-1), idx, "invalid alphabet index")
|
||||||
|
|
||||||
idx, err = indexer.InnerRingIndex()
|
idx, err = indexer.InnerRingIndex(context.Background())
|
||||||
require.NoError(t, err, "failed to get IR index")
|
require.NoError(t, err, "failed to get IR index")
|
||||||
require.Equal(t, int32(0), idx, "invalid IR index")
|
require.Equal(t, int32(0), idx, "invalid IR index")
|
||||||
})
|
})
|
||||||
|
@ -71,11 +72,11 @@ func TestIndexerReturnsIndexes(t *testing.T) {
|
||||||
|
|
||||||
indexer := newInnerRingIndexer(cf, irf, key, time.Second)
|
indexer := newInnerRingIndexer(cf, irf, key, time.Second)
|
||||||
|
|
||||||
idx, err := indexer.AlphabetIndex()
|
idx, err := indexer.AlphabetIndex(context.Background())
|
||||||
require.NoError(t, err, "failed to get alphabet index")
|
require.NoError(t, err, "failed to get alphabet index")
|
||||||
require.Equal(t, int32(0), idx, "invalid alphabet index")
|
require.Equal(t, int32(0), idx, "invalid alphabet index")
|
||||||
|
|
||||||
idx, err = indexer.InnerRingIndex()
|
idx, err = indexer.InnerRingIndex(context.Background())
|
||||||
require.NoError(t, err, "failed to get IR index")
|
require.NoError(t, err, "failed to get IR index")
|
||||||
require.Equal(t, int32(-1), idx, "invalid IR index")
|
require.Equal(t, int32(-1), idx, "invalid IR index")
|
||||||
})
|
})
|
||||||
|
@ -100,30 +101,30 @@ func TestIndexerCachesIndexes(t *testing.T) {
|
||||||
|
|
||||||
indexer := newInnerRingIndexer(cf, irf, key, time.Second)
|
indexer := newInnerRingIndexer(cf, irf, key, time.Second)
|
||||||
|
|
||||||
idx, err := indexer.AlphabetIndex()
|
idx, err := indexer.AlphabetIndex(context.Background())
|
||||||
require.NoError(t, err, "failed to get alphabet index")
|
require.NoError(t, err, "failed to get alphabet index")
|
||||||
require.Equal(t, int32(-1), idx, "invalid alphabet index")
|
require.Equal(t, int32(-1), idx, "invalid alphabet index")
|
||||||
|
|
||||||
idx, err = indexer.InnerRingIndex()
|
idx, err = indexer.InnerRingIndex(context.Background())
|
||||||
require.NoError(t, err, "failed to get IR index")
|
require.NoError(t, err, "failed to get IR index")
|
||||||
require.Equal(t, int32(-1), idx, "invalid IR index")
|
require.Equal(t, int32(-1), idx, "invalid IR index")
|
||||||
|
|
||||||
size, err := indexer.InnerRingSize()
|
size, err := indexer.InnerRingSize(context.Background())
|
||||||
require.NoError(t, err, "failed to get IR size")
|
require.NoError(t, err, "failed to get IR size")
|
||||||
require.Equal(t, int32(0), size, "invalid IR size")
|
require.Equal(t, int32(0), size, "invalid IR size")
|
||||||
|
|
||||||
require.Equal(t, int32(1), cf.calls.Load(), "invalid commitee calls count")
|
require.Equal(t, int32(1), cf.calls.Load(), "invalid commitee calls count")
|
||||||
require.Equal(t, int32(1), irf.calls.Load(), "invalid IR calls count")
|
require.Equal(t, int32(1), irf.calls.Load(), "invalid IR calls count")
|
||||||
|
|
||||||
idx, err = indexer.AlphabetIndex()
|
idx, err = indexer.AlphabetIndex(context.Background())
|
||||||
require.NoError(t, err, "failed to get alphabet index")
|
require.NoError(t, err, "failed to get alphabet index")
|
||||||
require.Equal(t, int32(-1), idx, "invalid alphabet index")
|
require.Equal(t, int32(-1), idx, "invalid alphabet index")
|
||||||
|
|
||||||
idx, err = indexer.InnerRingIndex()
|
idx, err = indexer.InnerRingIndex(context.Background())
|
||||||
require.NoError(t, err, "failed to get IR index")
|
require.NoError(t, err, "failed to get IR index")
|
||||||
require.Equal(t, int32(-1), idx, "invalid IR index")
|
require.Equal(t, int32(-1), idx, "invalid IR index")
|
||||||
|
|
||||||
size, err = indexer.InnerRingSize()
|
size, err = indexer.InnerRingSize(context.Background())
|
||||||
require.NoError(t, err, "failed to get IR size")
|
require.NoError(t, err, "failed to get IR size")
|
||||||
require.Equal(t, int32(0), size, "invalid IR size")
|
require.Equal(t, int32(0), size, "invalid IR size")
|
||||||
|
|
||||||
|
@ -132,15 +133,15 @@ func TestIndexerCachesIndexes(t *testing.T) {
|
||||||
|
|
||||||
time.Sleep(2 * time.Second)
|
time.Sleep(2 * time.Second)
|
||||||
|
|
||||||
idx, err = indexer.AlphabetIndex()
|
idx, err = indexer.AlphabetIndex(context.Background())
|
||||||
require.NoError(t, err, "failed to get alphabet index")
|
require.NoError(t, err, "failed to get alphabet index")
|
||||||
require.Equal(t, int32(-1), idx, "invalid alphabet index")
|
require.Equal(t, int32(-1), idx, "invalid alphabet index")
|
||||||
|
|
||||||
idx, err = indexer.InnerRingIndex()
|
idx, err = indexer.InnerRingIndex(context.Background())
|
||||||
require.NoError(t, err, "failed to get IR index")
|
require.NoError(t, err, "failed to get IR index")
|
||||||
require.Equal(t, int32(-1), idx, "invalid IR index")
|
require.Equal(t, int32(-1), idx, "invalid IR index")
|
||||||
|
|
||||||
size, err = indexer.InnerRingSize()
|
size, err = indexer.InnerRingSize(context.Background())
|
||||||
require.NoError(t, err, "failed to get IR size")
|
require.NoError(t, err, "failed to get IR size")
|
||||||
require.Equal(t, int32(0), size, "invalid IR size")
|
require.Equal(t, int32(0), size, "invalid IR size")
|
||||||
|
|
||||||
|
@ -165,15 +166,15 @@ func TestIndexerThrowsErrors(t *testing.T) {
|
||||||
|
|
||||||
indexer := newInnerRingIndexer(cf, irf, key, time.Second)
|
indexer := newInnerRingIndexer(cf, irf, key, time.Second)
|
||||||
|
|
||||||
idx, err := indexer.AlphabetIndex()
|
idx, err := indexer.AlphabetIndex(context.Background())
|
||||||
require.ErrorContains(t, err, "test commitee error", "error from commitee not throwed")
|
require.ErrorContains(t, err, "test commitee error", "error from commitee not throwed")
|
||||||
require.Equal(t, int32(0), idx, "invalid alphabet index")
|
require.Equal(t, int32(0), idx, "invalid alphabet index")
|
||||||
|
|
||||||
idx, err = indexer.InnerRingIndex()
|
idx, err = indexer.InnerRingIndex(context.Background())
|
||||||
require.ErrorContains(t, err, "test commitee error", "error from IR not throwed")
|
require.ErrorContains(t, err, "test commitee error", "error from IR not throwed")
|
||||||
require.Equal(t, int32(0), idx, "invalid IR index")
|
require.Equal(t, int32(0), idx, "invalid IR index")
|
||||||
|
|
||||||
size, err := indexer.InnerRingSize()
|
size, err := indexer.InnerRingSize(context.Background())
|
||||||
require.ErrorContains(t, err, "test commitee error", "error from IR not throwed")
|
require.ErrorContains(t, err, "test commitee error", "error from IR not throwed")
|
||||||
require.Equal(t, int32(0), size, "invalid IR size")
|
require.Equal(t, int32(0), size, "invalid IR size")
|
||||||
|
|
||||||
|
@ -189,15 +190,15 @@ func TestIndexerThrowsErrors(t *testing.T) {
|
||||||
|
|
||||||
indexer = newInnerRingIndexer(cf, irf, key, time.Second)
|
indexer = newInnerRingIndexer(cf, irf, key, time.Second)
|
||||||
|
|
||||||
idx, err = indexer.AlphabetIndex()
|
idx, err = indexer.AlphabetIndex(context.Background())
|
||||||
require.ErrorContains(t, err, "test IR error", "error from commitee not throwed")
|
require.ErrorContains(t, err, "test IR error", "error from commitee not throwed")
|
||||||
require.Equal(t, int32(0), idx, "invalid alphabet index")
|
require.Equal(t, int32(0), idx, "invalid alphabet index")
|
||||||
|
|
||||||
idx, err = indexer.InnerRingIndex()
|
idx, err = indexer.InnerRingIndex(context.Background())
|
||||||
require.ErrorContains(t, err, "test IR error", "error from IR not throwed")
|
require.ErrorContains(t, err, "test IR error", "error from IR not throwed")
|
||||||
require.Equal(t, int32(0), idx, "invalid IR index")
|
require.Equal(t, int32(0), idx, "invalid IR index")
|
||||||
|
|
||||||
size, err = indexer.InnerRingSize()
|
size, err = indexer.InnerRingSize(context.Background())
|
||||||
require.ErrorContains(t, err, "test IR error", "error from IR not throwed")
|
require.ErrorContains(t, err, "test IR error", "error from IR not throwed")
|
||||||
require.Equal(t, int32(0), size, "invalid IR size")
|
require.Equal(t, int32(0), size, "invalid IR size")
|
||||||
}
|
}
|
||||||
|
@ -219,7 +220,7 @@ type testIRFetcher struct {
|
||||||
calls atomic.Int32
|
calls atomic.Int32
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *testIRFetcher) InnerRingKeys() (keys.PublicKeys, error) {
|
func (f *testIRFetcher) InnerRingKeys(context.Context) (keys.PublicKeys, error) {
|
||||||
f.calls.Add(1)
|
f.calls.Add(1)
|
||||||
return f.keys, f.err
|
return f.keys, f.err
|
||||||
}
|
}
|
||||||
|
|
|
@ -575,19 +575,19 @@ func parseMultinetConfig(cfg *viper.Viper, m metrics.MultinetMetrics) internalNe
|
||||||
|
|
||||||
func (s *Server) initConfigFromBlockchain(ctx context.Context) error {
|
func (s *Server) initConfigFromBlockchain(ctx context.Context) error {
|
||||||
// get current epoch
|
// get current epoch
|
||||||
epoch, err := s.netmapClient.Epoch()
|
epoch, err := s.netmapClient.Epoch(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("can't read epoch number: %w", err)
|
return fmt.Errorf("can't read epoch number: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// get current epoch duration
|
// get current epoch duration
|
||||||
epochDuration, err := s.netmapClient.EpochDuration()
|
epochDuration, err := s.netmapClient.EpochDuration(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("can't read epoch duration: %w", err)
|
return fmt.Errorf("can't read epoch duration: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// get balance precision
|
// get balance precision
|
||||||
balancePrecision, err := s.balanceClient.Decimals()
|
balancePrecision, err := s.balanceClient.Decimals(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("can't read balance contract precision: %w", err)
|
return fmt.Errorf("can't read balance contract precision: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -597,7 +597,7 @@ func (s *Server) initConfigFromBlockchain(ctx context.Context) error {
|
||||||
s.precision.SetBalancePrecision(balancePrecision)
|
s.precision.SetBalancePrecision(balancePrecision)
|
||||||
|
|
||||||
// get next epoch delta tick
|
// get next epoch delta tick
|
||||||
s.initialEpochTickDelta, err = s.nextEpochBlockDelta()
|
s.initialEpochTickDelta, err = s.nextEpochBlockDelta(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -613,8 +613,8 @@ func (s *Server) initConfigFromBlockchain(ctx context.Context) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) nextEpochBlockDelta() (uint32, error) {
|
func (s *Server) nextEpochBlockDelta(ctx context.Context) (uint32, error) {
|
||||||
epochBlock, err := s.netmapClient.LastEpochBlock()
|
epochBlock, err := s.netmapClient.LastEpochBlock(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, fmt.Errorf("can't read last epoch block: %w", err)
|
return 0, fmt.Errorf("can't read last epoch block: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package innerring
|
package innerring
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/netmap/nodevalidation/state"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/netmap/nodevalidation/state"
|
||||||
|
@ -17,8 +18,8 @@ type networkSettings netmapclient.Client
|
||||||
// MaintenanceModeAllowed requests network configuration from the Sidechain
|
// MaintenanceModeAllowed requests network configuration from the Sidechain
|
||||||
// and check allowance of storage node's maintenance mode according to it.
|
// and check allowance of storage node's maintenance mode according to it.
|
||||||
// Always returns state.ErrMaintenanceModeDisallowed.
|
// Always returns state.ErrMaintenanceModeDisallowed.
|
||||||
func (s *networkSettings) MaintenanceModeAllowed() error {
|
func (s *networkSettings) MaintenanceModeAllowed(ctx context.Context) error {
|
||||||
allowed, err := (*netmapclient.Client)(s).MaintenanceModeAllowed()
|
allowed, err := (*netmapclient.Client)(s).MaintenanceModeAllowed(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("read maintenance mode's allowance from the Sidechain: %w", err)
|
return fmt.Errorf("read maintenance mode's allowance from the Sidechain: %w", err)
|
||||||
} else if allowed {
|
} else if allowed {
|
||||||
|
|
|
@ -279,6 +279,6 @@ type testNetmapClient struct {
|
||||||
netmap *netmap.NetMap
|
netmap *netmap.NetMap
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *testNetmapClient) NetMap() (*netmap.NetMap, error) {
|
func (c *testNetmapClient) NetMap(context.Context) (*netmap.NetMap, error) {
|
||||||
return c.netmap, nil
|
return c.netmap, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ func (ap *Processor) processEmit(ctx context.Context) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
networkMap, err := ap.netmapClient.NetMap()
|
networkMap, err := ap.netmapClient.NetMap(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ap.log.Warn(ctx, logs.AlphabetCantGetNetmapSnapshotToEmitGasToStorageNodes,
|
ap.log.Warn(ctx, logs.AlphabetCantGetNetmapSnapshotToEmitGasToStorageNodes,
|
||||||
zap.Error(err))
|
zap.Error(err))
|
||||||
|
|
|
@ -36,7 +36,7 @@ type (
|
||||||
}
|
}
|
||||||
|
|
||||||
netmapClient interface {
|
netmapClient interface {
|
||||||
NetMap() (*netmap.NetMap, error)
|
NetMap(ctx context.Context) (*netmap.NetMap, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
morphClient interface {
|
morphClient interface {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package container
|
package container
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"crypto/ecdsa"
|
"crypto/ecdsa"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -45,7 +46,7 @@ type signatureVerificationData struct {
|
||||||
// - v.binPublicKey is a public session key
|
// - v.binPublicKey is a public session key
|
||||||
// - session context corresponds to the container and verb in v
|
// - session context corresponds to the container and verb in v
|
||||||
// - session is "alive"
|
// - session is "alive"
|
||||||
func (cp *Processor) verifySignature(v signatureVerificationData) error {
|
func (cp *Processor) verifySignature(ctx context.Context, v signatureVerificationData) error {
|
||||||
var err error
|
var err error
|
||||||
var key frostfsecdsa.PublicKeyRFC6979
|
var key frostfsecdsa.PublicKeyRFC6979
|
||||||
keyProvided := v.binPublicKey != nil
|
keyProvided := v.binPublicKey != nil
|
||||||
|
@ -58,7 +59,7 @@ func (cp *Processor) verifySignature(v signatureVerificationData) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(v.binTokenSession) > 0 {
|
if len(v.binTokenSession) > 0 {
|
||||||
return cp.verifyByTokenSession(v, &key, keyProvided)
|
return cp.verifyByTokenSession(ctx, v, &key, keyProvided)
|
||||||
}
|
}
|
||||||
|
|
||||||
if keyProvided {
|
if keyProvided {
|
||||||
|
@ -77,8 +78,8 @@ func (cp *Processor) verifySignature(v signatureVerificationData) error {
|
||||||
return errors.New("signature is invalid or calculated with the key not bound to the container owner")
|
return errors.New("signature is invalid or calculated with the key not bound to the container owner")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cp *Processor) checkTokenLifetime(token session.Container) error {
|
func (cp *Processor) checkTokenLifetime(ctx context.Context, token session.Container) error {
|
||||||
curEpoch, err := cp.netState.Epoch()
|
curEpoch, err := cp.netState.Epoch(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not read current epoch: %w", err)
|
return fmt.Errorf("could not read current epoch: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -90,7 +91,7 @@ func (cp *Processor) checkTokenLifetime(token session.Container) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cp *Processor) verifyByTokenSession(v signatureVerificationData, key *frostfsecdsa.PublicKeyRFC6979, keyProvided bool) error {
|
func (cp *Processor) verifyByTokenSession(ctx context.Context, v signatureVerificationData, key *frostfsecdsa.PublicKeyRFC6979, keyProvided bool) error {
|
||||||
var tok session.Container
|
var tok session.Container
|
||||||
|
|
||||||
err := tok.Unmarshal(v.binTokenSession)
|
err := tok.Unmarshal(v.binTokenSession)
|
||||||
|
@ -118,7 +119,7 @@ func (cp *Processor) verifyByTokenSession(v signatureVerificationData, key *fros
|
||||||
return errors.New("owner differs with token owner")
|
return errors.New("owner differs with token owner")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = cp.checkTokenLifetime(tok)
|
err = cp.checkTokenLifetime(ctx, tok)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("check session lifetime: %w", err)
|
return fmt.Errorf("check session lifetime: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,11 +170,11 @@ type testNetworkState struct {
|
||||||
epoch uint64
|
epoch uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *testNetworkState) HomomorphicHashDisabled() (bool, error) {
|
func (s *testNetworkState) HomomorphicHashDisabled(context.Context) (bool, error) {
|
||||||
return s.homHashDisabled, nil
|
return s.homHashDisabled, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *testNetworkState) Epoch() (uint64, error) {
|
func (s *testNetworkState) Epoch(context.Context) (uint64, error) {
|
||||||
return s.epoch, nil
|
return s.epoch, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ func (c *testContainerClient) ContractAddress() util.Uint160 {
|
||||||
return c.contractAddress
|
return c.contractAddress
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *testContainerClient) Get(cid []byte) (*containercore.Container, error) {
|
func (c *testContainerClient) Get(ctx context.Context, cid []byte) (*containercore.Container, error) {
|
||||||
key := hex.EncodeToString(cid)
|
key := hex.EncodeToString(cid)
|
||||||
if cont, found := c.get[key]; found {
|
if cont, found := c.get[key]; found {
|
||||||
return cont, nil
|
return cont, nil
|
||||||
|
@ -237,6 +237,6 @@ func (c *testMorphClient) NotarySignAndInvokeTX(mainTx *transaction.Transaction)
|
||||||
|
|
||||||
type testFrostFSIDClient struct{}
|
type testFrostFSIDClient struct{}
|
||||||
|
|
||||||
func (c *testFrostFSIDClient) GetSubject(addr util.Uint160) (*frostfsidclient.Subject, error) {
|
func (c *testFrostFSIDClient) GetSubject(ctx context.Context, addr util.Uint160) (*frostfsidclient.Subject, error) {
|
||||||
return &frostfsidclient.Subject{}, nil
|
return &frostfsidclient.Subject{}, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ func (cp *Processor) processContainerPut(ctx context.Context, put putEvent) bool
|
||||||
e: put,
|
e: put,
|
||||||
}
|
}
|
||||||
|
|
||||||
err := cp.checkPutContainer(pctx)
|
err := cp.checkPutContainer(ctx, pctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cp.log.Error(ctx, logs.ContainerPutContainerCheckFailed,
|
cp.log.Error(ctx, logs.ContainerPutContainerCheckFailed,
|
||||||
zap.Error(err),
|
zap.Error(err),
|
||||||
|
@ -66,8 +66,8 @@ func (cp *Processor) processContainerPut(ctx context.Context, put putEvent) bool
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cp *Processor) checkPutContainer(ctx *putContainerContext) error {
|
func (cp *Processor) checkPutContainer(ctx context.Context, pctx *putContainerContext) error {
|
||||||
binCnr := ctx.e.Container()
|
binCnr := pctx.e.Container()
|
||||||
var cnr containerSDK.Container
|
var cnr containerSDK.Container
|
||||||
|
|
||||||
err := cnr.Unmarshal(binCnr)
|
err := cnr.Unmarshal(binCnr)
|
||||||
|
@ -75,12 +75,12 @@ func (cp *Processor) checkPutContainer(ctx *putContainerContext) error {
|
||||||
return fmt.Errorf("invalid binary container: %w", err)
|
return fmt.Errorf("invalid binary container: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = cp.verifySignature(signatureVerificationData{
|
err = cp.verifySignature(ctx, signatureVerificationData{
|
||||||
ownerContainer: cnr.Owner(),
|
ownerContainer: cnr.Owner(),
|
||||||
verb: session.VerbContainerPut,
|
verb: session.VerbContainerPut,
|
||||||
binTokenSession: ctx.e.SessionToken(),
|
binTokenSession: pctx.e.SessionToken(),
|
||||||
binPublicKey: ctx.e.PublicKey(),
|
binPublicKey: pctx.e.PublicKey(),
|
||||||
signature: ctx.e.Signature(),
|
signature: pctx.e.Signature(),
|
||||||
signedData: binCnr,
|
signedData: binCnr,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -88,13 +88,13 @@ func (cp *Processor) checkPutContainer(ctx *putContainerContext) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// check homomorphic hashing setting
|
// check homomorphic hashing setting
|
||||||
err = checkHomomorphicHashing(cp.netState, cnr)
|
err = checkHomomorphicHashing(ctx, cp.netState, cnr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("incorrect homomorphic hashing setting: %w", err)
|
return fmt.Errorf("incorrect homomorphic hashing setting: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// check native name and zone
|
// check native name and zone
|
||||||
err = cp.checkNNS(ctx, cnr)
|
err = cp.checkNNS(ctx, pctx, cnr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("NNS: %w", err)
|
return fmt.Errorf("NNS: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ func (cp *Processor) processContainerDelete(ctx context.Context, e containerEven
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
err := cp.checkDeleteContainer(e)
|
err := cp.checkDeleteContainer(ctx, e)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cp.log.Error(ctx, logs.ContainerDeleteContainerCheckFailed,
|
cp.log.Error(ctx, logs.ContainerDeleteContainerCheckFailed,
|
||||||
zap.Error(err),
|
zap.Error(err),
|
||||||
|
@ -130,7 +130,7 @@ func (cp *Processor) processContainerDelete(ctx context.Context, e containerEven
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cp *Processor) checkDeleteContainer(e containerEvent.Delete) error {
|
func (cp *Processor) checkDeleteContainer(ctx context.Context, e containerEvent.Delete) error {
|
||||||
binCnr := e.ContainerID()
|
binCnr := e.ContainerID()
|
||||||
|
|
||||||
var idCnr cid.ID
|
var idCnr cid.ID
|
||||||
|
@ -141,12 +141,12 @@ func (cp *Processor) checkDeleteContainer(e containerEvent.Delete) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// receive owner of the related container
|
// receive owner of the related container
|
||||||
cnr, err := cp.cnrClient.Get(binCnr)
|
cnr, err := cp.cnrClient.Get(ctx, binCnr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not receive the container: %w", err)
|
return fmt.Errorf("could not receive the container: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = cp.verifySignature(signatureVerificationData{
|
err = cp.verifySignature(ctx, signatureVerificationData{
|
||||||
ownerContainer: cnr.Value.Owner(),
|
ownerContainer: cnr.Value.Owner(),
|
||||||
verb: session.VerbContainerDelete,
|
verb: session.VerbContainerDelete,
|
||||||
idContainerSet: true,
|
idContainerSet: true,
|
||||||
|
@ -163,21 +163,21 @@ func (cp *Processor) checkDeleteContainer(e containerEvent.Delete) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cp *Processor) checkNNS(ctx *putContainerContext, cnr containerSDK.Container) error {
|
func (cp *Processor) checkNNS(ctx context.Context, pctx *putContainerContext, cnr containerSDK.Container) error {
|
||||||
// fetch domain info
|
// fetch domain info
|
||||||
ctx.d = containerSDK.ReadDomain(cnr)
|
pctx.d = containerSDK.ReadDomain(cnr)
|
||||||
|
|
||||||
// if PutNamed event => check if values in container correspond to args
|
// if PutNamed event => check if values in container correspond to args
|
||||||
if named, ok := ctx.e.(interface {
|
if named, ok := pctx.e.(interface {
|
||||||
Name() string
|
Name() string
|
||||||
Zone() string
|
Zone() string
|
||||||
}); ok {
|
}); ok {
|
||||||
if name := named.Name(); name != ctx.d.Name() {
|
if name := named.Name(); name != pctx.d.Name() {
|
||||||
return fmt.Errorf("names differ %s/%s", name, ctx.d.Name())
|
return fmt.Errorf("names differ %s/%s", name, pctx.d.Name())
|
||||||
}
|
}
|
||||||
|
|
||||||
if zone := named.Zone(); zone != ctx.d.Zone() {
|
if zone := named.Zone(); zone != pctx.d.Zone() {
|
||||||
return fmt.Errorf("zones differ %s/%s", zone, ctx.d.Zone())
|
return fmt.Errorf("zones differ %s/%s", zone, pctx.d.Zone())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,12 +186,12 @@ func (cp *Processor) checkNNS(ctx *putContainerContext, cnr containerSDK.Contain
|
||||||
return fmt.Errorf("could not get container owner address: %w", err)
|
return fmt.Errorf("could not get container owner address: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
subject, err := cp.frostFSIDClient.GetSubject(addr)
|
subject, err := cp.frostFSIDClient.GetSubject(ctx, addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not get subject from FrostfsID contract: %w", err)
|
return fmt.Errorf("could not get subject from FrostfsID contract: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace, hasNamespace := strings.CutSuffix(ctx.d.Zone(), ".ns")
|
namespace, hasNamespace := strings.CutSuffix(pctx.d.Zone(), ".ns")
|
||||||
if !hasNamespace {
|
if !hasNamespace {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -203,8 +203,8 @@ func (cp *Processor) checkNNS(ctx *putContainerContext, cnr containerSDK.Contain
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkHomomorphicHashing(ns NetworkState, cnr containerSDK.Container) error {
|
func checkHomomorphicHashing(ctx context.Context, ns NetworkState, cnr containerSDK.Container) error {
|
||||||
netSetting, err := ns.HomomorphicHashDisabled()
|
netSetting, err := ns.HomomorphicHashDisabled(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not get setting in contract: %w", err)
|
return fmt.Errorf("could not get setting in contract: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ type (
|
||||||
|
|
||||||
ContClient interface {
|
ContClient interface {
|
||||||
ContractAddress() util.Uint160
|
ContractAddress() util.Uint160
|
||||||
Get(cid []byte) (*containercore.Container, error)
|
Get(ctx context.Context, cid []byte) (*containercore.Container, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
MorphClient interface {
|
MorphClient interface {
|
||||||
|
@ -33,7 +33,7 @@ type (
|
||||||
}
|
}
|
||||||
|
|
||||||
FrostFSIDClient interface {
|
FrostFSIDClient interface {
|
||||||
GetSubject(addr util.Uint160) (*frostfsidclient.Subject, error)
|
GetSubject(ctx context.Context, addr util.Uint160) (*frostfsidclient.Subject, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Processor of events produced by container contract in the sidechain.
|
// Processor of events produced by container contract in the sidechain.
|
||||||
|
@ -68,7 +68,7 @@ type NetworkState interface {
|
||||||
//
|
//
|
||||||
// Must return any error encountered
|
// Must return any error encountered
|
||||||
// which did not allow reading the value.
|
// which did not allow reading the value.
|
||||||
Epoch() (uint64, error)
|
Epoch(ctx context.Context) (uint64, error)
|
||||||
|
|
||||||
// HomomorphicHashDisabled must return boolean that
|
// HomomorphicHashDisabled must return boolean that
|
||||||
// represents homomorphic network state:
|
// represents homomorphic network state:
|
||||||
|
@ -76,7 +76,7 @@ type NetworkState interface {
|
||||||
// * false if hashing is enabled.
|
// * false if hashing is enabled.
|
||||||
//
|
//
|
||||||
// which did not allow reading the value.
|
// which did not allow reading the value.
|
||||||
HomomorphicHashDisabled() (bool, error)
|
HomomorphicHashDisabled(ctx context.Context) (bool, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// New creates a container contract processor instance.
|
// New creates a container contract processor instance.
|
||||||
|
|
|
@ -236,7 +236,7 @@ type testIRFetcher struct {
|
||||||
publicKeys keys.PublicKeys
|
publicKeys keys.PublicKeys
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *testIRFetcher) InnerRingKeys() (keys.PublicKeys, error) {
|
func (f *testIRFetcher) InnerRingKeys(context.Context) (keys.PublicKeys, error) {
|
||||||
return f.publicKeys, nil
|
return f.publicKeys, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ type testMainnetClient struct {
|
||||||
designateHash util.Uint160
|
designateHash util.Uint160
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *testMainnetClient) NeoFSAlphabetList() (res keys.PublicKeys, err error) {
|
func (c *testMainnetClient) NeoFSAlphabetList(context.Context) (res keys.PublicKeys, err error) {
|
||||||
return c.alphabetKeys, nil
|
return c.alphabetKeys, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ func (gp *Processor) processAlphabetSync(ctx context.Context, txHash util.Uint25
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
mainnetAlphabet, err := gp.mainnetClient.NeoFSAlphabetList()
|
mainnetAlphabet, err := gp.mainnetClient.NeoFSAlphabetList(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
gp.log.Error(ctx, logs.GovernanceCantFetchAlphabetListFromMainNet,
|
gp.log.Error(ctx, logs.GovernanceCantFetchAlphabetListFromMainNet,
|
||||||
zap.Error(err))
|
zap.Error(err))
|
||||||
|
@ -95,7 +95,7 @@ func prettyKeys(keys keys.PublicKeys) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gp *Processor) updateNeoFSAlphabetRoleInSidechain(ctx context.Context, sidechainAlphabet, newAlphabet keys.PublicKeys, txHash util.Uint256) {
|
func (gp *Processor) updateNeoFSAlphabetRoleInSidechain(ctx context.Context, sidechainAlphabet, newAlphabet keys.PublicKeys, txHash util.Uint256) {
|
||||||
innerRing, err := gp.irFetcher.InnerRingKeys()
|
innerRing, err := gp.irFetcher.InnerRingKeys(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
gp.log.Error(ctx, logs.GovernanceCantFetchInnerRingListFromSideChain,
|
gp.log.Error(ctx, logs.GovernanceCantFetchInnerRingListFromSideChain,
|
||||||
zap.Error(err))
|
zap.Error(err))
|
||||||
|
|
|
@ -52,7 +52,7 @@ type (
|
||||||
// Implementation must take into account availability of
|
// Implementation must take into account availability of
|
||||||
// the notary contract.
|
// the notary contract.
|
||||||
IRFetcher interface {
|
IRFetcher interface {
|
||||||
InnerRingKeys() (keys.PublicKeys, error)
|
InnerRingKeys(ctx context.Context) (keys.PublicKeys, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
FrostFSClient interface {
|
FrostFSClient interface {
|
||||||
|
@ -64,7 +64,7 @@ type (
|
||||||
}
|
}
|
||||||
|
|
||||||
MainnetClient interface {
|
MainnetClient interface {
|
||||||
NeoFSAlphabetList() (res keys.PublicKeys, err error)
|
NeoFSAlphabetList(context.Context) (res keys.PublicKeys, err error)
|
||||||
GetDesignateHash() util.Uint160
|
GetDesignateHash() util.Uint160
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -294,7 +294,7 @@ type testNodeStateSettings struct {
|
||||||
maintAllowed bool
|
maintAllowed bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *testNodeStateSettings) MaintenanceModeAllowed() error {
|
func (s *testNodeStateSettings) MaintenanceModeAllowed(context.Context) error {
|
||||||
if s.maintAllowed {
|
if s.maintAllowed {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -303,7 +303,7 @@ func (s *testNodeStateSettings) MaintenanceModeAllowed() error {
|
||||||
|
|
||||||
type testValidator struct{}
|
type testValidator struct{}
|
||||||
|
|
||||||
func (v *testValidator) VerifyAndUpdate(*netmap.NodeInfo) error {
|
func (v *testValidator) VerifyAndUpdate(context.Context, *netmap.NodeInfo) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -381,7 +381,7 @@ func (c *testNetmapClient) ContractAddress() util.Uint160 {
|
||||||
return c.contractAddress
|
return c.contractAddress
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *testNetmapClient) EpochDuration() (uint64, error) {
|
func (c *testNetmapClient) EpochDuration(context.Context) (uint64, error) {
|
||||||
return c.epochDuration, nil
|
return c.epochDuration, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,7 +392,7 @@ func (c *testNetmapClient) MorphTxHeight(h util.Uint256) (uint32, error) {
|
||||||
return 0, fmt.Errorf("not found")
|
return 0, fmt.Errorf("not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *testNetmapClient) NetMap() (*netmap.NetMap, error) {
|
func (c *testNetmapClient) NetMap(context.Context) (*netmap.NetMap, error) {
|
||||||
return c.netmap, nil
|
return c.netmap, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package locode
|
package locode
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
@ -29,7 +30,7 @@ var errMissingRequiredAttr = errors.New("missing required attribute in DB record
|
||||||
// - Continent: R.Continent().String().
|
// - Continent: R.Continent().String().
|
||||||
//
|
//
|
||||||
// UN-LOCODE attribute remains untouched.
|
// UN-LOCODE attribute remains untouched.
|
||||||
func (v *Validator) VerifyAndUpdate(n *netmap.NodeInfo) error {
|
func (v *Validator) VerifyAndUpdate(_ context.Context, n *netmap.NodeInfo) error {
|
||||||
attrLocode := n.LOCODE()
|
attrLocode := n.LOCODE()
|
||||||
if attrLocode == "" {
|
if attrLocode == "" {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package locode_test
|
package locode_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -92,7 +93,7 @@ func TestValidator_VerifyAndUpdate(t *testing.T) {
|
||||||
t.Run("w/o locode", func(t *testing.T) {
|
t.Run("w/o locode", func(t *testing.T) {
|
||||||
n := nodeInfoWithSomeAttrs()
|
n := nodeInfoWithSomeAttrs()
|
||||||
|
|
||||||
err := validator.VerifyAndUpdate(n)
|
err := validator.VerifyAndUpdate(context.Background(), n)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -102,7 +103,7 @@ func TestValidator_VerifyAndUpdate(t *testing.T) {
|
||||||
|
|
||||||
addLocodeAttrValue(n, "WRONG LOCODE")
|
addLocodeAttrValue(n, "WRONG LOCODE")
|
||||||
|
|
||||||
err := validator.VerifyAndUpdate(n)
|
err := validator.VerifyAndUpdate(context.Background(), n)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -111,7 +112,7 @@ func TestValidator_VerifyAndUpdate(t *testing.T) {
|
||||||
|
|
||||||
addLocodeAttr(n, locodestd.LOCODE{"RU", "SPB"})
|
addLocodeAttr(n, locodestd.LOCODE{"RU", "SPB"})
|
||||||
|
|
||||||
err := validator.VerifyAndUpdate(n)
|
err := validator.VerifyAndUpdate(context.Background(), n)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -119,7 +120,7 @@ func TestValidator_VerifyAndUpdate(t *testing.T) {
|
||||||
|
|
||||||
addLocodeAttr(n, r.LOCODE)
|
addLocodeAttr(n, r.LOCODE)
|
||||||
|
|
||||||
err := validator.VerifyAndUpdate(n)
|
err := validator.VerifyAndUpdate(context.Background(), n)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
require.Equal(t, rec.CountryCode().String(), n.Attribute("CountryCode"))
|
require.Equal(t, rec.CountryCode().String(), n.Attribute("CountryCode"))
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package maddress
|
package maddress
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/network"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/network"
|
||||||
|
@ -8,7 +9,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// VerifyAndUpdate calls network.VerifyAddress.
|
// VerifyAndUpdate calls network.VerifyAddress.
|
||||||
func (v *Validator) VerifyAndUpdate(n *netmap.NodeInfo) error {
|
func (v *Validator) VerifyAndUpdate(_ context.Context, n *netmap.NodeInfo) error {
|
||||||
err := network.VerifyMultiAddress(*n)
|
err := network.VerifyMultiAddress(*n)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not verify multiaddress: %w", err)
|
return fmt.Errorf("could not verify multiaddress: %w", err)
|
||||||
|
|
|
@ -7,6 +7,7 @@ map candidates.
|
||||||
package state
|
package state
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap"
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap"
|
||||||
|
@ -23,7 +24,7 @@ type NetworkSettings interface {
|
||||||
// no error if allowed;
|
// no error if allowed;
|
||||||
// ErrMaintenanceModeDisallowed if disallowed;
|
// ErrMaintenanceModeDisallowed if disallowed;
|
||||||
// other error if there are any problems with the check.
|
// other error if there are any problems with the check.
|
||||||
MaintenanceModeAllowed() error
|
MaintenanceModeAllowed(ctx context.Context) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// NetMapCandidateValidator represents tool which checks state of nodes which
|
// NetMapCandidateValidator represents tool which checks state of nodes which
|
||||||
|
@ -55,13 +56,13 @@ func (x *NetMapCandidateValidator) SetNetworkSettings(netSettings NetworkSetting
|
||||||
// MUST NOT be called before SetNetworkSettings.
|
// MUST NOT be called before SetNetworkSettings.
|
||||||
//
|
//
|
||||||
// See also netmap.NodeInfo.IsOnline/SetOnline and other similar methods.
|
// See also netmap.NodeInfo.IsOnline/SetOnline and other similar methods.
|
||||||
func (x *NetMapCandidateValidator) VerifyAndUpdate(node *netmap.NodeInfo) error {
|
func (x *NetMapCandidateValidator) VerifyAndUpdate(ctx context.Context, node *netmap.NodeInfo) error {
|
||||||
if node.Status().IsOnline() {
|
if node.Status().IsOnline() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if node.Status().IsMaintenance() {
|
if node.Status().IsMaintenance() {
|
||||||
return x.netSettings.MaintenanceModeAllowed()
|
return x.netSettings.MaintenanceModeAllowed(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
return errors.New("invalid status: MUST be either ONLINE or MAINTENANCE")
|
return errors.New("invalid status: MUST be either ONLINE or MAINTENANCE")
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package state_test
|
package state_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/netmap/nodevalidation/state"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/netmap/nodevalidation/state"
|
||||||
|
@ -13,7 +14,7 @@ type testNetworkSettings struct {
|
||||||
disallowed bool
|
disallowed bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x testNetworkSettings) MaintenanceModeAllowed() error {
|
func (x testNetworkSettings) MaintenanceModeAllowed(context.Context) error {
|
||||||
if x.disallowed {
|
if x.disallowed {
|
||||||
return state.ErrMaintenanceModeDisallowed
|
return state.ErrMaintenanceModeDisallowed
|
||||||
}
|
}
|
||||||
|
@ -81,7 +82,7 @@ func TestValidator_VerifyAndUpdate(t *testing.T) {
|
||||||
testCase.validatorPreparer(&v)
|
testCase.validatorPreparer(&v)
|
||||||
}
|
}
|
||||||
|
|
||||||
err := v.VerifyAndUpdate(&node)
|
err := v.VerifyAndUpdate(context.Background(), &node)
|
||||||
|
|
||||||
if testCase.valid {
|
if testCase.valid {
|
||||||
require.NoError(t, err, testCase.name)
|
require.NoError(t, err, testCase.name)
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package nodevalidation
|
package nodevalidation
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/netmap"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/netmap"
|
||||||
apinetmap "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap"
|
apinetmap "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap"
|
||||||
)
|
)
|
||||||
|
@ -26,9 +28,9 @@ func New(validators ...netmap.NodeValidator) *CompositeValidator {
|
||||||
// VerifyAndUpdate passes apinetmap.NodeInfo to wrapped validators.
|
// VerifyAndUpdate passes apinetmap.NodeInfo to wrapped validators.
|
||||||
//
|
//
|
||||||
// If error appears, returns it immediately.
|
// If error appears, returns it immediately.
|
||||||
func (c *CompositeValidator) VerifyAndUpdate(ni *apinetmap.NodeInfo) error {
|
func (c *CompositeValidator) VerifyAndUpdate(ctx context.Context, ni *apinetmap.NodeInfo) error {
|
||||||
for _, v := range c.validators {
|
for _, v := range c.validators {
|
||||||
if err := v.VerifyAndUpdate(ni); err != nil {
|
if err := v.VerifyAndUpdate(ctx, ni); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ import (
|
||||||
func (np *Processor) processNewEpoch(ctx context.Context, ev netmapEvent.NewEpoch) bool {
|
func (np *Processor) processNewEpoch(ctx context.Context, ev netmapEvent.NewEpoch) bool {
|
||||||
epoch := ev.EpochNumber()
|
epoch := ev.EpochNumber()
|
||||||
|
|
||||||
epochDuration, err := np.netmapClient.EpochDuration()
|
epochDuration, err := np.netmapClient.EpochDuration(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
np.log.Warn(ctx, logs.NetmapCantGetEpochDuration,
|
np.log.Warn(ctx, logs.NetmapCantGetEpochDuration,
|
||||||
zap.Error(err))
|
zap.Error(err))
|
||||||
|
@ -37,7 +37,7 @@ func (np *Processor) processNewEpoch(ctx context.Context, ev netmapEvent.NewEpoc
|
||||||
}
|
}
|
||||||
|
|
||||||
// get new netmap snapshot
|
// get new netmap snapshot
|
||||||
networkMap, err := np.netmapClient.NetMap()
|
networkMap, err := np.netmapClient.NetMap(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
np.log.Warn(ctx, logs.NetmapCantGetNetmapSnapshotToPerformCleanup,
|
np.log.Warn(ctx, logs.NetmapCantGetNetmapSnapshotToPerformCleanup,
|
||||||
zap.Error(err))
|
zap.Error(err))
|
||||||
|
|
|
@ -39,7 +39,7 @@ func (np *Processor) processAddPeer(ctx context.Context, ev netmapEvent.AddPeer)
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate and update node info
|
// validate and update node info
|
||||||
err = np.nodeValidator.VerifyAndUpdate(&nodeInfo)
|
err = np.nodeValidator.VerifyAndUpdate(ctx, &nodeInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
np.log.Warn(ctx, logs.NetmapCouldNotVerifyAndUpdateInformationAboutNetworkMapCandidate,
|
np.log.Warn(ctx, logs.NetmapCouldNotVerifyAndUpdateInformationAboutNetworkMapCandidate,
|
||||||
zap.Error(err),
|
zap.Error(err),
|
||||||
|
@ -108,7 +108,7 @@ func (np *Processor) processUpdatePeer(ctx context.Context, ev netmapEvent.Updat
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
if ev.Maintenance() {
|
if ev.Maintenance() {
|
||||||
err = np.nodeStateSettings.MaintenanceModeAllowed()
|
err = np.nodeStateSettings.MaintenanceModeAllowed(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
np.log.Info(ctx, logs.NetmapPreventSwitchingNodeToMaintenanceState,
|
np.log.Info(ctx, logs.NetmapPreventSwitchingNodeToMaintenanceState,
|
||||||
zap.Error(err),
|
zap.Error(err),
|
||||||
|
|
|
@ -49,15 +49,15 @@ type (
|
||||||
//
|
//
|
||||||
// If no error occurs, the parameter must point to the
|
// If no error occurs, the parameter must point to the
|
||||||
// ready-made NodeInfo structure.
|
// ready-made NodeInfo structure.
|
||||||
VerifyAndUpdate(*netmap.NodeInfo) error
|
VerifyAndUpdate(context.Context, *netmap.NodeInfo) error
|
||||||
}
|
}
|
||||||
|
|
||||||
Client interface {
|
Client interface {
|
||||||
MorphNotaryInvoke(ctx context.Context, contract util.Uint160, fee fixedn.Fixed8, nonce uint32, vub *uint32, method string, args ...any) error
|
MorphNotaryInvoke(ctx context.Context, contract util.Uint160, fee fixedn.Fixed8, nonce uint32, vub *uint32, method string, args ...any) error
|
||||||
ContractAddress() util.Uint160
|
ContractAddress() util.Uint160
|
||||||
EpochDuration() (uint64, error)
|
EpochDuration(ctx context.Context) (uint64, error)
|
||||||
MorphTxHeight(h util.Uint256) (res uint32, err error)
|
MorphTxHeight(h util.Uint256) (res uint32, err error)
|
||||||
NetMap() (*netmap.NetMap, error)
|
NetMap(ctx context.Context) (*netmap.NetMap, error)
|
||||||
NewEpoch(ctx context.Context, epoch uint64) error
|
NewEpoch(ctx context.Context, epoch uint64) error
|
||||||
MorphIsValidScript(script []byte, signers []transaction.Signer) (valid bool, err error)
|
MorphIsValidScript(script []byte, signers []transaction.Signer) (valid bool, err error)
|
||||||
MorphNotarySignAndInvokeTX(mainTx *transaction.Transaction) error
|
MorphNotarySignAndInvokeTX(mainTx *transaction.Transaction) error
|
||||||
|
|
|
@ -34,16 +34,16 @@ func (w *netmapClientWrapper) ContractAddress() util.Uint160 {
|
||||||
return w.netmapClient.ContractAddress()
|
return w.netmapClient.ContractAddress()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *netmapClientWrapper) EpochDuration() (uint64, error) {
|
func (w *netmapClientWrapper) EpochDuration(ctx context.Context) (uint64, error) {
|
||||||
return w.netmapClient.EpochDuration()
|
return w.netmapClient.EpochDuration(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *netmapClientWrapper) MorphTxHeight(h util.Uint256) (res uint32, err error) {
|
func (w *netmapClientWrapper) MorphTxHeight(h util.Uint256) (res uint32, err error) {
|
||||||
return w.netmapClient.Morph().TxHeight(h)
|
return w.netmapClient.Morph().TxHeight(h)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *netmapClientWrapper) NetMap() (*netmap.NetMap, error) {
|
func (w *netmapClientWrapper) NetMap(ctx context.Context) (*netmap.NetMap, error) {
|
||||||
return w.netmapClient.NetMap()
|
return w.netmapClient.NetMap(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *netmapClientWrapper) NewEpoch(ctx context.Context, epoch uint64) error {
|
func (w *netmapClientWrapper) NewEpoch(ctx context.Context, epoch uint64) error {
|
||||||
|
|
|
@ -60,7 +60,7 @@ func (s *Server) IsAlphabet(ctx context.Context) bool {
|
||||||
// InnerRingIndex is a getter for a global index of node in inner ring list. Negative
|
// InnerRingIndex is a getter for a global index of node in inner ring list. Negative
|
||||||
// index means that node is not in the inner ring list.
|
// index means that node is not in the inner ring list.
|
||||||
func (s *Server) InnerRingIndex(ctx context.Context) int {
|
func (s *Server) InnerRingIndex(ctx context.Context) int {
|
||||||
index, err := s.statusIndex.InnerRingIndex()
|
index, err := s.statusIndex.InnerRingIndex(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.log.Error(ctx, logs.InnerringCantGetInnerRingIndex, zap.Error(err))
|
s.log.Error(ctx, logs.InnerringCantGetInnerRingIndex, zap.Error(err))
|
||||||
return -1
|
return -1
|
||||||
|
@ -72,7 +72,7 @@ func (s *Server) InnerRingIndex(ctx context.Context) int {
|
||||||
// InnerRingSize is a getter for a global size of inner ring list. This value
|
// InnerRingSize is a getter for a global size of inner ring list. This value
|
||||||
// paired with inner ring index.
|
// paired with inner ring index.
|
||||||
func (s *Server) InnerRingSize(ctx context.Context) int {
|
func (s *Server) InnerRingSize(ctx context.Context) int {
|
||||||
size, err := s.statusIndex.InnerRingSize()
|
size, err := s.statusIndex.InnerRingSize(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.log.Error(ctx, logs.InnerringCantGetInnerRingSize, zap.Error(err))
|
s.log.Error(ctx, logs.InnerringCantGetInnerRingSize, zap.Error(err))
|
||||||
return 0
|
return 0
|
||||||
|
@ -84,7 +84,7 @@ func (s *Server) InnerRingSize(ctx context.Context) int {
|
||||||
// AlphabetIndex is a getter for a global index of node in alphabet list.
|
// AlphabetIndex is a getter for a global index of node in alphabet list.
|
||||||
// Negative index means that node is not in the alphabet list.
|
// Negative index means that node is not in the alphabet list.
|
||||||
func (s *Server) AlphabetIndex(ctx context.Context) int {
|
func (s *Server) AlphabetIndex(ctx context.Context) int {
|
||||||
index, err := s.statusIndex.AlphabetIndex()
|
index, err := s.statusIndex.AlphabetIndex(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.log.Error(ctx, logs.InnerringCantGetAlphabetIndex, zap.Error(err))
|
s.log.Error(ctx, logs.InnerringCantGetAlphabetIndex, zap.Error(err))
|
||||||
return -1
|
return -1
|
||||||
|
|
|
@ -279,7 +279,7 @@ func (s *containerSource) IsContainerAvailable(ctx context.Context, id cid.ID) (
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
wasRemoved, err := container.WasRemoved(s.cs, id)
|
wasRemoved, err := container.WasRemoved(ctx, s.cs, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -425,7 +425,7 @@ func (e *StorageEngine) evacuateShardObjects(ctx context.Context, cancel context
|
||||||
}
|
}
|
||||||
egContainer.Go(func() error {
|
egContainer.Go(func() error {
|
||||||
var skip bool
|
var skip bool
|
||||||
c, err := e.containerSource.Load().cs.Get(cnt)
|
c, err := e.containerSource.Load().cs.Get(ctx, cnt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if client.IsErrContainerNotFound(err) {
|
if client.IsErrContainerNotFound(err) {
|
||||||
skip = true
|
skip = true
|
||||||
|
|
|
@ -37,7 +37,7 @@ type containerStorage struct {
|
||||||
latency time.Duration
|
latency time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cs *containerStorage) Get(id cid.ID) (*coreContainer.Container, error) {
|
func (cs *containerStorage) Get(ctx context.Context, id cid.ID) (*coreContainer.Container, error) {
|
||||||
time.Sleep(cs.latency)
|
time.Sleep(cs.latency)
|
||||||
v, ok := cs.cntmap[id]
|
v, ok := cs.cntmap[id]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -49,7 +49,7 @@ func (cs *containerStorage) Get(id cid.ID) (*coreContainer.Container, error) {
|
||||||
return &coreCnt, nil
|
return &coreCnt, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cs *containerStorage) DeletionInfo(cid.ID) (*coreContainer.DelInfo, error) {
|
func (cs *containerStorage) DeletionInfo(context.Context, cid.ID) (*coreContainer.DelInfo, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -360,7 +360,7 @@ func dropUserAttributes(ctx context.Context, db *bbolt.DB, cs container.InfoProv
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
last = keys[len(keys)-1]
|
last = keys[len(keys)-1]
|
||||||
cnt, err := dropNonIndexedUserAttributeBuckets(db, cs, keys)
|
cnt, err := dropNonIndexedUserAttributeBuckets(ctx, db, cs, keys)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log("deleting user attribute buckets completed with an error:", err)
|
log("deleting user attribute buckets completed with an error:", err)
|
||||||
return err
|
return err
|
||||||
|
@ -376,8 +376,8 @@ func dropUserAttributes(ctx context.Context, db *bbolt.DB, cs container.InfoProv
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func dropNonIndexedUserAttributeBuckets(db *bbolt.DB, cs container.InfoProvider, keys [][]byte) (uint64, error) {
|
func dropNonIndexedUserAttributeBuckets(ctx context.Context, db *bbolt.DB, cs container.InfoProvider, keys [][]byte) (uint64, error) {
|
||||||
keysToDrop, err := selectUserAttributeKeysToDrop(keys, cs)
|
keysToDrop, err := selectUserAttributeKeysToDrop(ctx, keys, cs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, fmt.Errorf("select non indexed user attributes: %w", err)
|
return 0, fmt.Errorf("select non indexed user attributes: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -394,7 +394,7 @@ func dropNonIndexedUserAttributeBuckets(db *bbolt.DB, cs container.InfoProvider,
|
||||||
return uint64(len(keysToDrop)), nil
|
return uint64(len(keysToDrop)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func selectUserAttributeKeysToDrop(keys [][]byte, cs container.InfoProvider) ([][]byte, error) {
|
func selectUserAttributeKeysToDrop(ctx context.Context, keys [][]byte, cs container.InfoProvider) ([][]byte, error) {
|
||||||
var keysToDrop [][]byte
|
var keysToDrop [][]byte
|
||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
attr, ok := attributeFromAttributeBucket(key)
|
attr, ok := attributeFromAttributeBucket(key)
|
||||||
|
@ -409,7 +409,7 @@ func selectUserAttributeKeysToDrop(keys [][]byte, cs container.InfoProvider) ([]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("parse container ID from user attribute bucket key %s", hex.EncodeToString(key))
|
return nil, fmt.Errorf("parse container ID from user attribute bucket key %s", hex.EncodeToString(key))
|
||||||
}
|
}
|
||||||
info, err := cs.Info(contID)
|
info, err := cs.Info(ctx, contID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -280,7 +280,7 @@ func (s *Shard) refillObject(ctx context.Context, data []byte, addr oid.Address,
|
||||||
|
|
||||||
var isIndexedContainer bool
|
var isIndexedContainer bool
|
||||||
if hasIndexedAttribute {
|
if hasIndexedAttribute {
|
||||||
info, err := s.containerInfo.Info(addr.Container())
|
info, err := s.containerInfo.Info(ctx, addr.Container())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package balance
|
package balance
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
|
@ -10,14 +11,14 @@ import (
|
||||||
|
|
||||||
// BalanceOf receives the amount of funds in the client's account
|
// BalanceOf receives the amount of funds in the client's account
|
||||||
// through the Balance contract call, and returns it.
|
// through the Balance contract call, and returns it.
|
||||||
func (c *Client) BalanceOf(id user.ID) (*big.Int, error) {
|
func (c *Client) BalanceOf(ctx context.Context, id user.ID) (*big.Int, error) {
|
||||||
h := id.ScriptHash()
|
h := id.ScriptHash()
|
||||||
|
|
||||||
invokePrm := client.TestInvokePrm{}
|
invokePrm := client.TestInvokePrm{}
|
||||||
invokePrm.SetMethod(balanceOfMethod)
|
invokePrm.SetMethod(balanceOfMethod)
|
||||||
invokePrm.SetArgs(h)
|
invokePrm.SetArgs(h)
|
||||||
|
|
||||||
prms, err := c.client.TestInvoke(invokePrm)
|
prms, err := c.client.TestInvoke(ctx, invokePrm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("test invoke (%s): %w", balanceOfMethod, err)
|
return nil, fmt.Errorf("test invoke (%s): %w", balanceOfMethod, err)
|
||||||
} else if ln := len(prms); ln != 1 {
|
} else if ln := len(prms); ln != 1 {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package balance
|
package balance
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
||||||
|
@ -8,11 +9,11 @@ import (
|
||||||
|
|
||||||
// Decimals decimal precision of currency transactions
|
// Decimals decimal precision of currency transactions
|
||||||
// through the Balance contract call, and returns it.
|
// through the Balance contract call, and returns it.
|
||||||
func (c *Client) Decimals() (uint32, error) {
|
func (c *Client) Decimals(ctx context.Context) (uint32, error) {
|
||||||
invokePrm := client.TestInvokePrm{}
|
invokePrm := client.TestInvokePrm{}
|
||||||
invokePrm.SetMethod(decimalsMethod)
|
invokePrm.SetMethod(decimalsMethod)
|
||||||
|
|
||||||
prms, err := c.client.TestInvoke(invokePrm)
|
prms, err := c.client.TestInvoke(ctx, invokePrm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, fmt.Errorf("test invoke (%s): %w", decimalsMethod, err)
|
return 0, fmt.Errorf("test invoke (%s): %w", decimalsMethod, err)
|
||||||
} else if ln := len(prms); ln != 1 {
|
} else if ln := len(prms); ln != 1 {
|
||||||
|
|
|
@ -499,7 +499,7 @@ func (c *Client) TxHeight(h util.Uint256) (res uint32, err error) {
|
||||||
// NeoFSAlphabetList returns keys that stored in NeoFS Alphabet role. Main chain
|
// NeoFSAlphabetList returns keys that stored in NeoFS Alphabet role. Main chain
|
||||||
// stores alphabet node keys of inner ring there, however the sidechain stores both
|
// stores alphabet node keys of inner ring there, however the sidechain stores both
|
||||||
// alphabet and non alphabet node keys of inner ring.
|
// alphabet and non alphabet node keys of inner ring.
|
||||||
func (c *Client) NeoFSAlphabetList() (res keys.PublicKeys, err error) {
|
func (c *Client) NeoFSAlphabetList(_ context.Context) (res keys.PublicKeys, err error) {
|
||||||
c.switchLock.RLock()
|
c.switchLock.RLock()
|
||||||
defer c.switchLock.RUnlock()
|
defer c.switchLock.RUnlock()
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package container
|
package container
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||||
|
@ -13,7 +14,7 @@ import (
|
||||||
// to the specified user of FrostFS system. If idUser is nil, returns the list of all containers.
|
// to the specified user of FrostFS system. If idUser is nil, returns the list of all containers.
|
||||||
//
|
//
|
||||||
// If remote RPC does not support neo-go session API, fallback to List() method.
|
// If remote RPC does not support neo-go session API, fallback to List() method.
|
||||||
func (c *Client) ContainersOf(idUser *user.ID) ([]cid.ID, error) {
|
func (c *Client) ContainersOf(ctx context.Context, idUser *user.ID) ([]cid.ID, error) {
|
||||||
var cidList []cid.ID
|
var cidList []cid.ID
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
@ -21,7 +22,7 @@ func (c *Client) ContainersOf(idUser *user.ID) ([]cid.ID, error) {
|
||||||
cidList = append(cidList, id)
|
cidList = append(cidList, id)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if err = c.IterateContainersOf(idUser, cb); err != nil {
|
if err = c.IterateContainersOf(ctx, idUser, cb); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return cidList, nil
|
return cidList, nil
|
||||||
|
@ -30,7 +31,7 @@ func (c *Client) ContainersOf(idUser *user.ID) ([]cid.ID, error) {
|
||||||
// iterateContainers iterates over a list of container identifiers
|
// iterateContainers iterates over a list of container identifiers
|
||||||
// belonging to the specified user of FrostFS system and executes
|
// belonging to the specified user of FrostFS system and executes
|
||||||
// `cb` on each element. If idUser is nil, calls it on the list of all containers.
|
// `cb` on each element. If idUser is nil, calls it on the list of all containers.
|
||||||
func (c *Client) IterateContainersOf(idUser *user.ID, cb func(item cid.ID) error) error {
|
func (c *Client) IterateContainersOf(ctx context.Context, idUser *user.ID, cb func(item cid.ID) error) error {
|
||||||
var rawID []byte
|
var rawID []byte
|
||||||
if idUser != nil {
|
if idUser != nil {
|
||||||
rawID = idUser.WalletBytes()
|
rawID = idUser.WalletBytes()
|
||||||
|
@ -59,7 +60,7 @@ func (c *Client) IterateContainersOf(idUser *user.ID, cb func(item cid.ID) error
|
||||||
cnrHash := c.client.ContractAddress()
|
cnrHash := c.client.ContractAddress()
|
||||||
err := c.client.Morph().TestInvokeIterator(itemCb, batchSize, cnrHash, containersOfMethod, rawID)
|
err := c.client.Morph().TestInvokeIterator(itemCb, batchSize, cnrHash, containersOfMethod, rawID)
|
||||||
if err != nil && errors.Is(err, unwrap.ErrNoSessionID) {
|
if err != nil && errors.Is(err, unwrap.ErrNoSessionID) {
|
||||||
return c.iterate(idUser, cb)
|
return c.iterate(ctx, idUser, cb)
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package container
|
package container
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -14,27 +15,27 @@ import (
|
||||||
"github.com/mr-tron/base58"
|
"github.com/mr-tron/base58"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (x *containerSource) DeletionInfo(cnr cid.ID) (*containercore.DelInfo, error) {
|
func (x *containerSource) DeletionInfo(ctx context.Context, cnr cid.ID) (*containercore.DelInfo, error) {
|
||||||
return DeletionInfo((*Client)(x), cnr)
|
return DeletionInfo(ctx, (*Client)(x), cnr)
|
||||||
}
|
}
|
||||||
|
|
||||||
type deletionInfo interface {
|
type deletionInfo interface {
|
||||||
DeletionInfo(cid []byte) (*containercore.DelInfo, error)
|
DeletionInfo(ctx context.Context, cid []byte) (*containercore.DelInfo, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeletionInfo(c deletionInfo, cnr cid.ID) (*containercore.DelInfo, error) {
|
func DeletionInfo(ctx context.Context, c deletionInfo, cnr cid.ID) (*containercore.DelInfo, error) {
|
||||||
binCnr := make([]byte, sha256.Size)
|
binCnr := make([]byte, sha256.Size)
|
||||||
cnr.Encode(binCnr)
|
cnr.Encode(binCnr)
|
||||||
|
|
||||||
return c.DeletionInfo(binCnr)
|
return c.DeletionInfo(ctx, binCnr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) DeletionInfo(cid []byte) (*containercore.DelInfo, error) {
|
func (c *Client) DeletionInfo(ctx context.Context, cid []byte) (*containercore.DelInfo, error) {
|
||||||
prm := client.TestInvokePrm{}
|
prm := client.TestInvokePrm{}
|
||||||
prm.SetMethod(deletionInfoMethod)
|
prm.SetMethod(deletionInfoMethod)
|
||||||
prm.SetArgs(cid)
|
prm.SetArgs(cid)
|
||||||
|
|
||||||
res, err := c.client.TestInvoke(prm)
|
res, err := c.client.TestInvoke(ctx, prm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if strings.Contains(err.Error(), containerContract.NotFoundError) {
|
if strings.Contains(err.Error(), containerContract.NotFoundError) {
|
||||||
return nil, new(apistatus.ContainerNotFound)
|
return nil, new(apistatus.ContainerNotFound)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package container
|
package container
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -16,8 +17,8 @@ import (
|
||||||
|
|
||||||
type containerSource Client
|
type containerSource Client
|
||||||
|
|
||||||
func (x *containerSource) Get(cnr cid.ID) (*containercore.Container, error) {
|
func (x *containerSource) Get(ctx context.Context, cnr cid.ID) (*containercore.Container, error) {
|
||||||
return Get((*Client)(x), cnr)
|
return Get(ctx, (*Client)(x), cnr)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AsContainerSource provides container Source interface
|
// AsContainerSource provides container Source interface
|
||||||
|
@ -27,15 +28,15 @@ func AsContainerSource(w *Client) containercore.Source {
|
||||||
}
|
}
|
||||||
|
|
||||||
type getContainer interface {
|
type getContainer interface {
|
||||||
Get(cid []byte) (*containercore.Container, error)
|
Get(ctx context.Context, cid []byte) (*containercore.Container, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get marshals container ID, and passes it to Wrapper's Get method.
|
// Get marshals container ID, and passes it to Wrapper's Get method.
|
||||||
func Get(c getContainer, cnr cid.ID) (*containercore.Container, error) {
|
func Get(ctx context.Context, c getContainer, cnr cid.ID) (*containercore.Container, error) {
|
||||||
binCnr := make([]byte, sha256.Size)
|
binCnr := make([]byte, sha256.Size)
|
||||||
cnr.Encode(binCnr)
|
cnr.Encode(binCnr)
|
||||||
|
|
||||||
return c.Get(binCnr)
|
return c.Get(ctx, binCnr)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get reads the container from FrostFS system by binary identifier
|
// Get reads the container from FrostFS system by binary identifier
|
||||||
|
@ -43,12 +44,12 @@ func Get(c getContainer, cnr cid.ID) (*containercore.Container, error) {
|
||||||
//
|
//
|
||||||
// If an empty slice is returned for the requested identifier,
|
// If an empty slice is returned for the requested identifier,
|
||||||
// storage.ErrNotFound error is returned.
|
// storage.ErrNotFound error is returned.
|
||||||
func (c *Client) Get(cid []byte) (*containercore.Container, error) {
|
func (c *Client) Get(ctx context.Context, cid []byte) (*containercore.Container, error) {
|
||||||
prm := client.TestInvokePrm{}
|
prm := client.TestInvokePrm{}
|
||||||
prm.SetMethod(getMethod)
|
prm.SetMethod(getMethod)
|
||||||
prm.SetArgs(cid)
|
prm.SetArgs(cid)
|
||||||
|
|
||||||
res, err := c.client.TestInvoke(prm)
|
res, err := c.client.TestInvoke(ctx, prm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if strings.Contains(err.Error(), containerContract.NotFoundError) {
|
if strings.Contains(err.Error(), containerContract.NotFoundError) {
|
||||||
return nil, new(apistatus.ContainerNotFound)
|
return nil, new(apistatus.ContainerNotFound)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package container
|
package container
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
||||||
|
@ -15,7 +16,7 @@ import (
|
||||||
//
|
//
|
||||||
// Iterates through the identifiers of all FrostFS containers if pointer
|
// Iterates through the identifiers of all FrostFS containers if pointer
|
||||||
// to user identifier is nil.
|
// to user identifier is nil.
|
||||||
func (c *Client) iterate(idUser *user.ID, cb func(cid.ID) error) error {
|
func (c *Client) iterate(ctx context.Context, idUser *user.ID, cb func(cid.ID) error) error {
|
||||||
var rawID []byte
|
var rawID []byte
|
||||||
|
|
||||||
if idUser != nil {
|
if idUser != nil {
|
||||||
|
@ -26,7 +27,7 @@ func (c *Client) iterate(idUser *user.ID, cb func(cid.ID) error) error {
|
||||||
prm.SetMethod(listMethod)
|
prm.SetMethod(listMethod)
|
||||||
prm.SetArgs(rawID)
|
prm.SetArgs(rawID)
|
||||||
|
|
||||||
res, err := c.client.TestInvoke(prm)
|
res, err := c.client.TestInvoke(ctx, prm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("test invoke (%s): %w", listMethod, err)
|
return fmt.Errorf("test invoke (%s): %w", listMethod, err)
|
||||||
} else if ln := len(res); ln != 1 {
|
} else if ln := len(res); ln != 1 {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package frostfsid
|
package frostfsid
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
frostfsidclient "git.frostfs.info/TrueCloudLab/frostfs-contract/frostfsid/client"
|
frostfsidclient "git.frostfs.info/TrueCloudLab/frostfs-contract/frostfsid/client"
|
||||||
|
@ -14,12 +15,12 @@ const (
|
||||||
methodGetSubjectExtended = "getSubjectExtended"
|
methodGetSubjectExtended = "getSubjectExtended"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *Client) GetSubject(addr util.Uint160) (*frostfsidclient.Subject, error) {
|
func (c *Client) GetSubject(ctx context.Context, addr util.Uint160) (*frostfsidclient.Subject, error) {
|
||||||
prm := client.TestInvokePrm{}
|
prm := client.TestInvokePrm{}
|
||||||
prm.SetMethod(methodGetSubject)
|
prm.SetMethod(methodGetSubject)
|
||||||
prm.SetArgs(addr)
|
prm.SetArgs(addr)
|
||||||
|
|
||||||
res, err := c.client.TestInvoke(prm)
|
res, err := c.client.TestInvoke(ctx, prm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("test invoke (%s): %w", methodGetSubject, err)
|
return nil, fmt.Errorf("test invoke (%s): %w", methodGetSubject, err)
|
||||||
}
|
}
|
||||||
|
@ -37,12 +38,12 @@ func (c *Client) GetSubject(addr util.Uint160) (*frostfsidclient.Subject, error)
|
||||||
return subj, nil
|
return subj, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) GetSubjectExtended(addr util.Uint160) (*frostfsidclient.SubjectExtended, error) {
|
func (c *Client) GetSubjectExtended(ctx context.Context, addr util.Uint160) (*frostfsidclient.SubjectExtended, error) {
|
||||||
prm := client.TestInvokePrm{}
|
prm := client.TestInvokePrm{}
|
||||||
prm.SetMethod(methodGetSubjectExtended)
|
prm.SetMethod(methodGetSubjectExtended)
|
||||||
prm.SetArgs(addr)
|
prm.SetArgs(addr)
|
||||||
|
|
||||||
res, err := c.client.TestInvoke(prm)
|
res, err := c.client.TestInvoke(ctx, prm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("test invoke (%s): %w", methodGetSubjectExtended, err)
|
return nil, fmt.Errorf("test invoke (%s): %w", methodGetSubjectExtended, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,8 @@ const (
|
||||||
|
|
||||||
// MaxObjectSize receives max object size configuration
|
// MaxObjectSize receives max object size configuration
|
||||||
// value through the Netmap contract call.
|
// value through the Netmap contract call.
|
||||||
func (c *Client) MaxObjectSize() (uint64, error) {
|
func (c *Client) MaxObjectSize(ctx context.Context) (uint64, error) {
|
||||||
objectSize, err := c.readUInt64Config(MaxObjectSizeConfig)
|
objectSize, err := c.readUInt64Config(ctx, MaxObjectSizeConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
@ -35,8 +35,8 @@ func (c *Client) MaxObjectSize() (uint64, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// EpochDuration returns number of sidechain blocks per one FrostFS epoch.
|
// EpochDuration returns number of sidechain blocks per one FrostFS epoch.
|
||||||
func (c *Client) EpochDuration() (uint64, error) {
|
func (c *Client) EpochDuration(ctx context.Context) (uint64, error) {
|
||||||
epochDuration, err := c.readUInt64Config(EpochDurationConfig)
|
epochDuration, err := c.readUInt64Config(ctx, EpochDurationConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
@ -46,8 +46,8 @@ func (c *Client) EpochDuration() (uint64, error) {
|
||||||
|
|
||||||
// ContainerFee returns fee paid by container owner to each alphabet node
|
// ContainerFee returns fee paid by container owner to each alphabet node
|
||||||
// for container registration.
|
// for container registration.
|
||||||
func (c *Client) ContainerFee() (uint64, error) {
|
func (c *Client) ContainerFee(ctx context.Context) (uint64, error) {
|
||||||
fee, err := c.readUInt64Config(ContainerFeeConfig)
|
fee, err := c.readUInt64Config(ctx, ContainerFeeConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
@ -57,8 +57,8 @@ func (c *Client) ContainerFee() (uint64, error) {
|
||||||
|
|
||||||
// ContainerAliasFee returns additional fee paid by container owner to each
|
// ContainerAliasFee returns additional fee paid by container owner to each
|
||||||
// alphabet node for container nice name registration.
|
// alphabet node for container nice name registration.
|
||||||
func (c *Client) ContainerAliasFee() (uint64, error) {
|
func (c *Client) ContainerAliasFee(ctx context.Context) (uint64, error) {
|
||||||
fee, err := c.readUInt64Config(ContainerAliasFeeConfig)
|
fee, err := c.readUInt64Config(ctx, ContainerAliasFeeConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
@ -70,14 +70,14 @@ func (c *Client) ContainerAliasFee() (uint64, error) {
|
||||||
// settings.
|
// settings.
|
||||||
//
|
//
|
||||||
// Returns (false, nil) if config key is not found in the contract.
|
// Returns (false, nil) if config key is not found in the contract.
|
||||||
func (c *Client) HomomorphicHashDisabled() (bool, error) {
|
func (c *Client) HomomorphicHashDisabled(ctx context.Context) (bool, error) {
|
||||||
return c.readBoolConfig(HomomorphicHashingDisabledKey)
|
return c.readBoolConfig(ctx, HomomorphicHashingDisabledKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
// InnerRingCandidateFee returns global configuration value of fee paid by
|
// InnerRingCandidateFee returns global configuration value of fee paid by
|
||||||
// node to be in inner ring candidates list.
|
// node to be in inner ring candidates list.
|
||||||
func (c *Client) InnerRingCandidateFee() (uint64, error) {
|
func (c *Client) InnerRingCandidateFee(ctx context.Context) (uint64, error) {
|
||||||
fee, err := c.readUInt64Config(IrCandidateFeeConfig)
|
fee, err := c.readUInt64Config(ctx, IrCandidateFeeConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
@ -87,8 +87,8 @@ func (c *Client) InnerRingCandidateFee() (uint64, error) {
|
||||||
|
|
||||||
// WithdrawFee returns global configuration value of fee paid by user to
|
// WithdrawFee returns global configuration value of fee paid by user to
|
||||||
// withdraw assets from FrostFS contract.
|
// withdraw assets from FrostFS contract.
|
||||||
func (c *Client) WithdrawFee() (uint64, error) {
|
func (c *Client) WithdrawFee(ctx context.Context) (uint64, error) {
|
||||||
fee, err := c.readUInt64Config(WithdrawFeeConfig)
|
fee, err := c.readUInt64Config(ctx, WithdrawFeeConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
@ -101,12 +101,12 @@ func (c *Client) WithdrawFee() (uint64, error) {
|
||||||
// that storage nodes are allowed to switch their state to "maintenance".
|
// that storage nodes are allowed to switch their state to "maintenance".
|
||||||
//
|
//
|
||||||
// By default, maintenance state is disallowed.
|
// By default, maintenance state is disallowed.
|
||||||
func (c *Client) MaintenanceModeAllowed() (bool, error) {
|
func (c *Client) MaintenanceModeAllowed(ctx context.Context) (bool, error) {
|
||||||
return c.readBoolConfig(MaintenanceModeAllowedConfig)
|
return c.readBoolConfig(ctx, MaintenanceModeAllowedConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) readUInt64Config(key string) (uint64, error) {
|
func (c *Client) readUInt64Config(ctx context.Context, key string) (uint64, error) {
|
||||||
v, err := c.config([]byte(key), IntegerAssert)
|
v, err := c.config(ctx, []byte(key), IntegerAssert)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, fmt.Errorf("read netconfig value '%s': %w", key, err)
|
return 0, fmt.Errorf("read netconfig value '%s': %w", key, err)
|
||||||
}
|
}
|
||||||
|
@ -117,8 +117,8 @@ func (c *Client) readUInt64Config(key string) (uint64, error) {
|
||||||
|
|
||||||
// reads boolean value by the given key from the FrostFS network configuration
|
// reads boolean value by the given key from the FrostFS network configuration
|
||||||
// stored in the Sidechain. Returns false if key is not presented.
|
// stored in the Sidechain. Returns false if key is not presented.
|
||||||
func (c *Client) readBoolConfig(key string) (bool, error) {
|
func (c *Client) readBoolConfig(ctx context.Context, key string) (bool, error) {
|
||||||
v, err := c.config([]byte(key), BoolAssert)
|
v, err := c.config(ctx, []byte(key), BoolAssert)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, ErrConfigNotFound) {
|
if errors.Is(err, ErrConfigNotFound) {
|
||||||
return false, nil
|
return false, nil
|
||||||
|
@ -199,12 +199,12 @@ type NetworkConfiguration struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadNetworkConfiguration reads NetworkConfiguration from the FrostFS Sidechain.
|
// ReadNetworkConfiguration reads NetworkConfiguration from the FrostFS Sidechain.
|
||||||
func (c *Client) ReadNetworkConfiguration() (NetworkConfiguration, error) {
|
func (c *Client) ReadNetworkConfiguration(ctx context.Context) (NetworkConfiguration, error) {
|
||||||
var res NetworkConfiguration
|
var res NetworkConfiguration
|
||||||
prm := client.TestInvokePrm{}
|
prm := client.TestInvokePrm{}
|
||||||
prm.SetMethod(configListMethod)
|
prm.SetMethod(configListMethod)
|
||||||
|
|
||||||
items, err := c.client.TestInvoke(prm)
|
items, err := c.client.TestInvoke(ctx, prm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, fmt.Errorf("test invoke (%s): %w",
|
return res, fmt.Errorf("test invoke (%s): %w",
|
||||||
configListMethod, err)
|
configListMethod, err)
|
||||||
|
@ -285,12 +285,12 @@ var ErrConfigNotFound = errors.New("config value not found")
|
||||||
// method of FrostFS Netmap contract.
|
// method of FrostFS Netmap contract.
|
||||||
//
|
//
|
||||||
// Returns ErrConfigNotFound if config key is not found in the contract.
|
// Returns ErrConfigNotFound if config key is not found in the contract.
|
||||||
func (c *Client) config(key []byte, assert func(stackitem.Item) (any, error)) (any, error) {
|
func (c *Client) config(ctx context.Context, key []byte, assert func(stackitem.Item) (any, error)) (any, error) {
|
||||||
prm := client.TestInvokePrm{}
|
prm := client.TestInvokePrm{}
|
||||||
prm.SetMethod(configMethod)
|
prm.SetMethod(configMethod)
|
||||||
prm.SetArgs(key)
|
prm.SetArgs(key)
|
||||||
|
|
||||||
items, err := c.client.TestInvoke(prm)
|
items, err := c.client.TestInvoke(ctx, prm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("test invoke (%s): %w",
|
return nil, fmt.Errorf("test invoke (%s): %w",
|
||||||
configMethod, err)
|
configMethod, err)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package netmap
|
package netmap
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
||||||
|
@ -8,11 +9,11 @@ import (
|
||||||
|
|
||||||
// Epoch receives number of current FrostFS epoch
|
// Epoch receives number of current FrostFS epoch
|
||||||
// through the Netmap contract call.
|
// through the Netmap contract call.
|
||||||
func (c *Client) Epoch() (uint64, error) {
|
func (c *Client) Epoch(ctx context.Context) (uint64, error) {
|
||||||
prm := client.TestInvokePrm{}
|
prm := client.TestInvokePrm{}
|
||||||
prm.SetMethod(epochMethod)
|
prm.SetMethod(epochMethod)
|
||||||
|
|
||||||
items, err := c.client.TestInvoke(prm)
|
items, err := c.client.TestInvoke(ctx, prm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, fmt.Errorf("test invoke (%s): %w",
|
return 0, fmt.Errorf("test invoke (%s): %w",
|
||||||
epochMethod, err)
|
epochMethod, err)
|
||||||
|
@ -32,11 +33,11 @@ func (c *Client) Epoch() (uint64, error) {
|
||||||
|
|
||||||
// LastEpochBlock receives block number of current FrostFS epoch
|
// LastEpochBlock receives block number of current FrostFS epoch
|
||||||
// through the Netmap contract call.
|
// through the Netmap contract call.
|
||||||
func (c *Client) LastEpochBlock() (uint32, error) {
|
func (c *Client) LastEpochBlock(ctx context.Context) (uint32, error) {
|
||||||
prm := client.TestInvokePrm{}
|
prm := client.TestInvokePrm{}
|
||||||
prm.SetMethod(lastEpochBlockMethod)
|
prm.SetMethod(lastEpochBlockMethod)
|
||||||
|
|
||||||
items, err := c.client.TestInvoke(prm)
|
items, err := c.client.TestInvoke(ctx, prm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, fmt.Errorf("test invoke (%s): %w",
|
return 0, fmt.Errorf("test invoke (%s): %w",
|
||||||
lastEpochBlockMethod, err)
|
lastEpochBlockMethod, err)
|
||||||
|
|
|
@ -40,11 +40,11 @@ func (c *Client) UpdateInnerRing(ctx context.Context, p UpdateIRPrm) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetInnerRingList return current IR list.
|
// GetInnerRingList return current IR list.
|
||||||
func (c *Client) GetInnerRingList() (keys.PublicKeys, error) {
|
func (c *Client) GetInnerRingList(ctx context.Context) (keys.PublicKeys, error) {
|
||||||
invokePrm := client.TestInvokePrm{}
|
invokePrm := client.TestInvokePrm{}
|
||||||
invokePrm.SetMethod(innerRingListMethod)
|
invokePrm.SetMethod(innerRingListMethod)
|
||||||
|
|
||||||
prms, err := c.client.TestInvoke(invokePrm)
|
prms, err := c.client.TestInvoke(ctx, invokePrm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("test invoke (%s): %w", innerRingListMethod, err)
|
return nil, fmt.Errorf("test invoke (%s): %w", innerRingListMethod, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package netmap
|
package netmap
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
netmapcontract "git.frostfs.info/TrueCloudLab/frostfs-contract/netmap"
|
netmapcontract "git.frostfs.info/TrueCloudLab/frostfs-contract/netmap"
|
||||||
|
@ -11,12 +12,12 @@ import (
|
||||||
|
|
||||||
// GetNetMapByEpoch calls "snapshotByEpoch" method with the given epoch and
|
// GetNetMapByEpoch calls "snapshotByEpoch" method with the given epoch and
|
||||||
// decodes netmap.NetMap from the response.
|
// decodes netmap.NetMap from the response.
|
||||||
func (c *Client) GetNetMapByEpoch(epoch uint64) (*netmap.NetMap, error) {
|
func (c *Client) GetNetMapByEpoch(ctx context.Context, epoch uint64) (*netmap.NetMap, error) {
|
||||||
invokePrm := client.TestInvokePrm{}
|
invokePrm := client.TestInvokePrm{}
|
||||||
invokePrm.SetMethod(epochSnapshotMethod)
|
invokePrm.SetMethod(epochSnapshotMethod)
|
||||||
invokePrm.SetArgs(epoch)
|
invokePrm.SetArgs(epoch)
|
||||||
|
|
||||||
res, err := c.client.TestInvoke(invokePrm)
|
res, err := c.client.TestInvoke(ctx, invokePrm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("test invoke (%s): %w",
|
return nil, fmt.Errorf("test invoke (%s): %w",
|
||||||
epochSnapshotMethod, err)
|
epochSnapshotMethod, err)
|
||||||
|
@ -34,11 +35,11 @@ func (c *Client) GetNetMapByEpoch(epoch uint64) (*netmap.NetMap, error) {
|
||||||
|
|
||||||
// GetCandidates calls "netmapCandidates" method and decodes []netmap.NodeInfo
|
// GetCandidates calls "netmapCandidates" method and decodes []netmap.NodeInfo
|
||||||
// from the response.
|
// from the response.
|
||||||
func (c *Client) GetCandidates() ([]netmap.NodeInfo, error) {
|
func (c *Client) GetCandidates(ctx context.Context) ([]netmap.NodeInfo, error) {
|
||||||
invokePrm := client.TestInvokePrm{}
|
invokePrm := client.TestInvokePrm{}
|
||||||
invokePrm.SetMethod(netMapCandidatesMethod)
|
invokePrm.SetMethod(netMapCandidatesMethod)
|
||||||
|
|
||||||
res, err := c.client.TestInvoke(invokePrm)
|
res, err := c.client.TestInvoke(ctx, invokePrm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("test invoke (%s): %w", netMapCandidatesMethod, err)
|
return nil, fmt.Errorf("test invoke (%s): %w", netMapCandidatesMethod, err)
|
||||||
}
|
}
|
||||||
|
@ -51,11 +52,11 @@ func (c *Client) GetCandidates() ([]netmap.NodeInfo, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NetMap calls "netmap" method and decode netmap.NetMap from the response.
|
// NetMap calls "netmap" method and decode netmap.NetMap from the response.
|
||||||
func (c *Client) NetMap() (*netmap.NetMap, error) {
|
func (c *Client) NetMap(ctx context.Context) (*netmap.NetMap, error) {
|
||||||
invokePrm := client.TestInvokePrm{}
|
invokePrm := client.TestInvokePrm{}
|
||||||
invokePrm.SetMethod(netMapMethod)
|
invokePrm.SetMethod(netMapMethod)
|
||||||
|
|
||||||
res, err := c.client.TestInvoke(invokePrm)
|
res, err := c.client.TestInvoke(ctx, invokePrm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("test invoke (%s): %w",
|
return nil, fmt.Errorf("test invoke (%s): %w",
|
||||||
netMapMethod, err)
|
netMapMethod, err)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package netmap
|
package netmap
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
||||||
|
@ -8,12 +9,12 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetNetMap calls "snapshot" method and decodes netmap.NetMap from the response.
|
// GetNetMap calls "snapshot" method and decodes netmap.NetMap from the response.
|
||||||
func (c *Client) GetNetMap(diff uint64) (*netmap.NetMap, error) {
|
func (c *Client) GetNetMap(ctx context.Context, diff uint64) (*netmap.NetMap, error) {
|
||||||
prm := client.TestInvokePrm{}
|
prm := client.TestInvokePrm{}
|
||||||
prm.SetMethod(snapshotMethod)
|
prm.SetMethod(snapshotMethod)
|
||||||
prm.SetArgs(diff)
|
prm.SetArgs(diff)
|
||||||
|
|
||||||
res, err := c.client.TestInvoke(prm)
|
res, err := c.client.TestInvoke(ctx, prm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("test invoke (%s): %w", snapshotMethod, err)
|
return nil, fmt.Errorf("test invoke (%s): %w", snapshotMethod, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||||
|
@ -205,7 +206,9 @@ func (ti *TestInvokePrm) SetArgs(args ...any) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestInvoke calls TestInvoke method of Client with static internal script hash.
|
// TestInvoke calls TestInvoke method of Client with static internal script hash.
|
||||||
func (s StaticClient) TestInvoke(prm TestInvokePrm) ([]stackitem.Item, error) {
|
func (s StaticClient) TestInvoke(ctx context.Context, prm TestInvokePrm) ([]stackitem.Item, error) {
|
||||||
|
_, span := tracing.StartSpanFromContext(ctx, "Morph.TestInvoke."+prm.method)
|
||||||
|
defer span.End()
|
||||||
return s.client.TestInvoke(
|
return s.client.TestInvoke(
|
||||||
s.scScriptHash,
|
s.scScriptHash,
|
||||||
prm.method,
|
prm.method,
|
||||||
|
|
|
@ -21,7 +21,7 @@ func NewExecutor(client *balance.Client) accountingSvc.ServiceExecutor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *morphExecutor) Balance(_ context.Context, body *accounting.BalanceRequestBody) (*accounting.BalanceResponseBody, error) {
|
func (s *morphExecutor) Balance(ctx context.Context, body *accounting.BalanceRequestBody) (*accounting.BalanceResponseBody, error) {
|
||||||
idV2 := body.GetOwnerID()
|
idV2 := body.GetOwnerID()
|
||||||
if idV2 == nil {
|
if idV2 == nil {
|
||||||
return nil, errors.New("missing account")
|
return nil, errors.New("missing account")
|
||||||
|
@ -34,12 +34,12 @@ func (s *morphExecutor) Balance(_ context.Context, body *accounting.BalanceReque
|
||||||
return nil, fmt.Errorf("invalid account: %w", err)
|
return nil, fmt.Errorf("invalid account: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
amount, err := s.client.BalanceOf(id)
|
amount, err := s.client.BalanceOf(ctx, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
balancePrecision, err := s.client.Decimals()
|
balancePrecision, err := s.client.Decimals(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,12 +78,12 @@ var _ Server = (*Service)(nil)
|
||||||
|
|
||||||
// validateContainerTargetRequest validates request for the container target.
|
// validateContainerTargetRequest validates request for the container target.
|
||||||
// It checks if request actor is the owner of the container, otherwise it denies the request.
|
// It checks if request actor is the owner of the container, otherwise it denies the request.
|
||||||
func (s *Service) validateContainerTargetRequest(cid string, pubKey *keys.PublicKey) error {
|
func (s *Service) validateContainerTargetRequest(ctx context.Context, cid string, pubKey *keys.PublicKey) error {
|
||||||
var cidSDK cidSDK.ID
|
var cidSDK cidSDK.ID
|
||||||
if err := cidSDK.DecodeString(cid); err != nil {
|
if err := cidSDK.DecodeString(cid); err != nil {
|
||||||
return fmt.Errorf("invalid CID format: %w", err)
|
return fmt.Errorf("invalid CID format: %w", err)
|
||||||
}
|
}
|
||||||
isOwner, err := s.isActorContainerOwner(cidSDK, pubKey)
|
isOwner, err := s.isActorContainerOwner(ctx, cidSDK, pubKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to check owner: %w", err)
|
return fmt.Errorf("failed to check owner: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ func (s *Service) AddChain(ctx context.Context, req *apemanagerV2.AddChainReques
|
||||||
switch targetType := req.GetBody().GetTarget().GetTargetType(); targetType {
|
switch targetType := req.GetBody().GetTarget().GetTargetType(); targetType {
|
||||||
case apeV2.TargetTypeContainer:
|
case apeV2.TargetTypeContainer:
|
||||||
reqCID := req.GetBody().GetTarget().GetName()
|
reqCID := req.GetBody().GetTarget().GetName()
|
||||||
if err = s.validateContainerTargetRequest(reqCID, pub); err != nil {
|
if err = s.validateContainerTargetRequest(ctx, reqCID, pub); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
target = policy_engine.ContainerTarget(reqCID)
|
target = policy_engine.ContainerTarget(reqCID)
|
||||||
|
@ -153,7 +153,7 @@ func (s *Service) RemoveChain(ctx context.Context, req *apemanagerV2.RemoveChain
|
||||||
switch targetType := req.GetBody().GetTarget().GetTargetType(); targetType {
|
switch targetType := req.GetBody().GetTarget().GetTargetType(); targetType {
|
||||||
case apeV2.TargetTypeContainer:
|
case apeV2.TargetTypeContainer:
|
||||||
reqCID := req.GetBody().GetTarget().GetName()
|
reqCID := req.GetBody().GetTarget().GetName()
|
||||||
if err = s.validateContainerTargetRequest(reqCID, pub); err != nil {
|
if err = s.validateContainerTargetRequest(ctx, reqCID, pub); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
target = policy_engine.ContainerTarget(reqCID)
|
target = policy_engine.ContainerTarget(reqCID)
|
||||||
|
@ -177,7 +177,7 @@ func (s *Service) RemoveChain(ctx context.Context, req *apemanagerV2.RemoveChain
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) ListChains(_ context.Context, req *apemanagerV2.ListChainsRequest) (*apemanagerV2.ListChainsResponse, error) {
|
func (s *Service) ListChains(ctx context.Context, req *apemanagerV2.ListChainsRequest) (*apemanagerV2.ListChainsResponse, error) {
|
||||||
pub, err := getSignaturePublicKey(req.GetVerificationHeader())
|
pub, err := getSignaturePublicKey(req.GetVerificationHeader())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -188,7 +188,7 @@ func (s *Service) ListChains(_ context.Context, req *apemanagerV2.ListChainsRequ
|
||||||
switch targetType := req.GetBody().GetTarget().GetTargetType(); targetType {
|
switch targetType := req.GetBody().GetTarget().GetTargetType(); targetType {
|
||||||
case apeV2.TargetTypeContainer:
|
case apeV2.TargetTypeContainer:
|
||||||
reqCID := req.GetBody().GetTarget().GetName()
|
reqCID := req.GetBody().GetTarget().GetName()
|
||||||
if err = s.validateContainerTargetRequest(reqCID, pub); err != nil {
|
if err = s.validateContainerTargetRequest(ctx, reqCID, pub); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
target = policy_engine.ContainerTarget(reqCID)
|
target = policy_engine.ContainerTarget(reqCID)
|
||||||
|
@ -237,13 +237,13 @@ func getSignaturePublicKey(vh *session.RequestVerificationHeader) (*keys.PublicK
|
||||||
return key, nil
|
return key, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) isActorContainerOwner(cid cidSDK.ID, pk *keys.PublicKey) (bool, error) {
|
func (s *Service) isActorContainerOwner(ctx context.Context, cid cidSDK.ID, pk *keys.PublicKey) (bool, error) {
|
||||||
var actor user.ID
|
var actor user.ID
|
||||||
user.IDFromKey(&actor, (ecdsa.PublicKey)(*pk))
|
user.IDFromKey(&actor, (ecdsa.PublicKey)(*pk))
|
||||||
actorOwnerID := new(refs.OwnerID)
|
actorOwnerID := new(refs.OwnerID)
|
||||||
actor.WriteToV2(actorOwnerID)
|
actor.WriteToV2(actorOwnerID)
|
||||||
|
|
||||||
cnr, err := s.cnrSrc.Get(cid)
|
cnr, err := s.cnrSrc.Get(ctx, cid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, fmt.Errorf("get container error: %w", err)
|
return false, fmt.Errorf("get container error: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package ape
|
package ape
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"crypto/ecdsa"
|
"crypto/ecdsa"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -48,7 +49,7 @@ type CheckPrm struct {
|
||||||
// CheckCore provides methods to perform the common logic of APE check.
|
// CheckCore provides methods to perform the common logic of APE check.
|
||||||
type CheckCore interface {
|
type CheckCore interface {
|
||||||
// CheckAPE performs the common policy-engine check logic on a prepared request.
|
// CheckAPE performs the common policy-engine check logic on a prepared request.
|
||||||
CheckAPE(prm CheckPrm) error
|
CheckAPE(ctx context.Context, prm CheckPrm) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type checkerCoreImpl struct {
|
type checkerCoreImpl struct {
|
||||||
|
@ -70,7 +71,7 @@ func New(localOverrideStorage policyengine.LocalOverrideStorage, morphChainStora
|
||||||
}
|
}
|
||||||
|
|
||||||
// CheckAPE performs the common policy-engine check logic on a prepared request.
|
// CheckAPE performs the common policy-engine check logic on a prepared request.
|
||||||
func (c *checkerCoreImpl) CheckAPE(prm CheckPrm) error {
|
func (c *checkerCoreImpl) CheckAPE(ctx context.Context, prm CheckPrm) error {
|
||||||
var cr policyengine.ChainRouter
|
var cr policyengine.ChainRouter
|
||||||
if prm.BearerToken != nil && !prm.BearerToken.Impersonate() {
|
if prm.BearerToken != nil && !prm.BearerToken.Impersonate() {
|
||||||
var err error
|
var err error
|
||||||
|
@ -85,7 +86,7 @@ func (c *checkerCoreImpl) CheckAPE(prm CheckPrm) error {
|
||||||
cr = policyengine.NewDefaultChainRouterWithLocalOverrides(c.MorphChainStorage, c.LocalOverrideStorage)
|
cr = policyengine.NewDefaultChainRouterWithLocalOverrides(c.MorphChainStorage, c.LocalOverrideStorage)
|
||||||
}
|
}
|
||||||
|
|
||||||
groups, err := aperequest.Groups(c.FrostFSSubjectProvider, prm.PublicKey)
|
groups, err := aperequest.Groups(ctx, c.FrostFSSubjectProvider, prm.PublicKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to get group ids: %w", err)
|
return fmt.Errorf("failed to get group ids: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,11 +49,11 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
type ir interface {
|
type ir interface {
|
||||||
InnerRingKeys() ([][]byte, error)
|
InnerRingKeys(ctx context.Context) ([][]byte, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type containers interface {
|
type containers interface {
|
||||||
Get(cid.ID) (*containercore.Container, error)
|
Get(context.Context, cid.ID) (*containercore.Container, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type apeChecker struct {
|
type apeChecker struct {
|
||||||
|
@ -106,7 +106,7 @@ func (ac *apeChecker) List(ctx context.Context, req *container.ListRequest) (*co
|
||||||
ctx, span := tracing.StartSpanFromContext(ctx, "apeChecker.List")
|
ctx, span := tracing.StartSpanFromContext(ctx, "apeChecker.List")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
role, pk, err := ac.getRoleWithoutContainerID(req.GetBody().GetOwnerID(), req.GetMetaHeader(), req.GetVerificationHeader())
|
role, pk, err := ac.getRoleWithoutContainerID(ctx, req.GetBody().GetOwnerID(), req.GetMetaHeader(), req.GetVerificationHeader())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ func (ac *apeChecker) List(ctx context.Context, req *container.ListRequest) (*co
|
||||||
nativeschema.PropertyKeyActorRole: role,
|
nativeschema.PropertyKeyActorRole: role,
|
||||||
}
|
}
|
||||||
|
|
||||||
reqProps, err = ac.fillWithUserClaimTags(reqProps, pk)
|
reqProps, err = ac.fillWithUserClaimTags(ctx, reqProps, pk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -126,11 +126,11 @@ func (ac *apeChecker) List(ctx context.Context, req *container.ListRequest) (*co
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace, err := ac.namespaceByOwner(req.GetBody().GetOwnerID())
|
namespace, err := ac.namespaceByOwner(ctx, req.GetBody().GetOwnerID())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("could not get owner namespace: %w", err)
|
return nil, fmt.Errorf("could not get owner namespace: %w", err)
|
||||||
}
|
}
|
||||||
if err := ac.validateNamespaceByPublicKey(pk, namespace); err != nil {
|
if err := ac.validateNamespaceByPublicKey(ctx, pk, namespace); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ func (ac *apeChecker) List(ctx context.Context, req *container.ListRequest) (*co
|
||||||
reqProps,
|
reqProps,
|
||||||
)
|
)
|
||||||
|
|
||||||
groups, err := aperequest.Groups(ac.frostFSIDClient, pk)
|
groups, err := aperequest.Groups(ctx, ac.frostFSIDClient, pk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to get group ids: %w", err)
|
return nil, fmt.Errorf("failed to get group ids: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ func (ac *apeChecker) ListStream(req *container.ListStreamRequest, stream ListSt
|
||||||
ctx, span := tracing.StartSpanFromContext(stream.Context(), "apeChecker.ListStream")
|
ctx, span := tracing.StartSpanFromContext(stream.Context(), "apeChecker.ListStream")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
role, pk, err := ac.getRoleWithoutContainerID(req.GetBody().GetOwnerID(), req.GetMetaHeader(), req.GetVerificationHeader())
|
role, pk, err := ac.getRoleWithoutContainerID(stream.Context(), req.GetBody().GetOwnerID(), req.GetMetaHeader(), req.GetVerificationHeader())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,7 @@ func (ac *apeChecker) ListStream(req *container.ListStreamRequest, stream ListSt
|
||||||
nativeschema.PropertyKeyActorRole: role,
|
nativeschema.PropertyKeyActorRole: role,
|
||||||
}
|
}
|
||||||
|
|
||||||
reqProps, err = ac.fillWithUserClaimTags(reqProps, pk)
|
reqProps, err = ac.fillWithUserClaimTags(ctx, reqProps, pk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -199,11 +199,11 @@ func (ac *apeChecker) ListStream(req *container.ListStreamRequest, stream ListSt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace, err := ac.namespaceByOwner(req.GetBody().GetOwnerID())
|
namespace, err := ac.namespaceByOwner(ctx, req.GetBody().GetOwnerID())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not get owner namespace: %w", err)
|
return fmt.Errorf("could not get owner namespace: %w", err)
|
||||||
}
|
}
|
||||||
if err := ac.validateNamespaceByPublicKey(pk, namespace); err != nil {
|
if err := ac.validateNamespaceByPublicKey(ctx, pk, namespace); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ func (ac *apeChecker) ListStream(req *container.ListStreamRequest, stream ListSt
|
||||||
reqProps,
|
reqProps,
|
||||||
)
|
)
|
||||||
|
|
||||||
groups, err := aperequest.Groups(ac.frostFSIDClient, pk)
|
groups, err := aperequest.Groups(ctx, ac.frostFSIDClient, pk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to get group ids: %w", err)
|
return fmt.Errorf("failed to get group ids: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -252,7 +252,7 @@ func (ac *apeChecker) Put(ctx context.Context, req *container.PutRequest) (*cont
|
||||||
ctx, span := tracing.StartSpanFromContext(ctx, "apeChecker.Put")
|
ctx, span := tracing.StartSpanFromContext(ctx, "apeChecker.Put")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
role, pk, err := ac.getRoleWithoutContainerID(req.GetBody().GetContainer().GetOwnerID(), req.GetMetaHeader(), req.GetVerificationHeader())
|
role, pk, err := ac.getRoleWithoutContainerID(ctx, req.GetBody().GetContainer().GetOwnerID(), req.GetMetaHeader(), req.GetVerificationHeader())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -262,7 +262,7 @@ func (ac *apeChecker) Put(ctx context.Context, req *container.PutRequest) (*cont
|
||||||
nativeschema.PropertyKeyActorRole: role,
|
nativeschema.PropertyKeyActorRole: role,
|
||||||
}
|
}
|
||||||
|
|
||||||
reqProps, err = ac.fillWithUserClaimTags(reqProps, pk)
|
reqProps, err = ac.fillWithUserClaimTags(ctx, reqProps, pk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,7 @@ func (ac *apeChecker) Put(ctx context.Context, req *container.PutRequest) (*cont
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace, err := ac.namespaceByKnownOwner(req.GetBody().GetContainer().GetOwnerID())
|
namespace, err := ac.namespaceByKnownOwner(ctx, req.GetBody().GetContainer().GetOwnerID())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("get namespace error: %w", err)
|
return nil, fmt.Errorf("get namespace error: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -289,7 +289,7 @@ func (ac *apeChecker) Put(ctx context.Context, req *container.PutRequest) (*cont
|
||||||
reqProps,
|
reqProps,
|
||||||
)
|
)
|
||||||
|
|
||||||
groups, err := aperequest.Groups(ac.frostFSIDClient, pk)
|
groups, err := aperequest.Groups(ctx, ac.frostFSIDClient, pk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to get group ids: %w", err)
|
return nil, fmt.Errorf("failed to get group ids: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -321,7 +321,7 @@ func (ac *apeChecker) Put(ctx context.Context, req *container.PutRequest) (*cont
|
||||||
return nil, apeErr(nativeschema.MethodPutContainer, s)
|
return nil, apeErr(nativeschema.MethodPutContainer, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ac *apeChecker) getRoleWithoutContainerID(oID *refs.OwnerID, mh *session.RequestMetaHeader, vh *session.RequestVerificationHeader) (string, *keys.PublicKey, error) {
|
func (ac *apeChecker) getRoleWithoutContainerID(ctx context.Context, oID *refs.OwnerID, mh *session.RequestMetaHeader, vh *session.RequestVerificationHeader) (string, *keys.PublicKey, error) {
|
||||||
if vh == nil {
|
if vh == nil {
|
||||||
return "", nil, errMissingVerificationHeader
|
return "", nil, errMissingVerificationHeader
|
||||||
}
|
}
|
||||||
|
@ -344,7 +344,7 @@ func (ac *apeChecker) getRoleWithoutContainerID(oID *refs.OwnerID, mh *session.R
|
||||||
}
|
}
|
||||||
|
|
||||||
pkBytes := pk.Bytes()
|
pkBytes := pk.Bytes()
|
||||||
isIR, err := ac.isInnerRingKey(pkBytes)
|
isIR, err := ac.isInnerRingKey(ctx, pkBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", nil, err
|
return "", nil, err
|
||||||
}
|
}
|
||||||
|
@ -365,7 +365,7 @@ func (ac *apeChecker) validateContainerBoundedOperation(ctx context.Context, con
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
cont, err := ac.reader.Get(id)
|
cont, err := ac.reader.Get(ctx, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -381,7 +381,7 @@ func (ac *apeChecker) validateContainerBoundedOperation(ctx context.Context, con
|
||||||
namespace = cntNamespace
|
namespace = cntNamespace
|
||||||
}
|
}
|
||||||
|
|
||||||
groups, err := aperequest.Groups(ac.frostFSIDClient, pk)
|
groups, err := aperequest.Groups(ctx, ac.frostFSIDClient, pk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to get group ids: %w", err)
|
return fmt.Errorf("failed to get group ids: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -458,7 +458,7 @@ func (ac *apeChecker) getRequestProps(ctx context.Context, mh *session.RequestMe
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
role, err := ac.getRole(actor, pk, cont, cnrID)
|
role, err := ac.getRole(ctx, actor, pk, cont, cnrID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
@ -466,7 +466,7 @@ func (ac *apeChecker) getRequestProps(ctx context.Context, mh *session.RequestMe
|
||||||
nativeschema.PropertyKeyActorPublicKey: hex.EncodeToString(pk.Bytes()),
|
nativeschema.PropertyKeyActorPublicKey: hex.EncodeToString(pk.Bytes()),
|
||||||
nativeschema.PropertyKeyActorRole: role,
|
nativeschema.PropertyKeyActorRole: role,
|
||||||
}
|
}
|
||||||
reqProps, err = ac.fillWithUserClaimTags(reqProps, pk)
|
reqProps, err = ac.fillWithUserClaimTags(ctx, reqProps, pk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
@ -478,13 +478,13 @@ func (ac *apeChecker) getRequestProps(ctx context.Context, mh *session.RequestMe
|
||||||
return reqProps, pk, nil
|
return reqProps, pk, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ac *apeChecker) getRole(actor *user.ID, pk *keys.PublicKey, cont *containercore.Container, cnrID cid.ID) (string, error) {
|
func (ac *apeChecker) getRole(ctx context.Context, actor *user.ID, pk *keys.PublicKey, cont *containercore.Container, cnrID cid.ID) (string, error) {
|
||||||
if cont.Value.Owner().Equals(*actor) {
|
if cont.Value.Owner().Equals(*actor) {
|
||||||
return nativeschema.PropertyValueContainerRoleOwner, nil
|
return nativeschema.PropertyValueContainerRoleOwner, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
pkBytes := pk.Bytes()
|
pkBytes := pk.Bytes()
|
||||||
isIR, err := ac.isInnerRingKey(pkBytes)
|
isIR, err := ac.isInnerRingKey(ctx, pkBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -492,7 +492,7 @@ func (ac *apeChecker) getRole(actor *user.ID, pk *keys.PublicKey, cont *containe
|
||||||
return nativeschema.PropertyValueContainerRoleIR, nil
|
return nativeschema.PropertyValueContainerRoleIR, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
isContainer, err := ac.isContainerKey(pkBytes, cnrID, cont)
|
isContainer, err := ac.isContainerKey(ctx, pkBytes, cnrID, cont)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -586,8 +586,8 @@ func isOwnerFromKey(id user.ID, key *keys.PublicKey) bool {
|
||||||
return id2.Equals(id)
|
return id2.Equals(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ac *apeChecker) isInnerRingKey(pk []byte) (bool, error) {
|
func (ac *apeChecker) isInnerRingKey(ctx context.Context, pk []byte) (bool, error) {
|
||||||
innerRingKeys, err := ac.ir.InnerRingKeys()
|
innerRingKeys, err := ac.ir.InnerRingKeys(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
@ -601,11 +601,11 @@ func (ac *apeChecker) isInnerRingKey(pk []byte) (bool, error) {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ac *apeChecker) isContainerKey(pk []byte, cnrID cid.ID, cont *containercore.Container) (bool, error) {
|
func (ac *apeChecker) isContainerKey(ctx context.Context, pk []byte, cnrID cid.ID, cont *containercore.Container) (bool, error) {
|
||||||
binCnrID := make([]byte, sha256.Size)
|
binCnrID := make([]byte, sha256.Size)
|
||||||
cnrID.Encode(binCnrID)
|
cnrID.Encode(binCnrID)
|
||||||
|
|
||||||
nm, err := netmap.GetLatestNetworkMap(ac.nm)
|
nm, err := netmap.GetLatestNetworkMap(ctx, ac.nm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
@ -616,7 +616,7 @@ func (ac *apeChecker) isContainerKey(pk []byte, cnrID cid.ID, cont *containercor
|
||||||
|
|
||||||
// then check previous netmap, this can happen in-between epoch change
|
// then check previous netmap, this can happen in-between epoch change
|
||||||
// when node migrates data from last epoch container
|
// when node migrates data from last epoch container
|
||||||
nm, err = netmap.GetPreviousNetworkMap(ac.nm)
|
nm, err = netmap.GetPreviousNetworkMap(ctx, ac.nm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
@ -641,7 +641,7 @@ func isContainerNode(nm *netmapSDK.NetMap, pk, binCnrID []byte, cont *containerc
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ac *apeChecker) namespaceByOwner(owner *refs.OwnerID) (string, error) {
|
func (ac *apeChecker) namespaceByOwner(ctx context.Context, owner *refs.OwnerID) (string, error) {
|
||||||
var ownerSDK user.ID
|
var ownerSDK user.ID
|
||||||
if owner == nil {
|
if owner == nil {
|
||||||
return "", errOwnerIDIsNotSet
|
return "", errOwnerIDIsNotSet
|
||||||
|
@ -652,7 +652,7 @@ func (ac *apeChecker) namespaceByOwner(owner *refs.OwnerID) (string, error) {
|
||||||
addr := ownerSDK.ScriptHash()
|
addr := ownerSDK.ScriptHash()
|
||||||
|
|
||||||
namespace := ""
|
namespace := ""
|
||||||
subject, err := ac.frostFSIDClient.GetSubject(addr)
|
subject, err := ac.frostFSIDClient.GetSubject(ctx, addr)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
namespace = subject.Namespace
|
namespace = subject.Namespace
|
||||||
} else {
|
} else {
|
||||||
|
@ -663,7 +663,7 @@ func (ac *apeChecker) namespaceByOwner(owner *refs.OwnerID) (string, error) {
|
||||||
return namespace, nil
|
return namespace, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ac *apeChecker) namespaceByKnownOwner(owner *refs.OwnerID) (string, error) {
|
func (ac *apeChecker) namespaceByKnownOwner(ctx context.Context, owner *refs.OwnerID) (string, error) {
|
||||||
var ownerSDK user.ID
|
var ownerSDK user.ID
|
||||||
if owner == nil {
|
if owner == nil {
|
||||||
return "", errOwnerIDIsNotSet
|
return "", errOwnerIDIsNotSet
|
||||||
|
@ -672,7 +672,7 @@ func (ac *apeChecker) namespaceByKnownOwner(owner *refs.OwnerID) (string, error)
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
addr := ownerSDK.ScriptHash()
|
addr := ownerSDK.ScriptHash()
|
||||||
subject, err := ac.frostFSIDClient.GetSubject(addr)
|
subject, err := ac.frostFSIDClient.GetSubject(ctx, addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("get subject error: %w", err)
|
return "", fmt.Errorf("get subject error: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -706,12 +706,12 @@ func validateNamespace(cnrV2 *container.Container, ownerIDNamespace string) erro
|
||||||
|
|
||||||
// validateNamespace validates if a namespace of a request actor equals to owner's namespace.
|
// validateNamespace validates if a namespace of a request actor equals to owner's namespace.
|
||||||
// An actor's namespace is calculated by a public key.
|
// An actor's namespace is calculated by a public key.
|
||||||
func (ac *apeChecker) validateNamespaceByPublicKey(pk *keys.PublicKey, ownerIDNamespace string) error {
|
func (ac *apeChecker) validateNamespaceByPublicKey(ctx context.Context, pk *keys.PublicKey, ownerIDNamespace string) error {
|
||||||
var actor user.ID
|
var actor user.ID
|
||||||
user.IDFromKey(&actor, (ecdsa.PublicKey)(*pk))
|
user.IDFromKey(&actor, (ecdsa.PublicKey)(*pk))
|
||||||
actorOwnerID := new(refs.OwnerID)
|
actorOwnerID := new(refs.OwnerID)
|
||||||
actor.WriteToV2(actorOwnerID)
|
actor.WriteToV2(actorOwnerID)
|
||||||
actorNamespace, err := ac.namespaceByOwner(actorOwnerID)
|
actorNamespace, err := ac.namespaceByOwner(ctx, actorOwnerID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not get actor namespace: %w", err)
|
return fmt.Errorf("could not get actor namespace: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -722,11 +722,11 @@ func (ac *apeChecker) validateNamespaceByPublicKey(pk *keys.PublicKey, ownerIDNa
|
||||||
}
|
}
|
||||||
|
|
||||||
// fillWithUserClaimTags fills ape request properties with user claim tags getting them from frostfsid contract by actor public key.
|
// fillWithUserClaimTags fills ape request properties with user claim tags getting them from frostfsid contract by actor public key.
|
||||||
func (ac *apeChecker) fillWithUserClaimTags(reqProps map[string]string, pk *keys.PublicKey) (map[string]string, error) {
|
func (ac *apeChecker) fillWithUserClaimTags(ctx context.Context, reqProps map[string]string, pk *keys.PublicKey) (map[string]string, error) {
|
||||||
if reqProps == nil {
|
if reqProps == nil {
|
||||||
reqProps = make(map[string]string)
|
reqProps = make(map[string]string)
|
||||||
}
|
}
|
||||||
props, err := aperequest.FormFrostfsIDRequestProperties(ac.frostFSIDClient, pk)
|
props, err := aperequest.FormFrostfsIDRequestProperties(ctx, ac.frostFSIDClient, pk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return reqProps, err
|
return reqProps, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1092,7 +1092,7 @@ type irStub struct {
|
||||||
keys [][]byte
|
keys [][]byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *irStub) InnerRingKeys() ([][]byte, error) {
|
func (s *irStub) InnerRingKeys(_ context.Context) ([][]byte, error) {
|
||||||
return s.keys, nil
|
return s.keys, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1100,7 +1100,7 @@ type containerStub struct {
|
||||||
c map[cid.ID]*containercore.Container
|
c map[cid.ID]*containercore.Container
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *containerStub) Get(id cid.ID) (*containercore.Container, error) {
|
func (s *containerStub) Get(_ context.Context, id cid.ID) (*containercore.Container, error) {
|
||||||
if v, ok := s.c[id]; ok {
|
if v, ok := s.c[id]; ok {
|
||||||
return v, nil
|
return v, nil
|
||||||
}
|
}
|
||||||
|
@ -1112,21 +1112,21 @@ type netmapStub struct {
|
||||||
currentEpoch uint64
|
currentEpoch uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *netmapStub) GetNetMap(diff uint64) (*netmap.NetMap, error) {
|
func (s *netmapStub) GetNetMap(ctx context.Context, diff uint64) (*netmap.NetMap, error) {
|
||||||
if diff >= s.currentEpoch {
|
if diff >= s.currentEpoch {
|
||||||
return nil, errors.New("invalid diff")
|
return nil, errors.New("invalid diff")
|
||||||
}
|
}
|
||||||
return s.GetNetMapByEpoch(s.currentEpoch - diff)
|
return s.GetNetMapByEpoch(ctx, s.currentEpoch-diff)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *netmapStub) GetNetMapByEpoch(epoch uint64) (*netmap.NetMap, error) {
|
func (s *netmapStub) GetNetMapByEpoch(ctx context.Context, epoch uint64) (*netmap.NetMap, error) {
|
||||||
if nm, found := s.netmaps[epoch]; found {
|
if nm, found := s.netmaps[epoch]; found {
|
||||||
return nm, nil
|
return nm, nil
|
||||||
}
|
}
|
||||||
return nil, errors.New("netmap not found")
|
return nil, errors.New("netmap not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *netmapStub) Epoch() (uint64, error) {
|
func (s *netmapStub) Epoch(ctx context.Context) (uint64, error) {
|
||||||
return s.currentEpoch, nil
|
return s.currentEpoch, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1135,7 +1135,7 @@ type frostfsidStub struct {
|
||||||
subjectsExt map[util.Uint160]*client.SubjectExtended
|
subjectsExt map[util.Uint160]*client.SubjectExtended
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *frostfsidStub) GetSubject(owner util.Uint160) (*client.Subject, error) {
|
func (f *frostfsidStub) GetSubject(ctx context.Context, owner util.Uint160) (*client.Subject, error) {
|
||||||
s, ok := f.subjects[owner]
|
s, ok := f.subjects[owner]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("%s", frostfsidcore.SubjectNotFoundErrorMessage)
|
return nil, fmt.Errorf("%s", frostfsidcore.SubjectNotFoundErrorMessage)
|
||||||
|
@ -1143,7 +1143,7 @@ func (f *frostfsidStub) GetSubject(owner util.Uint160) (*client.Subject, error)
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *frostfsidStub) GetSubjectExtended(owner util.Uint160) (*client.SubjectExtended, error) {
|
func (f *frostfsidStub) GetSubjectExtended(ctx context.Context, owner util.Uint160) (*client.SubjectExtended, error) {
|
||||||
s, ok := f.subjectsExt[owner]
|
s, ok := f.subjectsExt[owner]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("%s", frostfsidcore.SubjectNotFoundErrorMessage)
|
return nil, fmt.Errorf("%s", frostfsidcore.SubjectNotFoundErrorMessage)
|
||||||
|
|
|
@ -29,8 +29,8 @@ type Reader interface {
|
||||||
// ContainersOf returns a list of container identifiers belonging
|
// ContainersOf returns a list of container identifiers belonging
|
||||||
// to the specified user of FrostFS system. Returns the identifiers
|
// to the specified user of FrostFS system. Returns the identifiers
|
||||||
// of all FrostFS containers if pointer to owner identifier is nil.
|
// of all FrostFS containers if pointer to owner identifier is nil.
|
||||||
ContainersOf(*user.ID) ([]cid.ID, error)
|
ContainersOf(context.Context, *user.ID) ([]cid.ID, error)
|
||||||
IterateContainersOf(*user.ID, func(cid.ID) error) error
|
IterateContainersOf(context.Context, *user.ID, func(cid.ID) error) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// Writer is an interface of container storage updater.
|
// Writer is an interface of container storage updater.
|
||||||
|
@ -133,7 +133,7 @@ func (s *morphExecutor) Delete(ctx context.Context, tokV2 *sessionV2.Token, body
|
||||||
return new(container.DeleteResponseBody), nil
|
return new(container.DeleteResponseBody), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *morphExecutor) Get(_ context.Context, body *container.GetRequestBody) (*container.GetResponseBody, error) {
|
func (s *morphExecutor) Get(ctx context.Context, body *container.GetRequestBody) (*container.GetResponseBody, error) {
|
||||||
idV2 := body.GetContainerID()
|
idV2 := body.GetContainerID()
|
||||||
if idV2 == nil {
|
if idV2 == nil {
|
||||||
return nil, errors.New("missing container ID")
|
return nil, errors.New("missing container ID")
|
||||||
|
@ -146,7 +146,7 @@ func (s *morphExecutor) Get(_ context.Context, body *container.GetRequestBody) (
|
||||||
return nil, fmt.Errorf("invalid container ID: %w", err)
|
return nil, fmt.Errorf("invalid container ID: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cnr, err := s.rdr.Get(id)
|
cnr, err := s.rdr.Get(ctx, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ func (s *morphExecutor) Get(_ context.Context, body *container.GetRequestBody) (
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *morphExecutor) List(_ context.Context, body *container.ListRequestBody) (*container.ListResponseBody, error) {
|
func (s *morphExecutor) List(ctx context.Context, body *container.ListRequestBody) (*container.ListResponseBody, error) {
|
||||||
idV2 := body.GetOwnerID()
|
idV2 := body.GetOwnerID()
|
||||||
if idV2 == nil {
|
if idV2 == nil {
|
||||||
return nil, errMissingUserID
|
return nil, errMissingUserID
|
||||||
|
@ -186,7 +186,7 @@ func (s *morphExecutor) List(_ context.Context, body *container.ListRequestBody)
|
||||||
return nil, fmt.Errorf("invalid user ID: %w", err)
|
return nil, fmt.Errorf("invalid user ID: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cnrs, err := s.rdr.ContainersOf(&id)
|
cnrs, err := s.rdr.ContainersOf(ctx, &id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -243,7 +243,7 @@ func (s *morphExecutor) ListStream(ctx context.Context, req *container.ListStrea
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = s.rdr.IterateContainersOf(&id, processCID); err != nil {
|
if err = s.rdr.IterateContainersOf(ctx, &id, processCID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ func (s *Server) TickEpoch(ctx context.Context, req *control.TickEpochRequest) (
|
||||||
resp := new(control.TickEpochResponse)
|
resp := new(control.TickEpochResponse)
|
||||||
resp.SetBody(new(control.TickEpochResponse_Body))
|
resp.SetBody(new(control.TickEpochResponse_Body))
|
||||||
|
|
||||||
epoch, err := s.netmapClient.Epoch()
|
epoch, err := s.netmapClient.Epoch(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("getting current epoch: %w", err)
|
return nil, fmt.Errorf("getting current epoch: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ func (s *Server) RemoveNode(ctx context.Context, req *control.RemoveNodeRequest)
|
||||||
resp := new(control.RemoveNodeResponse)
|
resp := new(control.RemoveNodeResponse)
|
||||||
resp.SetBody(new(control.RemoveNodeResponse_Body))
|
resp.SetBody(new(control.RemoveNodeResponse_Body))
|
||||||
|
|
||||||
nm, err := s.netmapClient.NetMap()
|
nm, err := s.netmapClient.NetMap(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("getting netmap: %w", err)
|
return nil, fmt.Errorf("getting netmap: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ func (s *Server) RemoveContainer(ctx context.Context, req *control.RemoveContain
|
||||||
return nil, status.Error(codes.InvalidArgument, "failed to read owner: "+err.Error())
|
return nil, status.Error(codes.InvalidArgument, "failed to read owner: "+err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
cids, err := s.containerClient.ContainersOf(&owner)
|
cids, err := s.containerClient.ContainersOf(ctx, &owner)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to get owner's containers: %w", err)
|
return nil, fmt.Errorf("failed to get owner's containers: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package control
|
package control
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/client"
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/client"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/common"
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/common"
|
||||||
)
|
)
|
||||||
|
@ -73,6 +75,7 @@ func SetNetmapStatus(
|
||||||
|
|
||||||
// GetNetmapStatus executes ControlService.GetNetmapStatus RPC.
|
// GetNetmapStatus executes ControlService.GetNetmapStatus RPC.
|
||||||
func GetNetmapStatus(
|
func GetNetmapStatus(
|
||||||
|
_ context.Context,
|
||||||
cli *client.Client,
|
cli *client.Client,
|
||||||
req *GetNetmapStatusRequest,
|
req *GetNetmapStatusRequest,
|
||||||
opts ...client.CallOption,
|
opts ...client.CallOption,
|
||||||
|
|
|
@ -157,7 +157,7 @@ func (s *Server) replicateObject(ctx context.Context, addr oid.Address, obj *obj
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
nodes, err := s.getContainerNodes(cid)
|
nodes, err := s.getContainerNodes(ctx, cid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ func (s *Server) replicateObject(ctx context.Context, addr oid.Address, obj *obj
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) replicateTree(ctx context.Context, contID cid.ID, treeID string, forest pilorama.Forest) (bool, string, error) {
|
func (s *Server) replicateTree(ctx context.Context, contID cid.ID, treeID string, forest pilorama.Forest) (bool, string, error) {
|
||||||
nodes, err := s.getContainerNodes(contID)
|
nodes, err := s.getContainerNodes(ctx, contID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, "", err
|
return false, "", err
|
||||||
}
|
}
|
||||||
|
@ -240,13 +240,13 @@ func (s *Server) replicateTreeToNode(ctx context.Context, forest pilorama.Forest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) getContainerNodes(contID cid.ID) ([]netmap.NodeInfo, error) {
|
func (s *Server) getContainerNodes(ctx context.Context, contID cid.ID) ([]netmap.NodeInfo, error) {
|
||||||
nm, err := s.netMapSrc.GetNetMap(0)
|
nm, err := s.netMapSrc.GetNetMap(ctx, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
c, err := s.cnrSrc.Get(contID)
|
c, err := s.cnrSrc.Get(ctx, contID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,12 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetNetmapStatus gets node status in FrostFS network.
|
// GetNetmapStatus gets node status in FrostFS network.
|
||||||
func (s *Server) GetNetmapStatus(_ context.Context, req *control.GetNetmapStatusRequest) (*control.GetNetmapStatusResponse, error) {
|
func (s *Server) GetNetmapStatus(ctx context.Context, req *control.GetNetmapStatusRequest) (*control.GetNetmapStatusResponse, error) {
|
||||||
if err := s.isValidRequest(req); err != nil {
|
if err := s.isValidRequest(req); err != nil {
|
||||||
return nil, status.Error(codes.PermissionDenied, err.Error())
|
return nil, status.Error(codes.PermissionDenied, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
st, epoch, err := s.nodeState.GetNetmapStatus()
|
st, epoch, err := s.nodeState.GetNetmapStatus(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ type NodeState interface {
|
||||||
// but starts local maintenance regardless of the network settings.
|
// but starts local maintenance regardless of the network settings.
|
||||||
ForceMaintenance(ctx context.Context) error
|
ForceMaintenance(ctx context.Context) error
|
||||||
|
|
||||||
GetNetmapStatus() (control.NetmapStatus, uint64, error)
|
GetNetmapStatus(ctx context.Context) (control.NetmapStatus, uint64, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// LocalOverrideStorageDecorator interface provides methods to decorate LocalOverrideEngine
|
// LocalOverrideStorageDecorator interface provides methods to decorate LocalOverrideEngine
|
||||||
|
|
|
@ -42,7 +42,7 @@ type NetworkInfo interface {
|
||||||
// Dump must return recent network information in FrostFS API v2 NetworkInfo structure.
|
// Dump must return recent network information in FrostFS API v2 NetworkInfo structure.
|
||||||
//
|
//
|
||||||
// If protocol version is <=2.9, MillisecondsPerBlock and network config should be unset.
|
// If protocol version is <=2.9, MillisecondsPerBlock and network config should be unset.
|
||||||
Dump(versionsdk.Version) (*netmapSDK.NetworkInfo, error)
|
Dump(context.Context, versionsdk.Version) (*netmapSDK.NetworkInfo, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewExecutionService(s NodeState, v versionsdk.Version, netInfo NetworkInfo, respSvc *response.Service) Server {
|
func NewExecutionService(s NodeState, v versionsdk.Version, netInfo NetworkInfo, respSvc *response.Service) Server {
|
||||||
|
@ -82,7 +82,7 @@ func (s *executorSvc) LocalNodeInfo(
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *executorSvc) NetworkInfo(
|
func (s *executorSvc) NetworkInfo(
|
||||||
_ context.Context,
|
ctx context.Context,
|
||||||
req *netmap.NetworkInfoRequest,
|
req *netmap.NetworkInfoRequest,
|
||||||
) (*netmap.NetworkInfoResponse, error) {
|
) (*netmap.NetworkInfoResponse, error) {
|
||||||
verV2 := req.GetMetaHeader().GetVersion()
|
verV2 := req.GetMetaHeader().GetVersion()
|
||||||
|
@ -95,7 +95,7 @@ func (s *executorSvc) NetworkInfo(
|
||||||
return nil, fmt.Errorf("can't read version: %w", err)
|
return nil, fmt.Errorf("can't read version: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ni, err := s.netInfo.Dump(ver)
|
ni, err := s.netInfo.Dump(ctx, ver)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -669,13 +669,13 @@ func (p patchStreamBasicChecker) CloseAndRecv(ctx context.Context) (*objectV2.Pa
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b Service) findRequestInfo(ctx context.Context, req MetaWithToken, idCnr cid.ID, op acl.Op) (info RequestInfo, err error) {
|
func (b Service) findRequestInfo(ctx context.Context, req MetaWithToken, idCnr cid.ID, op acl.Op) (info RequestInfo, err error) {
|
||||||
cnr, err := b.containers.Get(idCnr) // fetch actual container
|
cnr, err := b.containers.Get(ctx, idCnr) // fetch actual container
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return info, err
|
return info, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.token != nil {
|
if req.token != nil {
|
||||||
currentEpoch, err := b.nm.Epoch()
|
currentEpoch, err := b.nm.Epoch(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return info, errors.New("can't fetch current epoch")
|
return info, errors.New("can't fetch current epoch")
|
||||||
}
|
}
|
||||||
|
@ -727,13 +727,13 @@ func (b Service) findRequestInfo(ctx context.Context, req MetaWithToken, idCnr c
|
||||||
|
|
||||||
// findRequestInfoWithoutACLOperationAssert is findRequestInfo without session token verb assert.
|
// findRequestInfoWithoutACLOperationAssert is findRequestInfo without session token verb assert.
|
||||||
func (b Service) findRequestInfoWithoutACLOperationAssert(ctx context.Context, req MetaWithToken, idCnr cid.ID) (info RequestInfo, err error) {
|
func (b Service) findRequestInfoWithoutACLOperationAssert(ctx context.Context, req MetaWithToken, idCnr cid.ID) (info RequestInfo, err error) {
|
||||||
cnr, err := b.containers.Get(idCnr) // fetch actual container
|
cnr, err := b.containers.Get(ctx, idCnr) // fetch actual container
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return info, err
|
return info, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.token != nil {
|
if req.token != nil {
|
||||||
currentEpoch, err := b.nm.Epoch()
|
currentEpoch, err := b.nm.Epoch(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return info, errors.New("can't fetch current epoch")
|
return info, errors.New("can't fetch current epoch")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package v2
|
package v2
|
||||||
|
|
||||||
|
import "context"
|
||||||
|
|
||||||
// InnerRingFetcher is an interface that must provide
|
// InnerRingFetcher is an interface that must provide
|
||||||
// Inner Ring information.
|
// Inner Ring information.
|
||||||
type InnerRingFetcher interface {
|
type InnerRingFetcher interface {
|
||||||
// InnerRingKeys must return list of public keys of
|
// InnerRingKeys must return list of public keys of
|
||||||
// the actual inner ring.
|
// the actual inner ring.
|
||||||
InnerRingKeys() ([][]byte, error)
|
InnerRingKeys(ctx context.Context) ([][]byte, error)
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ func (c *checkerImpl) CheckAPE(ctx context.Context, prm Prm) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.checkerCore.CheckAPE(checkercore.CheckPrm{
|
return c.checkerCore.CheckAPE(ctx, checkercore.CheckPrm{
|
||||||
Request: r,
|
Request: r,
|
||||||
PublicKey: pub,
|
PublicKey: pub,
|
||||||
Namespace: prm.Namespace,
|
Namespace: prm.Namespace,
|
||||||
|
|
|
@ -219,7 +219,7 @@ func scriptHashFromSenderKey(t *testing.T, senderKey string) util.Uint160 {
|
||||||
return pk.GetScriptHash()
|
return pk.GetScriptHash()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *frostfsIDProviderMock) GetSubject(key util.Uint160) (*client.Subject, error) {
|
func (f *frostfsIDProviderMock) GetSubject(ctx context.Context, key util.Uint160) (*client.Subject, error) {
|
||||||
v, ok := f.subjects[key]
|
v, ok := f.subjects[key]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("%s", frostfsidcore.SubjectNotFoundErrorMessage)
|
return nil, fmt.Errorf("%s", frostfsidcore.SubjectNotFoundErrorMessage)
|
||||||
|
@ -227,7 +227,7 @@ func (f *frostfsIDProviderMock) GetSubject(key util.Uint160) (*client.Subject, e
|
||||||
return v, nil
|
return v, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *frostfsIDProviderMock) GetSubjectExtended(key util.Uint160) (*client.SubjectExtended, error) {
|
func (f *frostfsIDProviderMock) GetSubjectExtended(ctx context.Context, key util.Uint160) (*client.SubjectExtended, error) {
|
||||||
v, ok := f.subjectsExtended[key]
|
v, ok := f.subjectsExtended[key]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("%s", frostfsidcore.SubjectNotFoundErrorMessage)
|
return nil, fmt.Errorf("%s", frostfsidcore.SubjectNotFoundErrorMessage)
|
||||||
|
@ -619,21 +619,21 @@ type netmapStub struct {
|
||||||
currentEpoch uint64
|
currentEpoch uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *netmapStub) GetNetMap(diff uint64) (*netmapSDK.NetMap, error) {
|
func (s *netmapStub) GetNetMap(ctx context.Context, diff uint64) (*netmapSDK.NetMap, error) {
|
||||||
if diff >= s.currentEpoch {
|
if diff >= s.currentEpoch {
|
||||||
return nil, errors.New("invalid diff")
|
return nil, errors.New("invalid diff")
|
||||||
}
|
}
|
||||||
return s.GetNetMapByEpoch(s.currentEpoch - diff)
|
return s.GetNetMapByEpoch(ctx, s.currentEpoch-diff)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *netmapStub) GetNetMapByEpoch(epoch uint64) (*netmapSDK.NetMap, error) {
|
func (s *netmapStub) GetNetMapByEpoch(ctx context.Context, epoch uint64) (*netmapSDK.NetMap, error) {
|
||||||
if nm, found := s.netmaps[epoch]; found {
|
if nm, found := s.netmaps[epoch]; found {
|
||||||
return nm, nil
|
return nm, nil
|
||||||
}
|
}
|
||||||
return nil, errors.New("netmap not found")
|
return nil, errors.New("netmap not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *netmapStub) Epoch() (uint64, error) {
|
func (s *netmapStub) Epoch(ctx context.Context) (uint64, error) {
|
||||||
return s.currentEpoch, nil
|
return s.currentEpoch, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -641,14 +641,14 @@ type testContainerSource struct {
|
||||||
containers map[cid.ID]*container.Container
|
containers map[cid.ID]*container.Container
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *testContainerSource) Get(cnrID cid.ID) (*container.Container, error) {
|
func (s *testContainerSource) Get(ctx context.Context, cnrID cid.ID) (*container.Container, error) {
|
||||||
if cnr, found := s.containers[cnrID]; found {
|
if cnr, found := s.containers[cnrID]; found {
|
||||||
return cnr, nil
|
return cnr, nil
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("container not found")
|
return nil, fmt.Errorf("container not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *testContainerSource) DeletionInfo(cid.ID) (*container.DelInfo, error) {
|
func (s *testContainerSource) DeletionInfo(context.Context, cid.ID) (*container.DelInfo, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,7 @@ func (c *checkerImpl) newAPERequest(ctx context.Context, prm Prm) (aperequest.Re
|
||||||
reqProps[xheadKey] = xhead.GetValue()
|
reqProps[xheadKey] = xhead.GetValue()
|
||||||
}
|
}
|
||||||
|
|
||||||
reqProps, err = c.fillWithUserClaimTags(reqProps, prm)
|
reqProps, err = c.fillWithUserClaimTags(ctx, reqProps, prm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return defaultRequest, err
|
return defaultRequest, err
|
||||||
}
|
}
|
||||||
|
@ -177,7 +177,7 @@ func (c *checkerImpl) fillHeaderWithECParent(ctx context.Context, prm Prm, heade
|
||||||
return nil, fmt.Errorf("EC parent object ID format error: %w", err)
|
return nil, fmt.Errorf("EC parent object ID format error: %w", err)
|
||||||
}
|
}
|
||||||
// only container node have access to collect parent object
|
// only container node have access to collect parent object
|
||||||
contNode, err := c.currentNodeIsContainerNode(prm.Container)
|
contNode, err := c.currentNodeIsContainerNode(ctx, prm.Container)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("check container node status: %w", err)
|
return nil, fmt.Errorf("check container node status: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -200,13 +200,13 @@ func isLogicalError(err error) bool {
|
||||||
return errors.As(err, &errObjRemoved) || errors.As(err, &errObjNotFound)
|
return errors.As(err, &errObjRemoved) || errors.As(err, &errObjNotFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *checkerImpl) currentNodeIsContainerNode(cnrID cid.ID) (bool, error) {
|
func (c *checkerImpl) currentNodeIsContainerNode(ctx context.Context, cnrID cid.ID) (bool, error) {
|
||||||
cnr, err := c.cnrSource.Get(cnrID)
|
cnr, err := c.cnrSource.Get(ctx, cnrID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
nm, err := netmap.GetLatestNetworkMap(c.nm)
|
nm, err := netmap.GetLatestNetworkMap(ctx, c.nm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
@ -220,7 +220,7 @@ func (c *checkerImpl) currentNodeIsContainerNode(cnrID cid.ID) (bool, error) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
nm, err = netmap.GetPreviousNetworkMap(c.nm)
|
nm, err = netmap.GetPreviousNetworkMap(ctx, c.nm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
@ -229,7 +229,7 @@ func (c *checkerImpl) currentNodeIsContainerNode(cnrID cid.ID) (bool, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// fillWithUserClaimTags fills ape request properties with user claim tags getting them from frostfsid contract by actor public key.
|
// fillWithUserClaimTags fills ape request properties with user claim tags getting them from frostfsid contract by actor public key.
|
||||||
func (c *checkerImpl) fillWithUserClaimTags(reqProps map[string]string, prm Prm) (map[string]string, error) {
|
func (c *checkerImpl) fillWithUserClaimTags(ctx context.Context, reqProps map[string]string, prm Prm) (map[string]string, error) {
|
||||||
if reqProps == nil {
|
if reqProps == nil {
|
||||||
reqProps = make(map[string]string)
|
reqProps = make(map[string]string)
|
||||||
}
|
}
|
||||||
|
@ -237,7 +237,7 @@ func (c *checkerImpl) fillWithUserClaimTags(reqProps map[string]string, prm Prm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
props, err := aperequest.FormFrostfsIDRequestProperties(c.frostFSIDClient, pk)
|
props, err := aperequest.FormFrostfsIDRequestProperties(ctx, c.frostFSIDClient, pk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return reqProps, err
|
return reqProps, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package target
|
package target
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
@ -13,20 +14,20 @@ import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/user"
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/user"
|
||||||
)
|
)
|
||||||
|
|
||||||
func New(prm objectwriter.Params) (transformer.ChunkedObjectWriter, error) {
|
func New(ctx context.Context, prm objectwriter.Params) (transformer.ChunkedObjectWriter, error) {
|
||||||
// prepare needed put parameters
|
// prepare needed put parameters
|
||||||
if err := preparePrm(&prm); err != nil {
|
if err := preparePrm(ctx, &prm); err != nil {
|
||||||
return nil, fmt.Errorf("could not prepare put parameters: %w", err)
|
return nil, fmt.Errorf("could not prepare put parameters: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if prm.Header.Signature() != nil {
|
if prm.Header.Signature() != nil {
|
||||||
return newUntrustedTarget(&prm)
|
return newUntrustedTarget(ctx, &prm)
|
||||||
}
|
}
|
||||||
return newTrustedTarget(&prm)
|
return newTrustedTarget(ctx, &prm)
|
||||||
}
|
}
|
||||||
|
|
||||||
func newUntrustedTarget(prm *objectwriter.Params) (transformer.ChunkedObjectWriter, error) {
|
func newUntrustedTarget(ctx context.Context, prm *objectwriter.Params) (transformer.ChunkedObjectWriter, error) {
|
||||||
maxPayloadSz := prm.Config.MaxSizeSrc.MaxObjectSize()
|
maxPayloadSz := prm.Config.MaxSizeSrc.MaxObjectSize(ctx)
|
||||||
if maxPayloadSz == 0 {
|
if maxPayloadSz == 0 {
|
||||||
return nil, errors.New("could not obtain max object size parameter")
|
return nil, errors.New("could not obtain max object size parameter")
|
||||||
}
|
}
|
||||||
|
@ -48,9 +49,9 @@ func newUntrustedTarget(prm *objectwriter.Params) (transformer.ChunkedObjectWrit
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTrustedTarget(prm *objectwriter.Params) (transformer.ChunkedObjectWriter, error) {
|
func newTrustedTarget(ctx context.Context, prm *objectwriter.Params) (transformer.ChunkedObjectWriter, error) {
|
||||||
prm.Relay = nil // do not relay request without signature
|
prm.Relay = nil // do not relay request without signature
|
||||||
maxPayloadSz := prm.Config.MaxSizeSrc.MaxObjectSize()
|
maxPayloadSz := prm.Config.MaxSizeSrc.MaxObjectSize(ctx)
|
||||||
if maxPayloadSz == 0 {
|
if maxPayloadSz == 0 {
|
||||||
return nil, errors.New("could not obtain max object size parameter")
|
return nil, errors.New("could not obtain max object size parameter")
|
||||||
}
|
}
|
||||||
|
@ -111,11 +112,11 @@ func newTrustedTarget(prm *objectwriter.Params) (transformer.ChunkedObjectWriter
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func preparePrm(prm *objectwriter.Params) error {
|
func preparePrm(ctx context.Context, prm *objectwriter.Params) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
// get latest network map
|
// get latest network map
|
||||||
nm, err := netmap.GetLatestNetworkMap(prm.Config.NetmapSource)
|
nm, err := netmap.GetLatestNetworkMap(ctx, prm.Config.NetmapSource)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not get latest network map: %w", err)
|
return fmt.Errorf("could not get latest network map: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -126,7 +127,7 @@ func preparePrm(prm *objectwriter.Params) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// get container to store the object
|
// get container to store the object
|
||||||
cnrInfo, err := prm.Config.ContainerSource.Get(idCnr)
|
cnrInfo, err := prm.Config.ContainerSource.Get(ctx, idCnr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not get container by ID: %w", err)
|
return fmt.Errorf("could not get container by ID: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ func (c *Config) NewNodeIterator(opts []placement.Option) *NodeIterator {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *NodeIterator) ForEachNode(ctx context.Context, f func(context.Context, NodeDescriptor) error) error {
|
func (n *NodeIterator) ForEachNode(ctx context.Context, f func(context.Context, NodeDescriptor) error) error {
|
||||||
traverser, err := placement.NewTraverser(n.Traversal.Opts...)
|
traverser, err := placement.NewTraverser(ctx, n.Traversal.Opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not create object placement traverser: %w", err)
|
return fmt.Errorf("could not create object placement traverser: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ func (e *ECWriter) WriteObject(ctx context.Context, obj *objectSDK.Object) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *ECWriter) relayIfNotContainerNode(ctx context.Context, obj *objectSDK.Object) (bool, bool, error) {
|
func (e *ECWriter) relayIfNotContainerNode(ctx context.Context, obj *objectSDK.Object) (bool, bool, error) {
|
||||||
currentNodeIsContainerNode, err := e.currentNodeIsContainerNode()
|
currentNodeIsContainerNode, err := e.currentNodeIsContainerNode(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, false, err
|
return false, false, err
|
||||||
}
|
}
|
||||||
|
@ -108,8 +108,8 @@ func (e *ECWriter) relayIfNotContainerNode(ctx context.Context, obj *objectSDK.O
|
||||||
return true, currentNodeIsContainerNode, nil
|
return true, currentNodeIsContainerNode, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *ECWriter) currentNodeIsContainerNode() (bool, error) {
|
func (e *ECWriter) currentNodeIsContainerNode(ctx context.Context) (bool, error) {
|
||||||
t, err := placement.NewTraverser(e.PlacementOpts...)
|
t, err := placement.NewTraverser(ctx, e.PlacementOpts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ func (e *ECWriter) currentNodeIsContainerNode() (bool, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *ECWriter) relayToContainerNode(ctx context.Context, objID oid.ID, index uint32) error {
|
func (e *ECWriter) relayToContainerNode(ctx context.Context, objID oid.ID, index uint32) error {
|
||||||
t, err := placement.NewTraverser(append(e.PlacementOpts, placement.ForObject(objID))...)
|
t, err := placement.NewTraverser(ctx, append(e.PlacementOpts, placement.ForObject(objID))...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ func (e *ECWriter) writeECPart(ctx context.Context, obj *objectSDK.Object) error
|
||||||
return e.writePartLocal(ctx, obj)
|
return e.writePartLocal(ctx, obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
t, err := placement.NewTraverser(append(e.PlacementOpts, placement.ForObject(obj.ECHeader().Parent()))...)
|
t, err := placement.NewTraverser(ctx, append(e.PlacementOpts, placement.ForObject(obj.ECHeader().Parent()))...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -217,7 +217,7 @@ func (e *ECWriter) writeRawObject(ctx context.Context, obj *objectSDK.Object) er
|
||||||
}
|
}
|
||||||
partsProcessed := make([]atomic.Bool, len(parts))
|
partsProcessed := make([]atomic.Bool, len(parts))
|
||||||
objID, _ := obj.ID()
|
objID, _ := obj.ID()
|
||||||
t, err := placement.NewTraverser(append(e.PlacementOpts, placement.ForObject(objID))...)
|
t, err := placement.NewTraverser(ctx, append(e.PlacementOpts, placement.ForObject(objID))...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ type testPlacementBuilder struct {
|
||||||
vectors [][]netmap.NodeInfo
|
vectors [][]netmap.NodeInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *testPlacementBuilder) BuildPlacement(_ cid.ID, _ *oid.ID, _ netmap.PlacementPolicy) (
|
func (p *testPlacementBuilder) BuildPlacement(ctx context.Context, _ cid.ID, _ *oid.ID, _ netmap.PlacementPolicy) (
|
||||||
[][]netmap.NodeInfo, error,
|
[][]netmap.NodeInfo, error,
|
||||||
) {
|
) {
|
||||||
arr := slices.Clone(p.vectors[0])
|
arr := slices.Clone(p.vectors[0])
|
||||||
|
|
|
@ -24,7 +24,7 @@ type MaxSizeSource interface {
|
||||||
// of physically stored object in system.
|
// of physically stored object in system.
|
||||||
//
|
//
|
||||||
// Must return 0 if value can not be obtained.
|
// Must return 0 if value can not be obtained.
|
||||||
MaxObjectSize() uint64
|
MaxObjectSize(context.Context) uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
type ClientConstructor interface {
|
type ClientConstructor interface {
|
||||||
|
@ -32,7 +32,7 @@ type ClientConstructor interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
type InnerRing interface {
|
type InnerRing interface {
|
||||||
InnerRingKeys() ([][]byte, error)
|
InnerRingKeys(ctx context.Context) ([][]byte, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type FormatValidatorConfig interface {
|
type FormatValidatorConfig interface {
|
||||||
|
|
|
@ -125,7 +125,7 @@ func (a *assemblerec) reconstructObject(ctx context.Context, writer ObjectWriter
|
||||||
|
|
||||||
func (a *assemblerec) reconstructObjectFromParts(ctx context.Context, headers bool) (*objectSDK.Object, error) {
|
func (a *assemblerec) reconstructObjectFromParts(ctx context.Context, headers bool) (*objectSDK.Object, error) {
|
||||||
objID := a.addr.Object()
|
objID := a.addr.Object()
|
||||||
trav, cnr, err := a.traverserGenerator.GenerateTraverser(a.addr.Container(), &objID, a.epoch)
|
trav, cnr, err := a.traverserGenerator.GenerateTraverser(ctx, a.addr.Container(), &objID, a.epoch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ type testClient struct {
|
||||||
|
|
||||||
type testEpochReceiver uint64
|
type testEpochReceiver uint64
|
||||||
|
|
||||||
func (e testEpochReceiver) Epoch() (uint64, error) {
|
func (e testEpochReceiver) Epoch(ctx context.Context) (uint64, error) {
|
||||||
return uint64(e), nil
|
return uint64(e), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ func newTestStorage() *testStorage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *testTraverserGenerator) GenerateTraverser(cnr cid.ID, obj *oid.ID, e uint64) (*placement.Traverser, *containerCore.Container, error) {
|
func (g *testTraverserGenerator) GenerateTraverser(ctx context.Context, cnr cid.ID, obj *oid.ID, e uint64) (*placement.Traverser, *containerCore.Container, error) {
|
||||||
opts := make([]placement.Option, 0, 4)
|
opts := make([]placement.Option, 0, 4)
|
||||||
opts = append(opts,
|
opts = append(opts,
|
||||||
placement.ForContainer(g.c),
|
placement.ForContainer(g.c),
|
||||||
|
@ -91,13 +91,13 @@ func (g *testTraverserGenerator) GenerateTraverser(cnr cid.ID, obj *oid.ID, e ui
|
||||||
opts = append(opts, placement.ForObject(*obj))
|
opts = append(opts, placement.ForObject(*obj))
|
||||||
}
|
}
|
||||||
|
|
||||||
t, err := placement.NewTraverser(opts...)
|
t, err := placement.NewTraverser(context.Background(), opts...)
|
||||||
return t, &containerCore.Container{
|
return t, &containerCore.Container{
|
||||||
Value: g.c,
|
Value: g.c,
|
||||||
}, err
|
}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *testPlacementBuilder) BuildPlacement(cnr cid.ID, obj *oid.ID, _ netmap.PlacementPolicy) ([][]netmap.NodeInfo, error) {
|
func (p *testPlacementBuilder) BuildPlacement(ctx context.Context, cnr cid.ID, obj *oid.ID, _ netmap.PlacementPolicy) ([][]netmap.NodeInfo, error) {
|
||||||
var addr oid.Address
|
var addr oid.Address
|
||||||
addr.SetContainer(cnr)
|
addr.SetContainer(cnr)
|
||||||
|
|
||||||
|
|
|
@ -28,14 +28,14 @@ type containerStorage struct {
|
||||||
cnt *container.Container
|
cnt *container.Container
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cs *containerStorage) Get(cid.ID) (*coreContainer.Container, error) {
|
func (cs *containerStorage) Get(context.Context, cid.ID) (*coreContainer.Container, error) {
|
||||||
coreCnt := coreContainer.Container{
|
coreCnt := coreContainer.Container{
|
||||||
Value: *cs.cnt,
|
Value: *cs.cnt,
|
||||||
}
|
}
|
||||||
return &coreCnt, nil
|
return &coreCnt, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cs *containerStorage) DeletionInfo(cid.ID) (*coreContainer.DelInfo, error) {
|
func (cs *containerStorage) DeletionInfo(context.Context, cid.ID) (*coreContainer.DelInfo, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ func (g *RemoteGetter) Get(ctx context.Context, prm RemoteGetPrm) (*objectSDK.Ob
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
epoch, err := g.es.Epoch()
|
epoch, err := g.es.Epoch(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,7 @@ func (r *request) initEpoch(ctx context.Context) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
e, err := r.epochSource.Epoch()
|
e, err := r.epochSource.Epoch(ctx)
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
default:
|
default:
|
||||||
|
@ -141,7 +141,7 @@ func (r *request) initEpoch(ctx context.Context) bool {
|
||||||
func (r *request) generateTraverser(ctx context.Context, addr oid.Address) (*placement.Traverser, bool) {
|
func (r *request) generateTraverser(ctx context.Context, addr oid.Address) (*placement.Traverser, bool) {
|
||||||
obj := addr.Object()
|
obj := addr.Object()
|
||||||
|
|
||||||
t, _, err := r.traverserGenerator.GenerateTraverser(addr.Container(), &obj, r.curProcEpoch)
|
t, _, err := r.traverserGenerator.GenerateTraverser(ctx, addr.Container(), &obj, r.curProcEpoch)
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -20,11 +20,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type epochSource interface {
|
type epochSource interface {
|
||||||
Epoch() (uint64, error)
|
Epoch(ctx context.Context) (uint64, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type traverserGenerator interface {
|
type traverserGenerator interface {
|
||||||
GenerateTraverser(cid.ID, *oid.ID, uint64) (*placement.Traverser, *container.Container, error)
|
GenerateTraverser(context.Context, cid.ID, *oid.ID, uint64) (*placement.Traverser, *container.Container, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type keyStorage interface {
|
type keyStorage interface {
|
||||||
|
|
|
@ -22,7 +22,7 @@ import (
|
||||||
|
|
||||||
// GetRangeHash calls internal service and returns v2 response.
|
// GetRangeHash calls internal service and returns v2 response.
|
||||||
func (s *Service) GetRangeHash(ctx context.Context, req *objectV2.GetRangeHashRequest) (*objectV2.GetRangeHashResponse, error) {
|
func (s *Service) GetRangeHash(ctx context.Context, req *objectV2.GetRangeHashRequest) (*objectV2.GetRangeHashResponse, error) {
|
||||||
forward, err := s.needToForwardGetRangeHashRequest(req)
|
forward, err := s.needToForwardGetRangeHashRequest(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ type getRangeForwardParams struct {
|
||||||
address oid.Address
|
address oid.Address
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) needToForwardGetRangeHashRequest(req *objectV2.GetRangeHashRequest) (getRangeForwardParams, error) {
|
func (s *Service) needToForwardGetRangeHashRequest(ctx context.Context, req *objectV2.GetRangeHashRequest) (getRangeForwardParams, error) {
|
||||||
if req.GetMetaHeader().GetTTL() <= 1 {
|
if req.GetMetaHeader().GetTTL() <= 1 {
|
||||||
return getRangeForwardParams{}, nil
|
return getRangeForwardParams{}, nil
|
||||||
}
|
}
|
||||||
|
@ -66,17 +66,17 @@ func (s *Service) needToForwardGetRangeHashRequest(req *objectV2.GetRangeHashReq
|
||||||
}
|
}
|
||||||
result.address = addr
|
result.address = addr
|
||||||
|
|
||||||
cont, err := s.contSource.Get(addr.Container())
|
cont, err := s.contSource.Get(ctx, addr.Container())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return result, fmt.Errorf("(%T) could not get container: %w", s, err)
|
return result, fmt.Errorf("(%T) could not get container: %w", s, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
epoch, err := s.netmapSource.Epoch()
|
epoch, err := s.netmapSource.Epoch(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return result, fmt.Errorf("(%T) could not get epoch: %w", s, err)
|
return result, fmt.Errorf("(%T) could not get epoch: %w", s, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
nm, err := s.netmapSource.GetNetMapByEpoch(epoch)
|
nm, err := s.netmapSource.GetNetMapByEpoch(ctx, epoch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return result, fmt.Errorf("(%T) could not get netmap: %w", s, err)
|
return result, fmt.Errorf("(%T) could not get netmap: %w", s, err)
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ func (s *Service) needToForwardGetRangeHashRequest(req *objectV2.GetRangeHashReq
|
||||||
builder := placement.NewNetworkMapBuilder(nm)
|
builder := placement.NewNetworkMapBuilder(nm)
|
||||||
|
|
||||||
objectID := addr.Object()
|
objectID := addr.Object()
|
||||||
nodesVector, err := builder.BuildPlacement(addr.Container(), &objectID, cont.Value.PlacementPolicy())
|
nodesVector, err := builder.BuildPlacement(ctx, addr.Container(), &objectID, cont.Value.PlacementPolicy())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return result, fmt.Errorf("(%T) could not build object placement: %w", s, err)
|
return result, fmt.Errorf("(%T) could not build object placement: %w", s, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ func (s *Streamer) init(ctx context.Context, req *objectV2.PatchRequest) error {
|
||||||
}
|
}
|
||||||
oV2.GetHeader().SetOwnerID(ownerID)
|
oV2.GetHeader().SetOwnerID(ownerID)
|
||||||
|
|
||||||
target, err := target.New(objectwriter.Params{
|
target, err := target.New(ctx, objectwriter.Params{
|
||||||
Config: s.Config,
|
Config: s.Config,
|
||||||
Common: commonPrm,
|
Common: commonPrm,
|
||||||
Header: objectSDK.NewFromV2(oV2),
|
Header: objectSDK.NewFromV2(oV2),
|
||||||
|
|
|
@ -86,7 +86,7 @@ func (s *Service) PutSingle(ctx context.Context, req *objectAPI.PutSingleRequest
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) validatePutSingle(ctx context.Context, obj *objectSDK.Object) (object.ContentMeta, error) {
|
func (s *Service) validatePutSingle(ctx context.Context, obj *objectSDK.Object) (object.ContentMeta, error) {
|
||||||
if err := s.validarePutSingleSize(obj); err != nil {
|
if err := s.validarePutSingleSize(ctx, obj); err != nil {
|
||||||
return object.ContentMeta{}, err
|
return object.ContentMeta{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,12 +97,12 @@ func (s *Service) validatePutSingle(ctx context.Context, obj *objectSDK.Object)
|
||||||
return s.validatePutSingleObject(ctx, obj)
|
return s.validatePutSingleObject(ctx, obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) validarePutSingleSize(obj *objectSDK.Object) error {
|
func (s *Service) validarePutSingleSize(ctx context.Context, obj *objectSDK.Object) error {
|
||||||
if uint64(len(obj.Payload())) != obj.PayloadSize() {
|
if uint64(len(obj.Payload())) != obj.PayloadSize() {
|
||||||
return target.ErrWrongPayloadSize
|
return target.ErrWrongPayloadSize
|
||||||
}
|
}
|
||||||
|
|
||||||
maxAllowedSize := s.Config.MaxSizeSrc.MaxObjectSize()
|
maxAllowedSize := s.Config.MaxSizeSrc.MaxObjectSize(ctx)
|
||||||
if obj.PayloadSize() > maxAllowedSize {
|
if obj.PayloadSize() > maxAllowedSize {
|
||||||
return target.ErrExceedingMaxSize
|
return target.ErrExceedingMaxSize
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,7 @@ func (s *Service) validatePutSingleObject(ctx context.Context, obj *objectSDK.Ob
|
||||||
|
|
||||||
func (s *Service) saveToNodes(ctx context.Context, obj *objectSDK.Object, req *objectAPI.PutSingleRequest, meta object.ContentMeta) error {
|
func (s *Service) saveToNodes(ctx context.Context, obj *objectSDK.Object, req *objectAPI.PutSingleRequest, meta object.ContentMeta) error {
|
||||||
localOnly := req.GetMetaHeader().GetTTL() <= 1
|
localOnly := req.GetMetaHeader().GetTTL() <= 1
|
||||||
placement, err := s.getPutSinglePlacementOptions(obj, req.GetBody().GetCopiesNumber(), localOnly)
|
placement, err := s.getPutSinglePlacementOptions(ctx, obj, req.GetBody().GetCopiesNumber(), localOnly)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -218,14 +218,14 @@ type putSinglePlacement struct {
|
||||||
resetSuccessAfterOnBroadcast bool
|
resetSuccessAfterOnBroadcast bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) getPutSinglePlacementOptions(obj *objectSDK.Object, copiesNumber []uint32, localOnly bool) (putSinglePlacement, error) {
|
func (s *Service) getPutSinglePlacementOptions(ctx context.Context, obj *objectSDK.Object, copiesNumber []uint32, localOnly bool) (putSinglePlacement, error) {
|
||||||
var result putSinglePlacement
|
var result putSinglePlacement
|
||||||
|
|
||||||
cnrID, ok := obj.ContainerID()
|
cnrID, ok := obj.ContainerID()
|
||||||
if !ok {
|
if !ok {
|
||||||
return result, errors.New("missing container ID")
|
return result, errors.New("missing container ID")
|
||||||
}
|
}
|
||||||
cnrInfo, err := s.Config.ContainerSource.Get(cnrID)
|
cnrInfo, err := s.Config.ContainerSource.Get(ctx, cnrID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return result, fmt.Errorf("could not get container by ID: %w", err)
|
return result, fmt.Errorf("could not get container by ID: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -249,7 +249,7 @@ func (s *Service) getPutSinglePlacementOptions(obj *objectSDK.Object, copiesNumb
|
||||||
}
|
}
|
||||||
result.placementOptions = append(result.placementOptions, placement.ForObject(objID))
|
result.placementOptions = append(result.placementOptions, placement.ForObject(objID))
|
||||||
|
|
||||||
latestNetmap, err := netmap.GetLatestNetworkMap(s.Config.NetmapSource)
|
latestNetmap, err := netmap.GetLatestNetworkMap(ctx, s.Config.NetmapSource)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return result, fmt.Errorf("could not get latest network map: %w", err)
|
return result, fmt.Errorf("could not get latest network map: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ func (p *Streamer) Init(ctx context.Context, prm *PutInitPrm) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
p.target, err = target.New(prmTarget)
|
p.target, err = target.New(ctx, prmTarget)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("(%T) could not initialize object target: %w", p, err)
|
return fmt.Errorf("(%T) could not initialize object target: %w", p, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ func (s *streamer) Send(ctx context.Context, req *object.PutRequest) (err error)
|
||||||
|
|
||||||
s.saveChunks = v.GetSignature() != nil
|
s.saveChunks = v.GetSignature() != nil
|
||||||
if s.saveChunks {
|
if s.saveChunks {
|
||||||
maxSz := s.stream.MaxSizeSrc.MaxObjectSize()
|
maxSz := s.stream.MaxSizeSrc.MaxObjectSize(ctx)
|
||||||
|
|
||||||
s.sizes = &sizes{
|
s.sizes = &sizes{
|
||||||
payloadSz: v.GetHeader().GetPayloadLength(),
|
payloadSz: v.GetHeader().GetPayloadLength(),
|
||||||
|
|
|
@ -20,7 +20,7 @@ func (exec *execCtx) executeOnContainer(ctx context.Context) error {
|
||||||
)
|
)
|
||||||
|
|
||||||
// initialize epoch number
|
// initialize epoch number
|
||||||
if err := exec.initEpoch(); err != nil {
|
if err := exec.initEpoch(ctx); err != nil {
|
||||||
return fmt.Errorf("%s: %w", logs.CouldNotGetCurrentEpochNumber, err)
|
return fmt.Errorf("%s: %w", logs.CouldNotGetCurrentEpochNumber, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ func (exec *execCtx) processCurrentEpoch(ctx context.Context) error {
|
||||||
zap.Uint64("number", exec.curProcEpoch),
|
zap.Uint64("number", exec.curProcEpoch),
|
||||||
)
|
)
|
||||||
|
|
||||||
traverser, _, err := exec.svc.traverserGenerator.GenerateTraverser(exec.containerID(), nil, exec.curProcEpoch)
|
traverser, _, err := exec.svc.traverserGenerator.GenerateTraverser(ctx, exec.containerID(), nil, exec.curProcEpoch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", logs.SearchCouldNotGenerateContainerTraverser, err)
|
return fmt.Errorf("%s: %w", logs.SearchCouldNotGenerateContainerTraverser, err)
|
||||||
}
|
}
|
||||||
|
@ -114,9 +114,9 @@ func (exec *execCtx) processCurrentEpoch(ctx context.Context) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (exec *execCtx) getContainer() (containerSDK.Container, error) {
|
func (exec *execCtx) getContainer(ctx context.Context) (containerSDK.Container, error) {
|
||||||
cnrID := exec.containerID()
|
cnrID := exec.containerID()
|
||||||
cnr, err := exec.svc.containerSource.Get(cnrID)
|
cnr, err := exec.svc.containerSource.Get(ctx, cnrID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return containerSDK.Container{}, err
|
return containerSDK.Container{}, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package searchsvc
|
package searchsvc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
|
||||||
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
|
@ -48,13 +50,13 @@ func (exec *execCtx) netmapLookupDepth() uint64 {
|
||||||
return exec.prm.common.NetmapLookupDepth()
|
return exec.prm.common.NetmapLookupDepth()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (exec *execCtx) initEpoch() error {
|
func (exec *execCtx) initEpoch(ctx context.Context) error {
|
||||||
exec.curProcEpoch = exec.netmapEpoch()
|
exec.curProcEpoch = exec.netmapEpoch()
|
||||||
if exec.curProcEpoch > 0 {
|
if exec.curProcEpoch > 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
e, err := exec.svc.currentEpochReceiver.Epoch()
|
e, err := exec.svc.currentEpochReceiver.Epoch(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue