From ecb1fef78cfc92573f42938cd2ae575f7f49008e Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Wed, 26 Jul 2023 14:38:43 +0300 Subject: [PATCH] [#129] client: Do not override error status WriteObject() Here is a scenario: 1. `resolveFrostFSErrors` is false. 2. The first object part was not written, which was signified in status. 3. The second part was written correctly. Client now thinks that the object is written even though it was not. In theory we could also return only status, but client-side splitting is not a single RPC, so it makes sense. Signed-off-by: Evgenii Stratonikov --- client/object_put_transformer.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/client/object_put_transformer.go b/client/object_put_transformer.go index ad8165d..402ad00 100644 --- a/client/object_put_transformer.go +++ b/client/object_put_transformer.go @@ -3,6 +3,7 @@ package client import ( "context" + apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/transformer" "google.golang.org/grpc/codes" @@ -82,6 +83,9 @@ func (it *internalTarget) putAsStream(ctx context.Context, o *object.Object) err wrt.WritePayloadChunk(ctx, o.Payload()) } it.res, err = wrt.Close(ctx) + if err == nil && !it.client.prm.resolveFrostFSErrors && !apistatus.IsSuccessful(it.res.st) { + err = apistatus.ErrFromStatus(it.res.st) + } return err } @@ -106,6 +110,10 @@ func (it *internalTarget) tryPutSingle(ctx context.Context, o *object.Object) (b statusRes: res.statusRes, obj: id, } + if !it.client.prm.resolveFrostFSErrors && !apistatus.IsSuccessful(it.res.st) { + return true, apistatus.ErrFromStatus(it.res.st) + } + return true, nil } return true, err } -- 2.45.2