From ec349e4523bc571b00234fe818adc06c22970a5d Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Fri, 19 Jul 2024 14:40:08 +0300 Subject: [PATCH] [#430] Adopt compatibility workarounds in Tree API Signed-off-by: Alex Vanin --- internal/frostfs/services/pool_wrapper.go | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/internal/frostfs/services/pool_wrapper.go b/internal/frostfs/services/pool_wrapper.go index 5dc9295..a1ee198 100644 --- a/internal/frostfs/services/pool_wrapper.go +++ b/internal/frostfs/services/pool_wrapper.go @@ -48,7 +48,13 @@ func (n GetSubTreeResponseBodyWrapper) GetNodeID() []uint64 { } func (n GetSubTreeResponseBodyWrapper) GetParentID() []uint64 { - return n.response.GetParentId() + resp := n.response.GetParentId() + if resp == nil { + // storage sends nil that should be interpreted as []uint64{0} + // due to protobuf compatibility, see 'GetSubTree' function + return []uint64{0} + } + return resp } func (n GetSubTreeResponseBodyWrapper) GetTimestamp() []uint64 { @@ -105,6 +111,13 @@ func (w *PoolWrapper) GetSubTree(ctx context.Context, bktInfo *data.BucketInfo, BearerToken: getBearer(ctx, bktInfo), Order: treepool.AscendingOrder, } + if len(rootID) == 1 && rootID[0] == 0 { + // storage node interprets 'nil' value as []uint64{0} + // gate wants to send 'nil' value instead of []uint64{0}, because + // it provides compatibility with previous tree service api where + // single uint64(0) value is dropped from signature + poolPrm.RootID = nil + } subTreeReader, err := w.p.GetSubTree(ctx, poolPrm) if err != nil { @@ -172,6 +185,13 @@ func (w *PoolWrapper) GetSubTreeStream(ctx context.Context, bktInfo *data.Bucket BearerToken: getBearer(ctx, bktInfo), Order: treepool.AscendingOrder, } + if len(rootID) == 1 && rootID[0] == 0 { + // storage node interprets 'nil' value as []uint64{0} + // gate wants to send 'nil' value instead of []uint64{0}, because + // it provides compatibility with previous tree service api where + // single uint64(0) value is dropped from signature + poolPrm.RootID = nil + } subTreeReader, err := w.p.GetSubTree(ctx, poolPrm) if err != nil {