Skip to content

Commit

Permalink
node/config: allow "1b" config values for 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 <carpawell@nspcc.ru>
  • Loading branch information
carpawell committed Jul 26, 2024
1 parent 8448ff3 commit d838b06
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 2 deletions.
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 @@ -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"))
})
}
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 @@ -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
},

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 @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion docs/storage-node-configuration.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down

0 comments on commit d838b06

Please sign in to comment.