Fix Patch handler bugs #1338

Merged
fyrchik merged 2 commits from aarifullin/frostfs-node:fix/patch/3 into master 2024-09-04 19:51:11 +00:00
2 changed files with 13 additions and 1 deletions

View file

@ -204,7 +204,7 @@ func (a *auditPatchStream) CloseAndRecv(ctx context.Context) (*object.PatchRespo
if err != nil { if err != nil {
a.failed = true a.failed = true
} }
a.objectID = resp.GetBody().ObjectID a.objectID = resp.GetBody().GetObjectID()
audit.LogRequestWithKey(a.log, objectGRPC.ObjectService_Patch_FullMethodName, a.key, audit.LogRequestWithKey(a.log, objectGRPC.ObjectService_Patch_FullMethodName, a.key,
audit.TargetFromContainerIDObjectID(a.containerID, a.objectID), audit.TargetFromContainerIDObjectID(a.containerID, a.objectID),
!a.failed) !a.failed)

View file

@ -30,6 +30,12 @@ type rangeProvider struct {
var _ patcherSDK.RangeProvider = (*rangeProvider)(nil) var _ patcherSDK.RangeProvider = (*rangeProvider)(nil)
func (r *rangeProvider) GetRange(ctx context.Context, rng *objectSDK.Range) io.Reader { 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() pipeReader, pipeWriter := io.Pipe()
var rngPrm getsvc.RangePrm var rngPrm getsvc.RangePrm
@ -61,3 +67,9 @@ func (r *rangeProvider) GetRange(ctx context.Context, rng *objectSDK.Range) io.R
return pipeReader return pipeReader
} }
type nopReader struct{}
func (nopReader) Read(_ []byte) (int, error) {
return 0, io.EOF
}