Skip to content

Commit

Permalink
Revert "Merge 0.12 into master (#2559)" (#2560)
Browse files Browse the repository at this point in the history
This reverts commit 003d245.

Signed-off-by: Lucas Servén Marín <[email protected]>
  • Loading branch information
squat authored May 4, 2020
1 parent 003d245 commit 2c61a47
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 170 deletions.
7 changes: 0 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ We use *breaking* word for marking changes that are not backward compatible (rel
moved `thanos check rules` to `thanos tools rules-check`. `thanos tools rules-check` also takes rules by `--rules` repeated flag not argument
anymore.

## [v0.12.2](https://github.com/thanos-io/thanos/releases/tag/v0.12.2) - 2020.04.30

### Fixed

- [#2459](https://github.com/thanos-io/thanos/issues/2459) Compact: Fixed issue with old blocks being marked and deleted in a (slow) loop.
- [#2533](https://github.com/thanos-io/thanos/pull/2515) Rule: do not wrap reload endpoint with `/`. Makes `/-/reload` accessible again when no prefix has been specified.

## [v0.12.1](https://github.com/thanos-io/thanos/releases/tag/v0.12.1) - 2020.04.20

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.12.2
0.12.1
2 changes: 1 addition & 1 deletion cmd/thanos/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ func runRule(
router = router.WithPrefix(webRoutePrefix)
}

router.Post("/-/reload", func(w http.ResponseWriter, r *http.Request) {
router.WithPrefix(webRoutePrefix).Post("/-/reload", func(w http.ResponseWriter, r *http.Request) {
reloadMsg := make(chan error)
reloadWebhandler <- reloadMsg
if err := <-reloadMsg; err != nil {
Expand Down
2 changes: 0 additions & 2 deletions pkg/block/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,8 +559,6 @@ func NewDeduplicateFilter() *DeduplicateFilter {
// Filter filters out duplicate blocks that can be formed
// from two or more overlapping blocks that fully submatches the source blocks of the older blocks.
func (f *DeduplicateFilter) Filter(_ context.Context, metas map[ulid.ULID]*metadata.Meta, synced *extprom.TxGaugeVec) error {
f.duplicateIDs = f.duplicateIDs[:0]

var wg sync.WaitGroup

metasByResolution := make(map[int64][]*metadata.Meta)
Expand Down
100 changes: 0 additions & 100 deletions pkg/compact/compact_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ func TestSyncer_GarbageCollect_e2e(t *testing.T) {

// After another sync the changes should also be reflected in the local groups.
testutil.Ok(t, sy.SyncMetas(ctx))
testutil.Ok(t, sy.GarbageCollect(ctx))

// Only the level 3 block, the last source block in both resolutions should be left.
groups, err := sy.Groups()
Expand Down Expand Up @@ -417,102 +416,3 @@ func createAndUpload(t testing.TB, bkt objstore.Bucket, blocks []blockgenSpec) (
}
return metas
}

// Regression test for #2459 issue.
func TestGarbageCollectDoesntCreateEmptyBlocksWithDeletionMarksOnly(t *testing.T) {
logger := log.NewLogfmtLogger(os.Stderr)

objtesting.ForeachStore(t, func(t *testing.T, bkt objstore.Bucket) {
ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
defer cancel()

// Generate two blocks, and then another block that covers both of them.
var metas []*metadata.Meta
var ids []ulid.ULID

for i := 0; i < 2; i++ {
var m metadata.Meta

m.Version = 1
m.ULID = ulid.MustNew(uint64(i), nil)
m.Compaction.Sources = []ulid.ULID{m.ULID}
m.Compaction.Level = 1

ids = append(ids, m.ULID)
metas = append(metas, &m)
}

var m1 metadata.Meta
m1.Version = 1
m1.ULID = ulid.MustNew(100, nil)
m1.Compaction.Level = 2
m1.Compaction.Sources = ids
m1.Thanos.Downsample.Resolution = 0

// Create all blocks in the bucket.
for _, m := range append(metas, &m1) {
fmt.Println("create", m.ULID)
var buf bytes.Buffer
testutil.Ok(t, json.NewEncoder(&buf).Encode(&m))
testutil.Ok(t, bkt.Upload(ctx, path.Join(m.ULID.String(), metadata.MetaFilename), &buf))
}

blocksMarkedForDeletion := promauto.With(nil).NewCounter(prometheus.CounterOpts{})
ignoreDeletionMarkFilter := block.NewIgnoreDeletionMarkFilter(nil, objstore.WithNoopInstr(bkt), 48*time.Hour)

duplicateBlocksFilter := block.NewDeduplicateFilter()
metaFetcher, err := block.NewMetaFetcher(nil, 32, objstore.WithNoopInstr(bkt), "", nil, []block.MetadataFilter{
ignoreDeletionMarkFilter,
duplicateBlocksFilter,
}, nil)
testutil.Ok(t, err)

sy, err := NewSyncer(nil, nil, bkt, metaFetcher, duplicateBlocksFilter, ignoreDeletionMarkFilter, blocksMarkedForDeletion, 1, false, false)
testutil.Ok(t, err)

// Do one initial synchronization with the bucket.
testutil.Ok(t, sy.SyncMetas(ctx))
testutil.Ok(t, sy.GarbageCollect(ctx))
testutil.Equals(t, 2.0, promtest.ToFloat64(sy.metrics.garbageCollectedBlocks))

rem, err := listBlocksMarkedForDeletion(ctx, bkt)
testutil.Ok(t, err)

sort.Slice(rem, func(i, j int) bool {
return rem[i].Compare(rem[j]) < 0
})

testutil.Equals(t, ids, rem)

// Delete source blocks.
for _, id := range ids {
testutil.Ok(t, block.Delete(ctx, logger, bkt, id))
}

// After another garbage-collect, we should not find new blocks that are deleted with new deletion mark files.
testutil.Ok(t, sy.SyncMetas(ctx))
testutil.Ok(t, sy.GarbageCollect(ctx))

rem, err = listBlocksMarkedForDeletion(ctx, bkt)
testutil.Ok(t, err)
testutil.Equals(t, 0, len(rem))
})
}

func listBlocksMarkedForDeletion(ctx context.Context, bkt objstore.Bucket) ([]ulid.ULID, error) {
var rem []ulid.ULID
err := bkt.Iter(ctx, "", func(n string) error {
id := ulid.MustParse(n[:len(n)-1])
deletionMarkFile := path.Join(id.String(), metadata.DeletionMarkFilename)

exists, err := bkt.Exists(ctx, deletionMarkFile)
if err != nil {
return err
}
if exists {
rem = append(rem, id)
}
return nil
})
return rem, err
}
59 changes: 6 additions & 53 deletions test/e2e/rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,44 +59,18 @@ groups:
severity: page
annotations:
summary: "I always complain and allow partial response in query."
`
testAlertRuleAddedLaterWebHandler = `
groups:
- name: example
partial_response_strategy: "WARN"
rules:
- alert: TestAlert_HasBeenLoadedViaWebHandler
# It must be based on actual metric, otherwise call to StoreAPI would be not involved.
expr: absent(some_metric)
labels:
severity: page
annotations:
summary: "I always complain and I have been loaded via /-/reload."
`
)

func createRuleFile(t *testing.T, path, content string) {
t.Helper()
err := ioutil.WriteFile(path, []byte(content), 0666)
testutil.Ok(t, err)
}

func createRuleFiles(t *testing.T, dir string) {
t.Helper()

for i, rule := range []string{testAlertRuleAbortOnPartialResponse, testAlertRuleWarnOnPartialResponse} {
createRuleFile(t, filepath.Join(dir, fmt.Sprintf("rules-%d.yaml", i)), rule)
err := ioutil.WriteFile(filepath.Join(dir, fmt.Sprintf("rules-%d.yaml", i)), []byte(rule), 0666)
testutil.Ok(t, err)
}
}

func reloadRulesHTTP(t *testing.T, ctx context.Context, endpoint string) {
req, err := http.NewRequestWithContext(ctx, "POST", "http://"+endpoint+"/-/reload", ioutil.NopCloser(bytes.NewReader(nil)))
testutil.Ok(t, err)
resp, err := http.DefaultClient.Do(req)
testutil.Ok(t, err)
testutil.Equals(t, 200, resp.StatusCode)
}

func writeTargets(t *testing.T, path string, addrs ...string) {
t.Helper()

Expand Down Expand Up @@ -295,14 +269,10 @@ func TestRule(t *testing.T) {
testutil.Ok(t, err)
defer s.Close()

ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute)
defer cancel()

// Prepare work dirs.
rulesSubDir := filepath.Join("rules")
rulesPath := filepath.Join(s.SharedDir(), rulesSubDir)
testutil.Ok(t, os.MkdirAll(rulesPath, os.ModePerm))
createRuleFiles(t, rulesPath)
testutil.Ok(t, os.MkdirAll(filepath.Join(s.SharedDir(), rulesSubDir), os.ModePerm))
createRuleFiles(t, filepath.Join(s.SharedDir(), rulesSubDir))
amTargetsSubDir := filepath.Join("rules_am_targets")
testutil.Ok(t, os.MkdirAll(filepath.Join(s.SharedDir(), amTargetsSubDir), os.ModePerm))
queryTargetsSubDir := filepath.Join("rules_query_targets")
Expand Down Expand Up @@ -463,13 +433,8 @@ func TestRule(t *testing.T) {
testutil.Ok(t, r.WaitSumMetrics(e2e.Equals(1), "thanos_ruler_alertmanagers_dns_provider_results"))
})

t.Run("reload works", func(t *testing.T) {
// Add a new rule via /-/reload.
// TODO(GiedriusS): add a test for reloading via SIGHUP. Need to extend e2e framework to expose PIDs.

createRuleFile(t, fmt.Sprintf("%s/newrule.yaml", rulesPath), testAlertRuleAddedLaterWebHandler)
reloadRulesHTTP(t, ctx, r.HTTPEndpoint())
})
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute)
defer cancel()

queryAndAssertSeries(t, ctx, q.HTTPEndpoint(), "ALERTS", promclient.QueryOptions{
Deduplicate: false,
Expand All @@ -481,13 +446,6 @@ func TestRule(t *testing.T) {
"alertstate": "firing",
"replica": "1",
},
{
"__name__": "ALERTS",
"severity": "page",
"alertname": "TestAlert_HasBeenLoadedViaWebHandler",
"alertstate": "firing",
"replica": "1",
},
{
"__name__": "ALERTS",
"severity": "page",
Expand All @@ -503,11 +461,6 @@ func TestRule(t *testing.T) {
"alertname": "TestAlert_AbortOnPartialResponse",
"replica": "1",
},
{
"severity": "page",
"alertname": "TestAlert_HasBeenLoadedViaWebHandler",
"replica": "1",
},
{
"severity": "page",
"alertname": "TestAlert_WarnOnPartialResponse",
Expand Down
2 changes: 1 addition & 1 deletion tutorials/katacoda/thanos/1-globalview/courseBase.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash

docker pull quay.io/prometheus/prometheus:v2.16.0
docker pull quay.io/thanos/thanos:v0.12.2
docker pull quay.io/thanos/thanos:v0.12.1
8 changes: 4 additions & 4 deletions tutorials/katacoda/thanos/1-globalview/step2.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ component and can be invoked in a single command.
Let's take a look at all the Thanos commands:

```
docker run --rm quay.io/thanos/thanos:v0.12.2 --help
docker run --rm quay.io/thanos/thanos:v0.12.1 --help
```{{execute}}
You should see multiple commands that solves different purposes.
Expand Down Expand Up @@ -53,7 +53,7 @@ docker run -d --net=host --rm \
-v $(pwd)/prometheus0_eu1.yml:/etc/prometheus/prometheus.yml \
--name prometheus-0-sidecar-eu1 \
-u root \
quay.io/thanos/thanos:v0.12.2 \
quay.io/thanos/thanos:v0.12.1 \
sidecar \
--http-address 0.0.0.0:19090 \
--grpc-address 0.0.0.0:19190 \
Expand All @@ -68,7 +68,7 @@ docker run -d --net=host --rm \
-v $(pwd)/prometheus0_us1.yml:/etc/prometheus/prometheus.yml \
--name prometheus-0-sidecar-us1 \
-u root \
quay.io/thanos/thanos:v0.12.2 \
quay.io/thanos/thanos:v0.12.1 \
sidecar \
--http-address 0.0.0.0:19091 \
--grpc-address 0.0.0.0:19191 \
Expand All @@ -81,7 +81,7 @@ docker run -d --net=host --rm \
-v $(pwd)/prometheus1_us1.yml:/etc/prometheus/prometheus.yml \
--name prometheus-1-sidecar-us1 \
-u root \
quay.io/thanos/thanos:v0.12.2 \
quay.io/thanos/thanos:v0.12.1 \
sidecar \
--http-address 0.0.0.0:19092 \
--grpc-address 0.0.0.0:19192 \
Expand Down
2 changes: 1 addition & 1 deletion tutorials/katacoda/thanos/1-globalview/step3.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Click below snippet to start the Querier.
```
docker run -d --net=host --rm \
--name querier \
quay.io/thanos/thanos:v0.12.2 \
quay.io/thanos/thanos:v0.12.1 \
query \
--http-address 0.0.0.0:29090 \
--query.replica-label replica \
Expand Down

0 comments on commit 2c61a47

Please sign in to comment.