policer: Simplify processRepNodes() checks #1605

Merged
fyrchik merged 2 commits from fyrchik/frostfs-node:refactor-policer into master 2025-01-21 05:34:55 +00:00
Owner

Hopefully, it is easier to read now.

Current flow is hard to reason about, #1601 is a notorious example of
accidental complexity.

  1. Remove multiple nested ifs, use depth=1.
  2. Process each status exactly once, hopefully preventing bugs like
    #1601.

Signed-off-by: Evgenii Stratonikov e.stratonikov@yadro.com

Hopefully, it is easier to read now. Current flow is hard to reason about, #1601 is a notorious example of accidental complexity. 1. Remove multiple nested ifs, use depth=1. 2. Process each status exactly once, hopefully preventing bugs like #1601. Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
fyrchik added the
refactoring
internal
labels 2025-01-17 09:40:51 +00:00
fyrchik added 1 commit 2025-01-17 09:40:51 +00:00
policer: Simplify processRepNodes() checks
Some checks failed
Tests and linters / Run gofumpt (pull_request) Successful in 24s
DCO action / DCO (pull_request) Failing after 31s
Vulncheck / Vulncheck (pull_request) Successful in 1m17s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m30s
Build / Build Components (pull_request) Successful in 1m47s
Tests and linters / Staticcheck (pull_request) Successful in 2m26s
Tests and linters / Lint (pull_request) Successful in 3m26s
Tests and linters / Tests (pull_request) Successful in 4m13s
Tests and linters / Tests with -race (pull_request) Successful in 4m36s
Tests and linters / gopls check (pull_request) Successful in 5m19s
5447d3f4e9
Current flow is hard to reason about, #1601 is a notorious example of
accidental complexity.
1. Remove multiple nested ifs, use depth=1.
2. Process each status exactly once, hopefully preventing bugs like
   #1601.

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
fyrchik requested review from storage-core-committers 2025-01-17 09:40:52 +00:00
fyrchik requested review from storage-core-developers 2025-01-17 09:40:52 +00:00
fyrchik force-pushed refactor-policer from 5447d3f4e9 to 87e7122aa7 2025-01-17 09:41:34 +00:00 Compare
fyrchik force-pushed refactor-policer from 87e7122aa7 to 9e2182e1a2 2025-01-17 10:19:28 +00:00 Compare
a-savchuk approved these changes 2025-01-17 10:41:08 +00:00
Dismissed
fyrchik added this to the v0.45.0 milestone 2025-01-17 12:32:46 +00:00
acid-ant approved these changes 2025-01-20 06:29:31 +00:00
Dismissed
dstepanov-yadro reviewed 2025-01-20 09:32:45 +00:00
@ -138,0 +139,4 @@
case nodeHoldsObject:
shortage--
case nodeDoesNotHoldObject:
if !cached {

While we're here, is it possible to get rid of this nested if? For example, I can't understand what this condition means.

While we're here, is it possible to get rid of this nested `if`? For example, I can't understand what this condition means.

Why is it that when we receive the error "object not found" from a node (st == nodeDoesNotHoldObject), and we have not previously requested information on this node (false == cached), we do not remove the node from the list of nodes?

Why is it that when we receive the error "object not found" from a node (`st == nodeDoesNotHoldObject`), and we have not previously requested information on this node (`false == cached`), we do not remove the node from the list of nodes?
Author
Owner

I don't like it too, have already tried get rid of this if.
Will try again harder, stay tuned.

I don't like it too, have already tried get rid of this `if`. Will try again harder, stay tuned.
Author
Owner

@dstepanov-yadro I have updated the code, please take a look.

@dstepanov-yadro I have updated the code, please take a look.
fyrchik changed title from policer: Simplify processRepNodes() checks to WIP: policer: Simplify processRepNodes() checks 2025-01-20 10:43:40 +00:00
fyrchik force-pushed refactor-policer from 9e2182e1a2 to 98e7033123 2025-01-20 11:11:58 +00:00 Compare
fyrchik dismissed a-savchuk's review 2025-01-20 11:11:58 +00:00
Reason:

New commits pushed, approval review dismissed automatically according to repository settings

fyrchik dismissed acid-ant's review 2025-01-20 11:11:58 +00:00
Reason:

New commits pushed, approval review dismissed automatically according to repository settings

fyrchik changed title from WIP: policer: Simplify processRepNodes() checks to policer: Simplify processRepNodes() checks 2025-01-20 11:12:28 +00:00
fyrchik requested review from storage-core-committers 2025-01-20 11:12:29 +00:00
fyrchik requested review from storage-core-developers 2025-01-20 11:12:29 +00:00
fyrchik changed title from policer: Simplify processRepNodes() checks to WIP: policer: Simplify processRepNodes() checks 2025-01-20 11:13:05 +00:00
fyrchik changed title from WIP: policer: Simplify processRepNodes() checks to policer: Simplify processRepNodes() checks 2025-01-20 11:13:34 +00:00
fyrchik added 1 commit 2025-01-20 13:10:31 +00:00
policer: Do not mutate slice under iteration
Some checks failed
DCO action / DCO (pull_request) Failing after 32s
Vulncheck / Vulncheck (pull_request) Successful in 1m7s
Build / Build Components (pull_request) Successful in 1m40s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m41s
Tests and linters / gopls check (pull_request) Successful in 2m30s
Tests and linters / Tests with -race (pull_request) Successful in 2m37s
Tests and linters / Run gofumpt (pull_request) Successful in 3m3s
Tests and linters / Lint (pull_request) Successful in 3m29s
Tests and linters / Staticcheck (pull_request) Successful in 3m25s
Tests and linters / Tests (pull_request) Successful in 6m14s
d24cbb0b1d
Nothing wrong with it, besides being difficult to read.

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
fyrchik force-pushed refactor-policer from d24cbb0b1d to 94ed520eba 2025-01-20 13:11:11 +00:00 Compare
fyrchik force-pushed refactor-policer from 94ed520eba to 106446f12d 2025-01-20 13:13:12 +00:00 Compare
a-savchuk approved these changes 2025-01-20 13:19:07 +00:00
fyrchik force-pushed refactor-policer from 106446f12d to 3d953d7185 2025-01-20 13:30:16 +00:00 Compare
dstepanov-yadro approved these changes 2025-01-20 14:09:23 +00:00
fyrchik merged commit 951a7ee1c7 into master 2025-01-21 05:34:55 +00:00
fyrchik deleted branch refactor-policer 2025-01-21 05:34:59 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
4 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#1605
No description provided.