Skip to content

Commit

Permalink
support downsampled blocks
Browse files Browse the repository at this point in the history
Signed-off-by: yeya24 <yb532204897@gmail.com>
  • Loading branch information
yeya24 committed May 18, 2021
1 parent c9a3774 commit f1a7888
Show file tree
Hide file tree
Showing 5 changed files with 295 additions and 68 deletions.
2 changes: 1 addition & 1 deletion cmd/thanos/compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func runCompact(
ignoreDeletionMarkFilter,
duplicateBlocksFilter,
noCompactMarkerFilter,
}, []block.MetadataModifier{block.NewReplicaLabelRemover(logger, conf.dedupReplicaLabels, conf.dedupFunc == compact.DedupAlgorithmPenalty)},
}, []block.MetadataModifier{block.NewReplicaLabelRemover(logger, conf.dedupReplicaLabels)},
)
cf.UpdateOnChange(func(blocks []metadata.Meta, err error) {
compactorView.Set(blocks, err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/thanos/tools_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ func registerBucketCleanup(app extkingpin.AppClause, objStoreConfig *extflag.Pat
block.NewConsistencyDelayMetaFilter(logger, *consistencyDelay, extprom.WrapRegistererWithPrefix(extpromPrefix, reg)),
ignoreDeletionMarkFilter,
duplicateBlocksFilter,
}, []block.MetadataModifier{block.NewReplicaLabelRemover(logger, make([]string, 0), false)},
}, []block.MetadataModifier{block.NewReplicaLabelRemover(logger, make([]string, 0))},
)
sy, err = compact.NewMetaSyncer(
logger,
Expand Down
10 changes: 2 additions & 8 deletions pkg/block/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -697,12 +697,11 @@ type ReplicaLabelRemover struct {
logger log.Logger

replicaLabels []string
dedupEnabled bool
}

// NewReplicaLabelRemover creates a ReplicaLabelRemover.
func NewReplicaLabelRemover(logger log.Logger, replicaLabels []string, dedupEnabled bool) *ReplicaLabelRemover {
return &ReplicaLabelRemover{logger: logger, replicaLabels: replicaLabels, dedupEnabled: dedupEnabled}
func NewReplicaLabelRemover(logger log.Logger, replicaLabels []string) *ReplicaLabelRemover {
return &ReplicaLabelRemover{logger: logger, replicaLabels: replicaLabels}
}

// Modify modifies external labels of existing blocks, it removes given replica labels from the metadata of blocks that have it.
Expand All @@ -712,11 +711,6 @@ func (r *ReplicaLabelRemover) Modify(_ context.Context, metas map[ulid.ULID]*met
}

for u, meta := range metas {
// Skip downsampled blocks for now if penalty based deduplication is enabled.
// TODO: remove this after downsampled blocks are supported.
if r.dedupEnabled && meta.Thanos.Downsample.Resolution != int64(0) {
continue
}
l := meta.Thanos.Labels
for _, replicaLabel := range r.replicaLabels {
if _, exists := l[replicaLabel]; exists {
Expand Down
6 changes: 3 additions & 3 deletions pkg/block/fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ func TestReplicaLabelRemover_Modify(t *testing.T) {
ULID(3): {Thanos: metadata.Thanos{Labels: map[string]string{"message": "something1"}}},
},
modified: 0,
replicaLabelRemover: NewReplicaLabelRemover(log.NewNopLogger(), []string{"replica", "rule_replica"}, false),
replicaLabelRemover: NewReplicaLabelRemover(log.NewNopLogger(), []string{"replica", "rule_replica"}),
},
{
name: "with replica labels",
Expand All @@ -916,7 +916,7 @@ func TestReplicaLabelRemover_Modify(t *testing.T) {
ULID(4): {Thanos: metadata.Thanos{Labels: map[string]string{"replica": "deduped"}}},
},
modified: 5.0,
replicaLabelRemover: NewReplicaLabelRemover(log.NewNopLogger(), []string{"replica", "rule_replica"}, false),
replicaLabelRemover: NewReplicaLabelRemover(log.NewNopLogger(), []string{"replica", "rule_replica"}),
},
{
name: "no replica label specified in the ReplicaLabelRemover",
Expand All @@ -931,7 +931,7 @@ func TestReplicaLabelRemover_Modify(t *testing.T) {
ULID(3): {Thanos: metadata.Thanos{Labels: map[string]string{"message": "something1"}}},
},
modified: 0,
replicaLabelRemover: NewReplicaLabelRemover(log.NewNopLogger(), []string{}, false),
replicaLabelRemover: NewReplicaLabelRemover(log.NewNopLogger(), []string{}),
},
} {
m := newTestFetcherMetrics()
Expand Down
Loading

0 comments on commit f1a7888

Please sign in to comment.