From 50aed4e9eb95d5681423e6404ba0ca02ba28b159 Mon Sep 17 00:00:00 2001 From: Anton Nikiforov Date: Tue, 2 Jul 2024 11:06:15 +0300 Subject: [PATCH] [#465] object: Set xHeader `__SYSTEM__NETMAP_EPOCH` Affects requests `GET`, `RANGE`, `HEAD`. Signed-off-by: Anton Nikiforov --- pkg/services/object/get/types.go | 6 +++--- pkg/services/object/internal/client/client.go | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/pkg/services/object/get/types.go b/pkg/services/object/get/types.go index a866132cc..9ac50ccd3 100644 --- a/pkg/services/object/get/types.go +++ b/pkg/services/object/get/types.go @@ -138,12 +138,12 @@ func (s *multiaddressRemoteStorage) Range(ctx context.Context, address oid.Addre prm.SetClient(s.client) prm.SetTTL(requestParams.TTL) + prm.SetXHeaders(requestParams.XHeaders) prm.SetNetmapEpoch(requestParams.Epoch) prm.SetAddress(address) prm.SetPrivateKey(requestParams.PrivateKey) prm.SetSessionToken(requestParams.SessionToken) prm.SetBearerToken(requestParams.BearerToken) - prm.SetXHeaders(requestParams.XHeaders) prm.SetRange(rng) if requestParams.IsRaw { prm.SetRawFlag() @@ -179,12 +179,12 @@ func (s *multiaddressRemoteStorage) Head(ctx context.Context, address oid.Addres prm.SetClient(s.client) prm.SetTTL(requestParams.TTL) + prm.SetXHeaders(requestParams.XHeaders) prm.SetNetmapEpoch(requestParams.Epoch) prm.SetAddress(address) prm.SetPrivateKey(requestParams.PrivateKey) prm.SetSessionToken(requestParams.SessionToken) prm.SetBearerToken(requestParams.BearerToken) - prm.SetXHeaders(requestParams.XHeaders) if requestParams.IsRaw { prm.SetRawFlag() @@ -203,12 +203,12 @@ func (s *multiaddressRemoteStorage) Get(ctx context.Context, address oid.Address prm.SetClient(s.client) prm.SetTTL(requestParams.TTL) + prm.SetXHeaders(requestParams.XHeaders) prm.SetNetmapEpoch(requestParams.Epoch) prm.SetAddress(address) prm.SetPrivateKey(requestParams.PrivateKey) prm.SetSessionToken(requestParams.SessionToken) prm.SetBearerToken(requestParams.BearerToken) - prm.SetXHeaders(requestParams.XHeaders) if requestParams.IsRaw { prm.SetRawFlag() diff --git a/pkg/services/object/internal/client/client.go b/pkg/services/object/internal/client/client.go index 2c405070d..574496169 100644 --- a/pkg/services/object/internal/client/client.go +++ b/pkg/services/object/internal/client/client.go @@ -7,7 +7,9 @@ import ( "errors" "fmt" "io" + "strconv" + apiSession "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/session" coreclient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/client" "git.frostfs.info/TrueCloudLab/frostfs-observability/tracing" "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. // // By default current epoch on the server will be used. -func (x *readPrmCommon) SetNetmapEpoch(_ uint64) { - // FIXME(@fyrchik): https://git.frostfs.info/TrueCloudLab/frostfs-node/issues/465 +func (x *readPrmCommon) SetNetmapEpoch(epoch uint64) { + 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.