From d838b06499684e465f10b79d839f7cd431f55df6 Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Thu, 25 Jul 2024 23:53:35 +0300 Subject: [PATCH] node/config: allow "1b" config values for memory amount It was not used in practice before, so no issues were opened, or tests were written, but it still looks like a valid configuration value. Signed-off-by: Pavel Karpy --- CHANGELOG.md | 1 + cmd/neofs-node/config/cast.go | 2 +- cmd/neofs-node/config/cast_test.go | 2 ++ cmd/neofs-node/config/test/config.json | 2 ++ cmd/neofs-node/config/test/config.yaml | 2 ++ docs/storage-node-configuration.md | 2 +- 6 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2306a18ccd..7ae4e09ed8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ Changelog for NeoFS Node ### Fixed - Control service's Drop call does not clean metabase (#2822) +- It was impossible to specify memory amount as "1b" (one byte) in config, default was used instead (#2899) ### Changed - neofs-cli allows several objects deletion at a time (#2774) diff --git a/cmd/neofs-node/config/cast.go b/cmd/neofs-node/config/cast.go index cf0017ca54..9036c3ab0a 100644 --- a/cmd/neofs-node/config/cast.go +++ b/cmd/neofs-node/config/cast.go @@ -199,7 +199,7 @@ func parseSizeInBytes(sizeStr string) uint64 { if sizeStr[lastChar] == 'b' || sizeStr[lastChar] == 'B' { lastChar-- } - if lastChar > 0 { + if lastChar >= 0 { switch unicode.ToLower(rune(sizeStr[lastChar])) { case 'k': multiplier = 1 << 10 diff --git a/cmd/neofs-node/config/cast_test.go b/cmd/neofs-node/config/cast_test.go index 85b6e1e95a..13173b02af 100644 --- a/cmd/neofs-node/config/cast_test.go +++ b/cmd/neofs-node/config/cast_test.go @@ -134,6 +134,8 @@ func TestSizeInBytes(t *testing.T) { require.EqualValues(t, tb/2, config.SizeInBytesSafe(c, "size_float")) require.EqualValues(t, uint64(14*gb+(gb*123/1000/mb*mb)), config.SizeInBytesSafe(c, "size_float_big")) require.EqualValues(t, 2048, config.SizeInBytesSafe(c, "size_bytes")) + require.EqualValues(t, 1, config.SizeInBytesSafe(c, "size_bytes_single_char")) + require.EqualValues(t, 1, config.SizeInBytesSafe(c, "size_bytes_single_char_no_space")) require.EqualValues(t, 123456, config.SizeInBytesSafe(c, "size_bytes_no_suffix")) }) } diff --git a/cmd/neofs-node/config/test/config.json b/cmd/neofs-node/config/test/config.json index 45635c7ab1..f2505f42f9 100644 --- a/cmd/neofs-node/config/test/config.json +++ b/cmd/neofs-node/config/test/config.json @@ -58,6 +58,8 @@ "size_float_big": "14.123 gb", "size_i_am_not_very_clever": "12.12345678", "size_bytes": "2048b", + "size_bytes_single_char": "1 b", + "size_bytes_single_char_no_space": "1b", "size_bytes_no_suffix": 123456 }, diff --git a/cmd/neofs-node/config/test/config.yaml b/cmd/neofs-node/config/test/config.yaml index 102c045a1c..d48a07cb21 100644 --- a/cmd/neofs-node/config/test/config.yaml +++ b/cmd/neofs-node/config/test/config.yaml @@ -51,6 +51,8 @@ sizes: size_float_big: 14.123 gb size_i_am_not_very_clever: 12.12345678 size_bytes: 2048b + size_bytes_single_char: 1 b + size_bytes_single_char_no_space: 1b size_bytes_no_suffix: 123456 with_default: diff --git a/docs/storage-node-configuration.md b/docs/storage-node-configuration.md index 51c2c0b2cf..25f6067b03 100644 --- a/docs/storage-node-configuration.md +++ b/docs/storage-node-configuration.md @@ -1,4 +1,4 @@ -# NeoFS Storage node configuration file +o # NeoFS Storage node configuration file This section contains detailed NeoFS Storage node configuration file description including default config values and some tips to set up configurable values.