Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/allow "1b" config values for memory amount #2899

Merged
merged 1 commit into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading