Skip to content

Commit

Permalink
[nspcc-dev#778] services/object: Wrap last client's error into errInc…
Browse files Browse the repository at this point in the history
…ompletePut

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 <leonard@nspcc.ru>
  • Loading branch information
Leonard Lyubich committed Sep 10, 2021
1 parent b920101 commit 00fd947
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions pkg/services/object/put/distributed.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -132,11 +145,11 @@ loop:
}

if !traverser.Success() {
if err, ok := resErr.Load().(error); ok {
return nil, err
}
var err errIncompletePut

err.singleErr, _ = resErr.Load().(error)

return nil, errIncompletePut
return nil, err
}

return new(transformer.AccessIdentifiers).
Expand Down

0 comments on commit 00fd947

Please sign in to comment.