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
Showing only changes of commit 3d953d7185 - Show all commits

View file

@ -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,8 +126,8 @@ func (p *Policer) processRepNodes(ctx context.Context, requirements *placementRe
if st == nodeDoesNotHoldObject {
// 1. This is the first time the node is encountered (`!st.Processed()`).
// 2. The node does not hold object (`st == nodeDoesNotHoldObject`).
// So we leave the node in the list and skip its removal
// at the end of the loop body.
// So we need to try to put an object to it.
candidates = append(candidates, nodes[i])
continue
}
}
@ -152,12 +153,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) {