satellite/~placement: do not ignore placement check for placement=0
There are cases when we would like to override the default placement=0 rule. For example when we would like to exclude tagged nodes from the selection (by default). Therefore we couldn't use a shortcut any more, we should always check the placement rules, even if we use placement=0. TODO: we need to update common, and rename `EveryCountry` to `DefaultPlacement`, just to avoid confusion. https://github.com/storj/storj/issues/6126 Change-Id: Iba6c655bd623e04351ea7ff91fd741785dc193e4
This commit is contained in:
parent
baef654197
commit
da08117fcd
@ -215,3 +215,13 @@ func NewExcludeFilter(filter NodeFilter) ExcludeFilter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var _ NodeFilter = ExcludeFilter{}
|
var _ NodeFilter = ExcludeFilter{}
|
||||||
|
|
||||||
|
// AnyFilter matches all the nodes.
|
||||||
|
type AnyFilter struct{}
|
||||||
|
|
||||||
|
// MatchInclude implements NodeFilter interface.
|
||||||
|
func (a AnyFilter) MatchInclude(node *SelectedNode) bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ NodeFilter = AnyFilter{}
|
||||||
|
@ -147,12 +147,10 @@ func (service *Service) CreateGetOrderLimits(ctx context.Context, bucket metabas
|
|||||||
return nil, storj.PiecePrivateKey{}, Error.Wrap(err)
|
return nil, storj.PiecePrivateKey{}, Error.Wrap(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if segment.Placement != storj.EveryCountry {
|
filter := service.placementRules(segment.Placement)
|
||||||
filter := service.placementRules(segment.Placement)
|
for id, node := range nodes {
|
||||||
for id, node := range nodes {
|
if !filter.MatchInclude(node) {
|
||||||
if !filter.MatchInclude(node) {
|
delete(nodes, id)
|
||||||
delete(nodes, id)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,9 @@ func (d *ConfigurablePlacementRule) String() string {
|
|||||||
// Set implements pflag.Value.
|
// Set implements pflag.Value.
|
||||||
func (d *ConfigurablePlacementRule) Set(s string) error {
|
func (d *ConfigurablePlacementRule) Set(s string) error {
|
||||||
if d.placements == nil {
|
if d.placements == nil {
|
||||||
d.placements = make(map[storj.PlacementConstraint]nodeselection.NodeFilter)
|
d.placements = map[storj.PlacementConstraint]nodeselection.NodeFilter{
|
||||||
|
storj.EveryCountry: nodeselection.AnyFilter{},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
d.AddLegacyStaticRules()
|
d.AddLegacyStaticRules()
|
||||||
return d.AddPlacementFromString(s)
|
return d.AddPlacementFromString(s)
|
||||||
@ -57,7 +59,8 @@ var _ pflag.Value = &ConfigurablePlacementRule{}
|
|||||||
// NewPlacementRules creates a fully initialized NewPlacementRules.
|
// NewPlacementRules creates a fully initialized NewPlacementRules.
|
||||||
func NewPlacementRules() *ConfigurablePlacementRule {
|
func NewPlacementRules() *ConfigurablePlacementRule {
|
||||||
return &ConfigurablePlacementRule{
|
return &ConfigurablePlacementRule{
|
||||||
placements: make(map[storj.PlacementConstraint]nodeselection.NodeFilter),
|
placements: map[storj.PlacementConstraint]nodeselection.NodeFilter{
|
||||||
|
storj.EveryCountry: nodeselection.AnyFilter{}},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,9 +155,6 @@ func (d *ConfigurablePlacementRule) AddPlacementFromString(definitions string) e
|
|||||||
|
|
||||||
// CreateFilters implements PlacementCondition.
|
// CreateFilters implements PlacementCondition.
|
||||||
func (d *ConfigurablePlacementRule) CreateFilters(constraint storj.PlacementConstraint) (filter nodeselection.NodeFilter) {
|
func (d *ConfigurablePlacementRule) CreateFilters(constraint storj.PlacementConstraint) (filter nodeselection.NodeFilter) {
|
||||||
if constraint == storj.EveryCountry {
|
|
||||||
return nodeselection.NodeFilters{}
|
|
||||||
}
|
|
||||||
if filters, found := d.placements[constraint]; found {
|
if filters, found := d.placements[constraint]; found {
|
||||||
return filters
|
return filters
|
||||||
}
|
}
|
||||||
|
@ -355,7 +355,7 @@ func (fork *observerFork) process(ctx context.Context, segment *rangedloop.Segme
|
|||||||
}
|
}
|
||||||
|
|
||||||
numOutOfPlacementPieces := 0
|
numOutOfPlacementPieces := 0
|
||||||
if fork.doPlacementCheck && segment.Placement != storj.EveryCountry {
|
if fork.doPlacementCheck {
|
||||||
outOfPlacementPieces, err := fork.nodesCache.OutOfPlacementPieces(ctx, segment.CreatedAt, segment.Pieces, segment.Placement)
|
outOfPlacementPieces, err := fork.nodesCache.OutOfPlacementPieces(ctx, segment.CreatedAt, segment.Pieces, segment.Placement)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fork.totalStats.remoteSegmentsFailedToCheck++
|
fork.totalStats.remoteSegmentsFailedToCheck++
|
||||||
|
@ -98,7 +98,7 @@ func (cache *ReliabilityCache) MissingPieces(ctx context.Context, created time.T
|
|||||||
func (cache *ReliabilityCache) OutOfPlacementPieces(ctx context.Context, created time.Time, pieces metabase.Pieces, placement storj.PlacementConstraint) (_ metabase.Pieces, err error) {
|
func (cache *ReliabilityCache) OutOfPlacementPieces(ctx context.Context, created time.Time, pieces metabase.Pieces, placement storj.PlacementConstraint) (_ metabase.Pieces, err error) {
|
||||||
defer mon.Task()(&ctx)(nil)
|
defer mon.Task()(&ctx)(nil)
|
||||||
|
|
||||||
if len(pieces) == 0 || placement == storj.EveryCountry {
|
if len(pieces) == 0 {
|
||||||
return metabase.Pieces{}, nil
|
return metabase.Pieces{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -717,22 +717,20 @@ func (repairer *SegmentRepairer) classifySegmentPieces(ctx context.Context, segm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if repairer.doPlacementCheck && placement != storj.EveryCountry {
|
result.OutOfPlacementPiecesSet = map[uint16]bool{}
|
||||||
result.OutOfPlacementPiecesSet = map[uint16]bool{}
|
|
||||||
|
|
||||||
nodeFilters := repairer.placementRules(segment.Placement)
|
nodeFilters := repairer.placementRules(segment.Placement)
|
||||||
checkPlacement := func(reliable []nodeselection.SelectedNode) {
|
checkPlacement := func(reliable []nodeselection.SelectedNode) {
|
||||||
for _, node := range reliable {
|
for _, node := range reliable {
|
||||||
if nodeFilters.MatchInclude(&node) {
|
if nodeFilters.MatchInclude(&node) {
|
||||||
continue
|
continue
|
||||||
}
|
|
||||||
|
|
||||||
result.OutOfPlacementPiecesSet[nodeIDPieceMap[node.ID]] = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result.OutOfPlacementPiecesSet[nodeIDPieceMap[node.ID]] = true
|
||||||
}
|
}
|
||||||
checkPlacement(online)
|
|
||||||
checkPlacement(offline)
|
|
||||||
}
|
}
|
||||||
|
checkPlacement(online)
|
||||||
|
checkPlacement(offline)
|
||||||
|
|
||||||
result.NumUnhealthyRetrievable = len(result.ClumpedPiecesSet) + len(result.OutOfPlacementPiecesSet)
|
result.NumUnhealthyRetrievable = len(result.ClumpedPiecesSet) + len(result.OutOfPlacementPiecesSet)
|
||||||
if len(result.ClumpedPiecesSet) != 0 && len(result.OutOfPlacementPiecesSet) != 0 {
|
if len(result.ClumpedPiecesSet) != 0 && len(result.OutOfPlacementPiecesSet) != 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user