From 6488ddee882ddb2facd8554aa274986076de0bbc Mon Sep 17 00:00:00 2001 From: Airat Arifullin Date: Tue, 27 Aug 2024 16:09:59 +0300 Subject: [PATCH] [#1338] object: Fix range provider in `Patch` handler Signed-off-by: Airat Arifullin --- pkg/services/object/patch/range_provider.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/services/object/patch/range_provider.go b/pkg/services/object/patch/range_provider.go index 755c5bf6..cb3f7c34 100644 --- a/pkg/services/object/patch/range_provider.go +++ b/pkg/services/object/patch/range_provider.go @@ -30,6 +30,12 @@ type rangeProvider struct { var _ patcherSDK.RangeProvider = (*rangeProvider)(nil) func (r *rangeProvider) GetRange(ctx context.Context, rng *objectSDK.Range) io.Reader { + // Remote GetRange request to a container node uses an SDK-client that fails range validation + // with zero-length. However, from the patcher's point of view, such request is still valid. + if rng.GetLength() == 0 { + return &nopReader{} + } + pipeReader, pipeWriter := io.Pipe() var rngPrm getsvc.RangePrm @@ -61,3 +67,9 @@ func (r *rangeProvider) GetRange(ctx context.Context, rng *objectSDK.Range) io.R return pipeReader } + +type nopReader struct{} + +func (nopReader) Read(_ []byte) (int, error) { + return 0, io.EOF +}