diff --git a/CHANGELOG.md b/CHANGELOG.md index 2306a18ccd..95b2b06a79 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 (#ASDF) ### 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..d22c8f6ddf 100644 --- a/cmd/neofs-node/config/cast_test.go +++ b/cmd/neofs-node/config/cast_test.go @@ -125,6 +125,8 @@ func TestSizeInBytes(t *testing.T) { ) configtest.ForEachFileType("test/config", func(c *config.Config) { c = c.Sub("sizes") + require.EqualValues(t, 1, config.SizeInBytesSafe(c, "size_b")) + require.EqualValues(t, 1, config.SizeInBytesSafe(c, "size_b_no_space")) require.EqualValues(t, kb, config.SizeInBytesSafe(c, "size_kb")) require.EqualValues(t, 2*kb, config.SizeInBytesSafe(c, "size_kb_no_space")) require.EqualValues(t, 12*mb, config.SizeInBytesSafe(c, "size_mb")) diff --git a/cmd/neofs-node/config/test/config.json b/cmd/neofs-node/config/test/config.json index 45635c7ab1..6d1601ef55 100644 --- a/cmd/neofs-node/config/test/config.json +++ b/cmd/neofs-node/config/test/config.json @@ -49,6 +49,8 @@ }, "sizes": { + "size_b": "1 b", + "size_b_no_space": "1b", "size_kb": "1 kb", "size_kb_no_space": "2kb", "size_mb": "12m", diff --git a/cmd/neofs-node/config/test/config.yaml b/cmd/neofs-node/config/test/config.yaml index 102c045a1c..334c703a0d 100644 --- a/cmd/neofs-node/config/test/config.yaml +++ b/cmd/neofs-node/config/test/config.yaml @@ -42,6 +42,8 @@ bool: incorrect: not true sizes: + size_b: 1 b + size_b_no_space: 1b size_kb: 1 kb size_kb_no_space: 2kb size_mb: 12m