policer: Do not mutate slice under iteration
Some checks failed
DCO action / DCO (pull_request) Failing after 49s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m52s
Build / Build Components (pull_request) Successful in 2m20s
Tests and linters / Lint (pull_request) Successful in 3m8s
Tests and linters / Tests with -race (pull_request) Successful in 3m18s
Tests and linters / Run gofumpt (pull_request) Successful in 3m27s
Tests and linters / Tests (pull_request) Successful in 4m7s
Tests and linters / Staticcheck (pull_request) Successful in 4m6s
Tests and linters / gopls check (pull_request) Successful in 5m7s
Vulncheck / Vulncheck (pull_request) Successful in 50s
Some checks failed
DCO action / DCO (pull_request) Failing after 49s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m52s
Build / Build Components (pull_request) Successful in 2m20s
Tests and linters / Lint (pull_request) Successful in 3m8s
Tests and linters / Tests with -race (pull_request) Successful in 3m18s
Tests and linters / Run gofumpt (pull_request) Successful in 3m27s
Tests and linters / Tests (pull_request) Successful in 4m7s
Tests and linters / Staticcheck (pull_request) Successful in 4m6s
Tests and linters / gopls check (pull_request) Successful in 5m7s
Vulncheck / Vulncheck (pull_request) Successful in 50s
Nothing wrong with it, besides being difficult to read. Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
98e7033123
commit
94ed520eba
1 changed files with 5 additions and 7 deletions
|
@ -110,6 +110,7 @@ func (p *Policer) processRepNodes(ctx context.Context, requirements *placementRe
|
|||
|
||||
// Number of copies that are stored on maintenance nodes.
|
||||
var uncheckedCopies int
|
||||
var candidates []netmap.NodeInfo
|
||||
for i := 0; shortage > 0 && i < len(nodes); i++ {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
|
@ -125,9 +126,9 @@ func (p *Policer) processRepNodes(ctx context.Context, requirements *placementRe
|
|||
checkedNodes.set(nodes[i], st)
|
||||
if st == nodeDoesNotHoldObject {
|
||||
// 1. The node does not hold object (`st == nodeDoesNotHoldObject`).
|
||||
// 2. This is the first time the node is encountered (`!cached``).
|
||||
// So we leave the node in the list and skip its removal
|
||||
// at the end of the loop body.
|
||||
// 2. This is the first time the node is encountered (`!cached`).
|
||||
// So we need to try to put an object to it.
|
||||
candidates = append(candidates, nodes[i])
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
@ -153,12 +154,9 @@ func (p *Policer) processRepNodes(ctx context.Context, requirements *placementRe
|
|||
default:
|
||||
panic("unreachable")
|
||||
}
|
||||
|
||||
nodes = append(nodes[:i], nodes[i+1:]...)
|
||||
i--
|
||||
}
|
||||
|
||||
p.handleProcessNodesResult(ctx, addr, requirements, nodes, checkedNodes, shortage, uncheckedCopies)
|
||||
p.handleProcessNodesResult(ctx, addr, requirements, candidates, checkedNodes, shortage, uncheckedCopies)
|
||||
}
|
||||
|
||||
func (p *Policer) checkStatus(ctx context.Context, addr oid.Address, node netmap.NodeInfo) (nodeProcessStatus, error) {
|
||||
|
|
Loading…
Reference in a new issue