[#465] object: Set xHeader __SYSTEM__NETMAP_EPOCH

Affects requests `GET`, `RANGE`, `HEAD`.

Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
Anton Nikiforov 2024-07-02 11:06:15 +03:00
parent 36eab4059c
commit 50aed4e9eb
2 changed files with 15 additions and 5 deletions

View file

@ -138,12 +138,12 @@ func (s *multiaddressRemoteStorage) Range(ctx context.Context, address oid.Addre
prm.SetClient(s.client) prm.SetClient(s.client)
prm.SetTTL(requestParams.TTL) prm.SetTTL(requestParams.TTL)
prm.SetXHeaders(requestParams.XHeaders)
prm.SetNetmapEpoch(requestParams.Epoch) prm.SetNetmapEpoch(requestParams.Epoch)
prm.SetAddress(address) prm.SetAddress(address)
prm.SetPrivateKey(requestParams.PrivateKey) prm.SetPrivateKey(requestParams.PrivateKey)
prm.SetSessionToken(requestParams.SessionToken) prm.SetSessionToken(requestParams.SessionToken)
prm.SetBearerToken(requestParams.BearerToken) prm.SetBearerToken(requestParams.BearerToken)
prm.SetXHeaders(requestParams.XHeaders)
prm.SetRange(rng) prm.SetRange(rng)
if requestParams.IsRaw { if requestParams.IsRaw {
prm.SetRawFlag() prm.SetRawFlag()
@ -179,12 +179,12 @@ func (s *multiaddressRemoteStorage) Head(ctx context.Context, address oid.Addres
prm.SetClient(s.client) prm.SetClient(s.client)
prm.SetTTL(requestParams.TTL) prm.SetTTL(requestParams.TTL)
prm.SetXHeaders(requestParams.XHeaders)
prm.SetNetmapEpoch(requestParams.Epoch) prm.SetNetmapEpoch(requestParams.Epoch)
prm.SetAddress(address) prm.SetAddress(address)
prm.SetPrivateKey(requestParams.PrivateKey) prm.SetPrivateKey(requestParams.PrivateKey)
prm.SetSessionToken(requestParams.SessionToken) prm.SetSessionToken(requestParams.SessionToken)
prm.SetBearerToken(requestParams.BearerToken) prm.SetBearerToken(requestParams.BearerToken)
prm.SetXHeaders(requestParams.XHeaders)
if requestParams.IsRaw { if requestParams.IsRaw {
prm.SetRawFlag() prm.SetRawFlag()
@ -203,12 +203,12 @@ func (s *multiaddressRemoteStorage) Get(ctx context.Context, address oid.Address
prm.SetClient(s.client) prm.SetClient(s.client)
prm.SetTTL(requestParams.TTL) prm.SetTTL(requestParams.TTL)
prm.SetXHeaders(requestParams.XHeaders)
prm.SetNetmapEpoch(requestParams.Epoch) prm.SetNetmapEpoch(requestParams.Epoch)
prm.SetAddress(address) prm.SetAddress(address)
prm.SetPrivateKey(requestParams.PrivateKey) prm.SetPrivateKey(requestParams.PrivateKey)
prm.SetSessionToken(requestParams.SessionToken) prm.SetSessionToken(requestParams.SessionToken)
prm.SetBearerToken(requestParams.BearerToken) prm.SetBearerToken(requestParams.BearerToken)
prm.SetXHeaders(requestParams.XHeaders)
if requestParams.IsRaw { if requestParams.IsRaw {
prm.SetRawFlag() prm.SetRawFlag()

View file

@ -7,7 +7,9 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"strconv"
apiSession "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/session"
coreclient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/client" coreclient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/client"
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing" "git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/bearer" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/bearer"
@ -80,8 +82,16 @@ type readPrmCommon struct {
// SetNetmapEpoch sets the epoch number to be used to locate the objectSDK. // SetNetmapEpoch sets the epoch number to be used to locate the objectSDK.
// //
// By default current epoch on the server will be used. // By default current epoch on the server will be used.
func (x *readPrmCommon) SetNetmapEpoch(_ uint64) { func (x *readPrmCommon) SetNetmapEpoch(epoch uint64) {
// FIXME(@fyrchik): https://git.frostfs.info/TrueCloudLab/frostfs-node/issues/465 e := strconv.FormatUint(epoch, 10)
for i := 0; i < len(x.xHeaders); i = i + 2 {
if x.xHeaders[i] == apiSession.XHeaderNetmapEpoch {
x.xHeaders[i+1] = strconv.FormatUint(epoch, 10)
return
}
}
x.xHeaders = append(x.xHeaders, apiSession.XHeaderNetmapEpoch, e)
} }
// GetObjectPrm groups parameters of GetObject operation. // GetObjectPrm groups parameters of GetObject operation.