[#220] netmap: process REP X policies correctly

For `REP X` select X nodes from the default filter
and fail if it cannot be done.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2020-12-03 13:52:36 +03:00 committed by Alex Vanin
parent 576841e0e0
commit 707a0bcb35
2 changed files with 50 additions and 0 deletions

View file

@ -71,6 +71,19 @@ func (m *Netmap) GetContainerNodes(p *PlacementPolicy, pivot []byte) (ContainerN
}
if r.Selector() == "" {
if len(p.Selectors()) == 0 {
s := new(Selector)
s.SetCount(r.Count())
s.SetFilter(MainFilterName)
nodes, err := c.getSelection(p, s)
if err != nil {
return nil, err
}
result[i] = flattenNodes(nodes)
}
for _, s := range p.Selectors() {
result[i] = append(result[i], flattenNodes(c.Selections[s.Name()])...)
}