Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pool: Drop opening no-op sessions #623

Merged
merged 3 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions eacl/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,7 @@ func (t Table) ToV2() *v2acl.Table {
// Defaults:
// - version: version.Current();
// - container ID: nil;
// - records: nil;
// - session token: nil;
// - signature: nil.
// - records: nil.
//
// Deprecated: use [ConstructTable] instead.
func NewTable() *Table {
Expand Down
2 changes: 1 addition & 1 deletion netmap/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func (p *PlacementPolicy) ReadFromV2(m netmap.PlacementPolicy) error {
return p.readFromV2(m, true)
}

// WriteToV2 writes PlacementPolicy to the session.Token message.
// WriteToV2 writes PlacementPolicy to the netmap.PlacementPolicy message.
// The message must not be nil.
//
// See also ReadFromV2.
Expand Down
8 changes: 6 additions & 2 deletions pool/mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type mockClient struct {
errorOnEndpointInfo bool
errorOnNetworkInfo bool
errOnGetObject error
errOnPutObject error
}

func (m *mockClient) Dial(_ client.PrmDial) error {
Expand Down Expand Up @@ -116,8 +117,7 @@ func (m *mockClient) NetMapSnapshot(_ context.Context, _ client.PrmNetMapSnapsho
}

func (m *mockClient) ObjectPutInit(_ context.Context, _ object.Object, _ user.Signer, _ client.PrmObjectPutInit) (client.ObjectWriter, error) {
// TODO implement me
panic("implement me")
return nil, m.errOnPutObject
}

func (m *mockClient) ObjectGetInit(_ context.Context, _ cid.ID, _ oid.ID, _ user.Signer, _ client.PrmObjectGet) (object.Object, *client.PayloadReader, error) {
Expand Down Expand Up @@ -214,6 +214,10 @@ func (m *mockClient) statusOnGetObject(err error) {
m.errOnGetObject = err
}

func (m *mockClient) statusOnPutObject(err error) {
m.errOnPutObject = err
}

func (m *mockClient) dial(context.Context) error {
if m.errorOnDial {
return errors.New("dial error")
Expand Down
83 changes: 6 additions & 77 deletions pool/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,26 +65,11 @@
//
// See details in [client.Client.ObjectGetInit].
func (p *Pool) ObjectGetInit(ctx context.Context, containerID cid.ID, objectID oid.ID, signer user.Signer, prm client.PrmObjectGet) (object.Object, *client.PayloadReader, error) {
var hdr object.Object
c, err := p.sdkClient()
if err != nil {
return hdr, nil, err
return object.Object{}, nil, err

Check warning on line 70 in pool/object.go

View check run for this annotation

Codecov / codecov/patch

pool/object.go#L70

Added line #L70 was not covered by tests
}
if err = p.withinContainerSession(
ctx,
c,
containerID,
p.actualSigner(signer),
session.VerbObjectGet,
&prm,
); err != nil {
return hdr, nil, fmt.Errorf("session: %w", err)
}

hdr, payloadReader, err := c.ObjectGetInit(ctx, containerID, objectID, signer, prm)
p.checkSessionTokenErr(err, c.addr, c.nodeSession)

return hdr, payloadReader, err
return c.ObjectGetInit(ctx, containerID, objectID, signer, prm)
}

// ObjectHead reads object header through a remote server using NeoFS API protocol.
Expand All @@ -97,21 +82,7 @@
if err != nil {
return nil, err
}
if err = p.withinContainerSession(
ctx,
c,
containerID,
p.actualSigner(signer),
session.VerbObjectHead,
&prm,
); err != nil {
return nil, fmt.Errorf("session: %w", err)
}

hdr, err := c.ObjectHead(ctx, containerID, objectID, signer, prm)
p.checkSessionTokenErr(err, c.addr, c.nodeSession)

return hdr, err
return c.ObjectHead(ctx, containerID, objectID, signer, prm)
}

// ObjectRangeInit initiates reading an object's payload range through a remote
Expand All @@ -124,21 +95,7 @@
if err != nil {
return nil, err
}
if err = p.withinContainerSession(
ctx,
c,
containerID,
p.actualSigner(signer),
session.VerbObjectRange,
&prm,
); err != nil {
return nil, fmt.Errorf("session: %w", err)
}

reader, err := c.ObjectRangeInit(ctx, containerID, objectID, offset, length, signer, prm)
p.checkSessionTokenErr(err, c.addr, c.nodeSession)

return reader, err
return c.ObjectRangeInit(ctx, containerID, objectID, offset, length, signer, prm)
}

// ObjectDelete marks an object for deletion from the container using NeoFS API protocol.
Expand Down Expand Up @@ -178,21 +135,7 @@
if err != nil {
return [][]byte{}, err
}
if err = p.withinContainerSession(
ctx,
c,
containerID,
p.actualSigner(signer),
session.VerbObjectRangeHash,
&prm,
); err != nil {
return [][]byte{}, fmt.Errorf("session: %w", err)
}

data, err := c.ObjectHash(ctx, containerID, objectID, signer, prm)
p.checkSessionTokenErr(err, c.addr, c.nodeSession)

return data, err
return c.ObjectHash(ctx, containerID, objectID, signer, prm)
}

// ObjectSearchInit initiates object selection through a remote server using NeoFS API protocol.
Expand All @@ -205,19 +148,5 @@
if err != nil {
return nil, err
}
if err = p.withinContainerSession(
ctx,
c,
containerID,
p.actualSigner(signer),
session.VerbObjectSearch,
&prm,
); err != nil {
return nil, fmt.Errorf("session: %w", err)
}

reader, err := c.ObjectSearchInit(ctx, containerID, signer, prm)
p.checkSessionTokenErr(err, c.addr, c.nodeSession)

return reader, err
return c.ObjectSearchInit(ctx, containerID, signer, prm)
}
Loading
Loading