Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

netmap: export ErrNotEnoughNodes #615

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion netmap/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,15 @@ type context struct {

// Various validation errors.
var (
// ErrNotEnoughNodes is returned when a placement policy cannot be satisfied
// due to low numbers of nodes in selected network map.
ErrNotEnoughNodes = errors.New("not enough nodes to SELECT from")

errInvalidFilterName = errors.New("filter name is invalid")
errInvalidNumber = errors.New("invalid number")
errInvalidFilterOp = errors.New("invalid filter operation")
errFilterNotFound = errors.New("filter not found")
errNonEmptyFilters = errors.New("simple filter contains sub-filters")
errNotEnoughNodes = errors.New("not enough nodes to SELECT from")
errUnnamedTopFilter = errors.New("unnamed top-level filter")
)

Expand Down
3 changes: 3 additions & 0 deletions netmap/netmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ func (m NetMap) PlacementVectors(vectors [][]NodeInfo, objectID oid.ID) ([][]Nod
//
// The value returned shares memory with the structure itself, so changing it can lead to data corruption.
// Make a copy if you need to change it.
//
// Returns ErrNotEnoughNodes if placement policy cannot be satisfied in the
// current network map because of a lack of container nodes.
func (m NetMap) ContainerNodes(p PlacementPolicy, containerID cid.ID) ([][]NodeInfo, error) {
c := newContext(m)
c.setCBF(p.backupFactor)
Expand Down
4 changes: 2 additions & 2 deletions netmap/selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (c *context) getSelection(_ PlacementPolicy, s netmap.Selector) ([]nodes, e
buckets := c.getSelectionBase(s)

if len(buckets) < bucketCount {
return nil, fmt.Errorf("%w: '%s'", errNotEnoughNodes, s.GetName())
return nil, fmt.Errorf("%w: '%s'", ErrNotEnoughNodes, s.GetName())
}

// We need deterministic output in case there is no pivot.
Expand Down Expand Up @@ -97,7 +97,7 @@ func (c *context) getSelection(_ PlacementPolicy, s netmap.Selector) ([]nodes, e
// Fallback to using minimum allowed backup factor (1).
res = append(res, fallback...)
if len(res) < bucketCount {
return nil, fmt.Errorf("%w: '%s'", errNotEnoughNodes, s.GetName())
return nil, fmt.Errorf("%w: '%s'", ErrNotEnoughNodes, s.GetName())
}
}

Expand Down
Loading