[#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 <ctulhurider@gmail.com>
support/v0.34
Leonard Lyubich 2022-10-11 14:08:43 +04:00 committed by fyrchik
parent 9a006ac14f
commit dde4d4df2a
2 changed files with 7 additions and 2 deletions

View File

@ -38,6 +38,7 @@ Changelog for NeoFS Node
- Do not increase error counter in `engine.Inhume` if shard is read-only (#1839) - Do not increase error counter in `engine.Inhume` if shard is read-only (#1839)
- `control drop-objects` can remove split objects (#1830) - `control drop-objects` can remove split objects (#1830)
- Node's status in `neofs-cli netmap nodeinfo` command (#1833) - Node's status in `neofs-cli netmap nodeinfo` command (#1833)
- Child check in object assembly process of `ObjectService.Get` handler (#1878)
### Removed ### Removed
- Remove WIF and NEP2 support in `neofs-cli`'s --wallet flag (#1128) - Remove WIF and NEP2 support in `neofs-cli`'s --wallet flag (#1128)

View File

@ -99,9 +99,13 @@ func (exec execCtx) address() oid.Address {
return exec.prm.addr 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 { func (exec execCtx) isChild(obj *objectSDK.Object) bool {
par := obj.Parent() 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) { func (exec execCtx) key() (*ecdsa.PrivateKey, error) {
@ -244,7 +248,7 @@ func (exec *execCtx) headChild(id oid.ID) (*objectSDK.Object, bool) {
case err == nil: case err == nil:
child := w.Object() child := w.Object()
if _, ok := child.ParentID(); ok && !exec.isChild(child) { if !exec.isChild(child) {
exec.status = statusUndefined exec.status = statusUndefined
exec.log.Debug("parent address in child object differs") exec.log.Debug("parent address in child object differs")