Skip to content

Commit

Permalink
pool: Do not open no-op sessions with storage nodes
Browse files Browse the repository at this point in the history
Currently, there are only two NeoFS operations supporting sessions:
object creation (PUT) and removal (DELETE). The latter is essentially
creation of the tombstone object. Sessions are used in cases when
client requests trusted storage node to form an object and sign it via
so-called private session key. Public part of this key is signed by
original client in the attached session token.

This makes no sense for any other op because server does nothing on
behalf of the client, it just executes his request.

Previously, pool of NeoFS clients could open session for any object op
incl. reading ones. As said, this broke nothing, but was completely
redundant.

This drops session opening for any op except PUT/DELETE to increase
pool's efficiency and relieve network pressure.

Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
  • Loading branch information
cthulhu-rider committed Sep 16, 2024
1 parent 5cdc80d commit 543ebdc
Show file tree
Hide file tree
Showing 2 changed files with 561 additions and 77 deletions.
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 @@ func (p *Pool) ObjectPutInit(ctx context.Context, hdr object.Object, signer user
//
// 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
}
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 @@ func (p *Pool) ObjectHead(ctx context.Context, containerID cid.ID, objectID oid.
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 @@ func (p *Pool) ObjectRangeInit(ctx context.Context, containerID cid.ID, objectID
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 @@ func (p *Pool) ObjectHash(ctx context.Context, containerID cid.ID, objectID oid.
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 @@ func (p *Pool) ObjectSearchInit(ctx context.Context, containerID cid.ID, signer
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

0 comments on commit 543ebdc

Please sign in to comment.