From 18ed3bb3e8e75efceef832c050d7e6c15a3e53d2 Mon Sep 17 00:00:00 2001 From: Ekaterina Pavlova Date: Sat, 2 Nov 2024 21:43:20 +0300 Subject: [PATCH 1/2] cli: fix missing errors on closure of writer in `upload-bin` Ref #3658 Signed-off-by: Ekaterina Pavlova --- cli/util/upload_bin.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cli/util/upload_bin.go b/cli/util/upload_bin.go index 7b7f315b1..89a4fdef0 100644 --- a/cli/util/upload_bin.go +++ b/cli/util/upload_bin.go @@ -581,11 +581,19 @@ func uploadObj(ctx context.Context, p *pool.Pool, signer user.Signer, owner util if err != nil { return fmt.Errorf("failed to initiate object upload: %w", err) } - defer writer.Close() _, err = writer.Write(objData) if err != nil { + _ = writer.Close() return fmt.Errorf("failed to write object data: %w", err) } + err = writer.Close() + if err != nil { + return fmt.Errorf("failed to close object writer: %w", err) + } + res := writer.GetResult() + if res.StoredObjectID().Equals(oid.ID{}) { + return fmt.Errorf("object ID is empty") + } return nil } From 29e2d712f4a207f0b965fb32cc18678c96456c1f Mon Sep 17 00:00:00 2001 From: Ekaterina Pavlova Date: Sat, 2 Nov 2024 21:56:06 +0300 Subject: [PATCH 2/2] cli: add flag `max-retries` for `upload-bin` Signed-off-by: Ekaterina Pavlova --- cli/util/convert.go | 13 +++++++++++- cli/util/upload_bin.go | 41 +++++++++++++++++++------------------- docs/neofs-blockstorage.md | 3 ++- 3 files changed, 34 insertions(+), 23 deletions(-) diff --git a/cli/util/convert.go b/cli/util/convert.go index 586513305..5c5a7e707 100644 --- a/cli/util/convert.go +++ b/cli/util/convert.go @@ -90,6 +90,17 @@ func NewCommands() []*cli.Command { Name: "skip-blocks-uploading", Usage: "Skip blocks uploading and upload only index files", }, + &cli.UintFlag{ + Name: "retries", + Usage: "Maximum number of Neo/NeoFS node request retries", + Value: 5, + Action: func(context *cli.Context, u uint) error { + if u < 1 { + return cli.Exit("retries should be greater than 0", 1) + } + return nil + }, + }, }, options.RPC...) uploadBinFlags = append(uploadBinFlags, options.Wallet...) return []*cli.Command{ @@ -172,7 +183,7 @@ func NewCommands() []*cli.Command { { Name: "upload-bin", Usage: "Fetch blocks from RPC node and upload them to the NeoFS container", - UsageText: "neo-go util upload-bin --fs-rpc-endpoint [,[...]] --container --block-attribute block --index-attribute index --rpc-endpoint [--timeout