From 61b4baf73613a1860de513e6567fc4045e1ca209 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Fri, 10 Sep 2021 16:39:50 +0300 Subject: [PATCH] [#778] services/object: Wrap last client's error into errIncompletePut Make `errIncompletePut` to be a structure which wraps single client error. Wrap error of the last client into `errIncompletePut` during placement execution. Signed-off-by: Leonard Lyubich --- pkg/services/object/put/distributed.go | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/pkg/services/object/put/distributed.go b/pkg/services/object/put/distributed.go index 20abae0c1d..45dd1a659c 100644 --- a/pkg/services/object/put/distributed.go +++ b/pkg/services/object/put/distributed.go @@ -32,7 +32,20 @@ type distributedTarget struct { log *logger.Logger } -var errIncompletePut = errors.New("incomplete object put") +// errIncompletePut is returned if processing on a container fails. +type errIncompletePut struct { + singleErr error // error from the last responding node +} + +func (x errIncompletePut) Error() string { + const commonMsg = "incomplete object PUT by placement" + + if x.singleErr != nil { + return fmt.Sprintf("%s: %v", commonMsg, x.singleErr) + } + + return commonMsg +} func (t *distributedTarget) WriteHeader(obj *object.RawObject) error { t.obj = obj @@ -132,11 +145,11 @@ loop: } if !traverser.Success() { - if err, ok := resErr.Load().(error); ok { - return nil, err - } + var err errIncompletePut - return nil, errIncompletePut + err.singleErr, _ = resErr.Load().(error) + + return nil, err } return new(transformer.AccessIdentifiers).