Skip to content

Commit fcc9187

Browse files
committed
sn/object: Forward original GET/HEAD/RANGE request to container members
Previously, when proxy SN forwarded read object requests to the container, it updated the request as follows: 1. meta header was wrapped into the new one with decremented TTL; 2. verification header was wrapped into to the new one with added signatures for original parts. This resulted in the following costs: - additional calculation of two signatures on proxy SN; - more expensive request serialization, more data over the network; - more expensive request deserialization on container SN; - additional verification of two signatures on container SN. At the same time, apart from the mentioned actions, container SN did not use additional data for processing. So if a node doesn't update TTL and add signatures, then it's just reduces the resources spent without changing the behavior. This makes proxy SN to not resign object GET/HEAD/RANGE requests on forwarding. Signed-off-by: Leonard Lyubich <[email protected]>
1 parent fce19b7 commit fcc9187

File tree

2 files changed

+7
-48
lines changed

2 files changed

+7
-48
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Changelog for NeoFS Node
1111
- SN caches up to 1000 bearer token verification results until the next epoch (#3369)
1212
- SN caches up to 1000 session token verification results until the next epoch (#3369)
1313
- SN no longer wastes memory for logger in ACL and GET/HEAD/RANGE handlers (#3408, #3412)
14+
- SN no longer modifies original GET/HEAD/RANGE request when proxying it to the container (#3413)
1415

1516
### Removed
1617

pkg/services/object/server.go

Lines changed: 6 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ func (s *Server) Head(ctx context.Context, req *protoobject.HeadRequest) (*proto
602602
}
603603

604604
var resp protoobject.HeadResponse
605-
p, err := convertHeadPrm(s.signer, req, &resp)
605+
p, err := convertHeadPrm(req, &resp)
606606
if err != nil {
607607
return s.makeStatusHeadResponse(err), nil
608608
}
@@ -657,7 +657,7 @@ func (x *headResponse) WriteHeader(hdr *object.Object) error {
657657

658658
// converts original request into parameters accepted by the internal handler.
659659
// Note that the response is untouched within this call.
660-
func convertHeadPrm(signer ecdsa.PrivateKey, req *protoobject.HeadRequest, resp *protoobject.HeadResponse) (getsvc.HeadPrm, error) {
660+
func convertHeadPrm(req *protoobject.HeadRequest, resp *protoobject.HeadResponse) (getsvc.HeadPrm, error) {
661661
body := req.GetBody()
662662
ma := body.GetAddress()
663663
if ma == nil { // includes nil body
@@ -686,25 +686,11 @@ func convertHeadPrm(signer ecdsa.PrivateKey, req *protoobject.HeadRequest, resp
686686
return p, nil
687687
}
688688

689-
var onceResign sync.Once
690689
meta := req.GetMetaHeader()
691690
if meta == nil {
692691
return getsvc.HeadPrm{}, errors.New("missing meta header")
693692
}
694693
p.SetRequestForwarder(func(ctx context.Context, node client.NodeInfo, c client.MultiAddressClient) (*object.Object, error) {
695-
var err error
696-
onceResign.Do(func() {
697-
req.MetaHeader = &protosession.RequestMetaHeader{
698-
// TODO: #1165 think how to set the other fields
699-
Ttl: meta.GetTtl() - 1,
700-
Origin: meta,
701-
}
702-
req.VerifyHeader, err = neofscrypto.SignRequestWithBuffer(neofsecdsa.Signer(signer), req, nil)
703-
})
704-
if err != nil {
705-
return nil, err
706-
}
707-
708694
nodePub := node.PublicKey()
709695
var hdr *object.Object
710696
return hdr, c.ForEachGRPCConn(ctx, func(ctx context.Context, conn *grpc.ClientConn) error {
@@ -1051,7 +1037,7 @@ func (s *Server) Get(req *protoobject.GetRequest, gStream protoobject.ObjectServ
10511037
return s.sendStatusGetResponse(gStream, err)
10521038
}
10531039

1054-
p, err := convertGetPrm(s.signer, req, &getStream{
1040+
p, err := convertGetPrm(req, &getStream{
10551041
base: gStream,
10561042
srv: s,
10571043
reqInfo: reqInfo,
@@ -1069,7 +1055,7 @@ func (s *Server) Get(req *protoobject.GetRequest, gStream protoobject.ObjectServ
10691055
// converts original request into parameters accepted by the internal handler.
10701056
// Note that the stream is untouched within this call, errors are not reported
10711057
// into it.
1072-
func convertGetPrm(signer ecdsa.PrivateKey, req *protoobject.GetRequest, stream *getStream) (getsvc.Prm, error) {
1058+
func convertGetPrm(req *protoobject.GetRequest, stream *getStream) (getsvc.Prm, error) {
10731059
body := req.GetBody()
10741060
ma := body.GetAddress()
10751061
if ma == nil { // includes nil body
@@ -1095,27 +1081,13 @@ func convertGetPrm(signer ecdsa.PrivateKey, req *protoobject.GetRequest, stream
10951081
return p, nil
10961082
}
10971083

1098-
var onceResign sync.Once
10991084
var onceHdr sync.Once
11001085
var respondedPayload int
11011086
meta := req.GetMetaHeader()
11021087
if meta == nil {
11031088
return getsvc.Prm{}, errors.New("missing meta header")
11041089
}
11051090
p.SetRequestForwarder(func(ctx context.Context, node client.NodeInfo, c client.MultiAddressClient) (*object.Object, error) {
1106-
var err error
1107-
onceResign.Do(func() {
1108-
req.MetaHeader = &protosession.RequestMetaHeader{
1109-
// TODO: #1165 think how to set the other fields
1110-
Ttl: meta.GetTtl() - 1,
1111-
Origin: meta,
1112-
}
1113-
req.VerifyHeader, err = neofscrypto.SignRequestWithBuffer(neofsecdsa.Signer(signer), req, nil)
1114-
})
1115-
if err != nil {
1116-
return nil, err
1117-
}
1118-
11191091
nodePub := node.PublicKey()
11201092
return nil, c.ForEachGRPCConn(ctx, func(ctx context.Context, conn *grpc.ClientConn) error {
11211093
err := continueGetFromRemoteNode(ctx, conn, nodePub, req, stream, &onceHdr, &respondedPayload)
@@ -1291,7 +1263,7 @@ func (s *Server) GetRange(req *protoobject.GetRangeRequest, gStream protoobject.
12911263
return s.sendStatusRangeResponse(gStream, err)
12921264
}
12931265

1294-
p, err := convertRangePrm(s.signer, req, &rangeStream{
1266+
p, err := convertRangePrm(req, &rangeStream{
12951267
base: gStream,
12961268
srv: s,
12971269
reqInfo: reqInfo,
@@ -1309,7 +1281,7 @@ func (s *Server) GetRange(req *protoobject.GetRangeRequest, gStream protoobject.
13091281
// converts original request into parameters accepted by the internal handler.
13101282
// Note that the stream is untouched within this call, errors are not reported
13111283
// into it.
1312-
func convertRangePrm(signer ecdsa.PrivateKey, req *protoobject.GetRangeRequest, stream *rangeStream) (getsvc.RangePrm, error) {
1284+
func convertRangePrm(req *protoobject.GetRangeRequest, stream *rangeStream) (getsvc.RangePrm, error) {
13131285
body := req.GetBody()
13141286
ma := body.GetAddress()
13151287
if ma == nil { // includes nil body
@@ -1348,26 +1320,12 @@ func convertRangePrm(signer ecdsa.PrivateKey, req *protoobject.GetRangeRequest,
13481320
return p, nil
13491321
}
13501322

1351-
var onceResign sync.Once
13521323
var respondedPayload int
13531324
meta := req.GetMetaHeader()
13541325
if meta == nil {
13551326
return getsvc.RangePrm{}, errors.New("missing meta header")
13561327
}
13571328
p.SetRequestForwarder(func(ctx context.Context, node client.NodeInfo, c client.MultiAddressClient) (*object.Object, error) {
1358-
var err error
1359-
onceResign.Do(func() {
1360-
req.MetaHeader = &protosession.RequestMetaHeader{
1361-
// TODO: #1165 think how to set the other fields
1362-
Ttl: meta.GetTtl() - 1,
1363-
Origin: meta,
1364-
}
1365-
req.VerifyHeader, err = neofscrypto.SignRequestWithBuffer(neofsecdsa.Signer(signer), req, nil)
1366-
})
1367-
if err != nil {
1368-
return nil, err
1369-
}
1370-
13711329
nodePub := node.PublicKey()
13721330
return nil, c.ForEachGRPCConn(ctx, func(ctx context.Context, conn *grpc.ClientConn) error {
13731331
err := continueRangeFromRemoteNode(ctx, conn, nodePub, req, stream, &respondedPayload)

0 commit comments

Comments
 (0)