Skip to content

Commit

Permalink
node/config: allow "1b" config values from memory amount
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
carpawell committed Jul 25, 2024
1 parent 8448ff3 commit 3e22688
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-node/config/cast.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions cmd/neofs-node/config/cast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
2 changes: 2 additions & 0 deletions cmd/neofs-node/config/test/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions cmd/neofs-node/config/test/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3e22688

Please sign in to comment.