From 9a6da336db287a4271320b4acac9d7b8ece004ea Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Wed, 6 Jul 2022 00:09:30 +0300 Subject: [PATCH] [#1581] node: Do not lose API version on forwarding Forwarded requests contained zero version in their meta header. It did not allow responding with API statuses (`v0.0` version considered to be older than `v2.11`) to the forwarding node and, therefore, did not allow analyzing responses. Signed-off-by: Pavel Karpy --- CHANGELOG.md | 1 + pkg/services/object/get/v2/util.go | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 472508f77..a6f096214 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ Changelog for NeoFS Node - Do not replicate object twice to the same node (#1410) - Concurrent object handling by the Policer (#1411) +- Attaching API version to the forwarded requests (#1581) ### Removed diff --git a/pkg/services/object/get/v2/util.go b/pkg/services/object/get/v2/util.go index 332937e05..55933b67c 100644 --- a/pkg/services/object/get/v2/util.go +++ b/pkg/services/object/get/v2/util.go @@ -24,6 +24,7 @@ import ( neofscrypto "github.com/nspcc-dev/neofs-sdk-go/crypto" "github.com/nspcc-dev/neofs-sdk-go/object" oid "github.com/nspcc-dev/neofs-sdk-go/object/id" + versionSDK "github.com/nspcc-dev/neofs-sdk-go/version" "github.com/nspcc-dev/tzhash/tz" ) @@ -76,6 +77,7 @@ func (s *Service) toPrm(req *objectV2.GetRequest, stream objectSvc.GetObjectStre metaHdr.SetTTL(meta.GetTTL() - 1) // TODO: #1165 think how to set the other fields metaHdr.SetOrigin(meta) + writeCurrentVersion(metaHdr) req.SetMetaHeader(metaHdr) @@ -218,6 +220,7 @@ func (s *Service) toRangePrm(req *objectV2.GetRangeRequest, stream objectSvc.Get metaHdr.SetTTL(meta.GetTTL() - 1) // TODO: #1165 think how to set the other fields metaHdr.SetOrigin(meta) + writeCurrentVersion(metaHdr) req.SetMetaHeader(metaHdr) @@ -405,6 +408,7 @@ func (s *Service) toHeadPrm(ctx context.Context, req *objectV2.HeadRequest, resp metaHdr.SetTTL(meta.GetTTL() - 1) // TODO: #1165 think how to set the other fields metaHdr.SetOrigin(meta) + writeCurrentVersion(metaHdr) req.SetMetaHeader(metaHdr) @@ -608,3 +612,12 @@ func groupAddressRequestForwarder(f func(network.Address, client.MultiAddressCli return res, firstErr } } + +func writeCurrentVersion(metaHdr *session.RequestMetaHeader) { + versionV2 := new(refs.Version) + + apiVersion := versionSDK.Current() + apiVersion.WriteToV2(versionV2) + + metaHdr.SetVersion(versionV2) +}