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{}
|
||||
|
||||
// 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,14 +147,12 @@ func (service *Service) CreateGetOrderLimits(ctx context.Context, bucket metabas
|
||||
return nil, storj.PiecePrivateKey{}, Error.Wrap(err)
|
||||
}
|
||||
|
||||
if segment.Placement != storj.EveryCountry {
|
||||
filter := service.placementRules(segment.Placement)
|
||||
for id, node := range nodes {
|
||||
if !filter.MatchInclude(node) {
|
||||
delete(nodes, id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
signer, err := NewSignerGet(service, segment.RootPieceID, time.Now(), orderLimit, bucket)
|
||||
if err != nil {
|
||||
|
@ -41,7 +41,9 @@ func (d *ConfigurablePlacementRule) String() string {
|
||||
// Set implements pflag.Value.
|
||||
func (d *ConfigurablePlacementRule) Set(s string) error {
|
||||
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()
|
||||
return d.AddPlacementFromString(s)
|
||||
@ -57,7 +59,8 @@ var _ pflag.Value = &ConfigurablePlacementRule{}
|
||||
// NewPlacementRules creates a fully initialized NewPlacementRules.
|
||||
func NewPlacementRules() *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.
|
||||
func (d *ConfigurablePlacementRule) CreateFilters(constraint storj.PlacementConstraint) (filter nodeselection.NodeFilter) {
|
||||
if constraint == storj.EveryCountry {
|
||||
return nodeselection.NodeFilters{}
|
||||
}
|
||||
if filters, found := d.placements[constraint]; found {
|
||||
return filters
|
||||
}
|
||||
|
@ -355,7 +355,7 @@ func (fork *observerFork) process(ctx context.Context, segment *rangedloop.Segme
|
||||
}
|
||||
|
||||
numOutOfPlacementPieces := 0
|
||||
if fork.doPlacementCheck && segment.Placement != storj.EveryCountry {
|
||||
if fork.doPlacementCheck {
|
||||
outOfPlacementPieces, err := fork.nodesCache.OutOfPlacementPieces(ctx, segment.CreatedAt, segment.Pieces, segment.Placement)
|
||||
if err != nil {
|
||||
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) {
|
||||
defer mon.Task()(&ctx)(nil)
|
||||
|
||||
if len(pieces) == 0 || placement == storj.EveryCountry {
|
||||
if len(pieces) == 0 {
|
||||
return metabase.Pieces{}, nil
|
||||
}
|
||||
|
||||
|
@ -717,7 +717,6 @@ func (repairer *SegmentRepairer) classifySegmentPieces(ctx context.Context, segm
|
||||
}
|
||||
}
|
||||
|
||||
if repairer.doPlacementCheck && placement != storj.EveryCountry {
|
||||
result.OutOfPlacementPiecesSet = map[uint16]bool{}
|
||||
|
||||
nodeFilters := repairer.placementRules(segment.Placement)
|
||||
@ -732,7 +731,6 @@ func (repairer *SegmentRepairer) classifySegmentPieces(ctx context.Context, segm
|
||||
}
|
||||
checkPlacement(online)
|
||||
checkPlacement(offline)
|
||||
}
|
||||
|
||||
result.NumUnhealthyRetrievable = len(result.ClumpedPiecesSet) + len(result.OutOfPlacementPiecesSet)
|
||||
if len(result.ClumpedPiecesSet) != 0 && len(result.OutOfPlacementPiecesSet) != 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user