traverser: Check for placement vector out of range #1516

Merged
fyrchik merged 1 commit from acid-ant/frostfs-node:bugfix/traverser-out-range into master 2024-11-21 11:27:53 +00:00
Member

Placement vector may contain fewer nodes count than it required by policy
due to the outage of the one of the node.

Signed-off-by: Anton Nikiforov an.nikiforov@yadro.com

Placement vector may contain fewer nodes count than it required by policy due to the outage of the one of the node. Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
acid-ant added 1 commit 2024-11-21 10:18:36 +00:00
[#xx] traverser: Check for placement vector out of range
Some checks failed
Tests and linters / Run gofumpt (pull_request) Successful in 2m39s
DCO action / DCO (pull_request) Failing after 2m58s
Pre-commit hooks / Pre-commit (pull_request) Successful in 3m13s
Vulncheck / Vulncheck (pull_request) Successful in 3m7s
Tests and linters / gopls check (pull_request) Successful in 4m38s
Tests and linters / Staticcheck (pull_request) Successful in 4m44s
Build / Build Components (pull_request) Successful in 6m3s
Tests and linters / Lint (pull_request) Successful in 6m26s
Tests and linters / Tests (pull_request) Successful in 8m49s
Tests and linters / Tests with -race (pull_request) Successful in 8m55s
afacc86f35
Placement vector may contain fewer nodes count than it required by policy
due to the outage of the one of the node.

Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
acid-ant requested review from storage-core-committers 2024-11-21 10:18:47 +00:00
acid-ant requested review from storage-core-developers 2024-11-21 10:18:50 +00:00
acid-ant force-pushed bugfix/traverser-out-range from afacc86f35 to 9e11e3dc85 2024-11-21 10:19:22 +00:00 Compare
acid-ant force-pushed bugfix/traverser-out-range from 9e11e3dc85 to 6132971266 2024-11-21 10:19:52 +00:00 Compare
dstepanov-yadro reviewed 2024-11-21 10:35:08 +00:00
@ -117,2 +116,2 @@
unsortedVector = append(unsortedVector, ns[i][:rem[i]]...)
regularVector = append(regularVector, ns[i][rem[i]:]...)
if len(ns[i]) < rem[i] {
unsortedVector = append(unsortedVector, ns[i]...)

Looks like you have forgotten regularVector = append(regularVector, ns[i][rem[i]:]...) here

Looks like you have forgotten `regularVector = append(regularVector, ns[i][rem[i]:]...)` here
Owner

But the like you wrote will panic!

But the like you wrote will panic!

I meant that the second slice is not updated.

I meant that the second slice is not updated.
Author
Member

It should not because we do not have enough nodes for that in the current vector.

It should not because we do not have enough nodes for that in the current vector.
fyrchik reviewed 2024-11-21 10:37:22 +00:00
@ -113,3 +113,2 @@
rem = defaultCopiesVector(cfg.policy)
var unsortedVector []netmap.NodeInfo
var regularVector []netmap.NodeInfo
var unsortedVector, regularVector []netmap.NodeInfo
Owner

Unrelated non-functional change, please, remove.

Unrelated non-functional change, please, remove.
Owner

Other than this LGTM

Other than this LGTM
Author
Member

Reverted.

Reverted.
acid-ant force-pushed bugfix/traverser-out-range from 6132971266 to bc1b4957e4 2024-11-21 10:46:13 +00:00 Compare
fyrchik reviewed 2024-11-21 10:57:13 +00:00
@ -116,3 +116,2 @@
for i := range rem {
unsortedVector = append(unsortedVector, ns[i][:rem[i]]...)
regularVector = append(regularVector, ns[i][rem[i]:]...)
if len(ns[i]) < rem[i] {
Owner

Linter complains about the size of this function.
How about

pivot := min(len(ns[i]), rem[i])
unsortedVector = append(unsortedVector, ns[i][:pivot]...)
regularVector = append(regularVector, ns[i][pivot:]...)
Linter complains about the size of this function. How about ``` pivot := min(len(ns[i]), rem[i]) unsortedVector = append(unsortedVector, ns[i][:pivot]...) regularVector = append(regularVector, ns[i][pivot:]...) ```
Owner

It is also somewhat more readable and concise IMO

It is also somewhat more readable and concise IMO
Author
Member

Nice! Updated.

Nice! Updated.
acid-ant force-pushed bugfix/traverser-out-range from bc1b4957e4 to 4d9d049e5a 2024-11-21 11:17:29 +00:00 Compare
acid-ant force-pushed bugfix/traverser-out-range from 4d9d049e5a to f12f04199e 2024-11-21 11:19:18 +00:00 Compare
fyrchik approved these changes 2024-11-21 11:21:34 +00:00
fyrchik merged commit f12f04199e into master 2024-11-21 11:27:53 +00:00
Sign in to join this conversation.
No reviewers
TrueCloudLab/storage-core-developers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-node#1516
No description provided.