Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return the composite error of PUT operation #813

Merged
merged 2 commits into from
Sep 10, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pkg/services/object/put/distributed.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"sync"
"sync/atomic"

"github.com/nspcc-dev/neofs-node/pkg/core/object"
svcutil "github.com/nspcc-dev/neofs-node/pkg/services/object/util"
Expand Down Expand Up @@ -93,6 +94,8 @@ func (t *distributedTarget) iteratePlacement(f func(placement.Node) error) (*tra
return nil, fmt.Errorf("(%T) could not create object placement traverser: %w", t, err)
}

var resErr atomic.Value

loop:
for {
addrs := traverser.Next()
Expand All @@ -110,6 +113,7 @@ loop:
defer wg.Done()

if err := f(addr); err != nil {
resErr.Store(err)
svcutil.LogServiceError(t.log, "PUT", addr.Addresses(), err)
return
}
Expand All @@ -128,6 +132,10 @@ loop:
}

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

return nil, errIncompletePut
}

Expand Down