From dde4d4df2ac58f7180f149ce38235a0e25b6329c Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Tue, 11 Oct 2022 14:08:43 +0400 Subject: [PATCH] [#1878] services/object: Fix child check in GET In previous implementation `ObjectService.Get` RPC handler failed with `parent address in child object differs` while assembling the "big" object. This was caused by the child check which required parent reference to be set in all child objects. The check was impracticable because not all elements of the split-chain have a link to the parent. Make `execCtx.isChild` to return `true` if parameterized object has no parent header in its own header. Signed-off-by: Leonard Lyubich --- CHANGELOG.md | 1 + pkg/services/object/get/exec.go | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6932f670..f35f41d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ Changelog for NeoFS Node - Do not increase error counter in `engine.Inhume` if shard is read-only (#1839) - `control drop-objects` can remove split objects (#1830) - Node's status in `neofs-cli netmap nodeinfo` command (#1833) +- Child check in object assembly process of `ObjectService.Get` handler (#1878) ### Removed - Remove WIF and NEP2 support in `neofs-cli`'s --wallet flag (#1128) diff --git a/pkg/services/object/get/exec.go b/pkg/services/object/get/exec.go index 11365dce..bbb901ad 100644 --- a/pkg/services/object/get/exec.go +++ b/pkg/services/object/get/exec.go @@ -99,9 +99,13 @@ func (exec execCtx) address() oid.Address { return exec.prm.addr } +// isChild checks if reading object is a parent of the given object. +// Object without reference to the parent (only children with the parent header +// have it) is automatically considered as child: this should be guaranteed by +// upper level logic. func (exec execCtx) isChild(obj *objectSDK.Object) bool { par := obj.Parent() - return par != nil && equalAddresses(exec.address(), object.AddressOf(par)) + return par == nil || equalAddresses(exec.address(), object.AddressOf(par)) } func (exec execCtx) key() (*ecdsa.PrivateKey, error) { @@ -244,7 +248,7 @@ func (exec *execCtx) headChild(id oid.ID) (*objectSDK.Object, bool) { case err == nil: child := w.Object() - if _, ok := child.ParentID(); ok && !exec.isChild(child) { + if !exec.isChild(child) { exec.status = statusUndefined exec.log.Debug("parent address in child object differs")