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

Release 0.22 #4457

Merged
merged 2 commits into from
Jul 20, 2021
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re
- [#4340](https://github.com/thanos-io/thanos/pull/4340) UI: now displays the duration and all annotations of an alert in the alerts page.
- [#4348](https://github.com/thanos-io/thanos/pull/4348) Fixed parsing of the port in the log middleware.
- [#4417](https://github.com/thanos-io/thanos/pull/4417) UI: fixed the night mode in Bucket UI.
- [#4442](https://github.com/thanos-io/thanos/pull/4442) Ruler: fix SIGHUP reload signal not working.

### Changed

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.22.0-rc.0
0.22.0
5 changes: 3 additions & 2 deletions cmd/thanos/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ type ruleConfig struct {
ruleFiles []string
objStoreConfig *extflag.PathOrContent
dataDir string
reloadSignal <-chan struct{}
lset labels.Labels
}

Expand Down Expand Up @@ -195,6 +194,7 @@ func registerRule(app *extkingpin.App) {
tracer,
comp,
*conf,
reload,
getFlagsMap(cmd.Flags()),
httpLogOpts,
grpcLogOpts,
Expand Down Expand Up @@ -257,6 +257,7 @@ func runRule(
tracer opentracing.Tracer,
comp component.Component,
conf ruleConfig,
reloadSignal <-chan struct{},
flagsMap map[string]string,
httpLogOpts []logging.Option,
grpcLogOpts []grpc_logging.Option,
Expand Down Expand Up @@ -483,7 +484,7 @@ func runRule(
}
for {
select {
case <-conf.reloadSignal:
case <-reloadSignal:
if err := reloadRules(logger, conf.ruleFiles, ruleMgr, conf.evalInterval, metrics); err != nil {
level.Error(logger).Log("msg", "reload rules by sighup failed", "err", err)
}
Expand Down
71 changes: 64 additions & 7 deletions test/e2e/rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,39 @@ groups:
severity: page
annotations:
summary: "I always complain and I have been loaded via /-/reload."
`
testAlertRuleAddedLaterSignal = `
groups:
- name: example
interval: 1s
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 sighup signal."
- name: example2
interval: 1s
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 sighup signal."
`
)

type rulesResp struct {
Status string
Data *rulespb.RuleGroups
}

func createRuleFile(t *testing.T, path, content string) {
t.Helper()
err := ioutil.WriteFile(path, []byte(content), 0666)
Expand All @@ -97,6 +127,30 @@ func reloadRulesHTTP(t *testing.T, ctx context.Context, endpoint string) {
testutil.Equals(t, 200, resp.StatusCode)
}

func reloadRulesSignal(t *testing.T, r *e2ethanos.Service) {
c := e2e.NewCommand("kill", "-1", "1")
_, _, err := r.Exec(c)
testutil.Ok(t, err)
}

func checkReloadSuccessful(t *testing.T, ctx context.Context, endpoint string, expectedRulegroupCount int) {
req, err := http.NewRequestWithContext(ctx, "GET", "http://"+endpoint+"/api/v1/rules", 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)

body, _ := ioutil.ReadAll(resp.Body)
testutil.Ok(t, resp.Body.Close())

var data = rulesResp{}

testutil.Ok(t, json.Unmarshal(body, &data))
testutil.Equals(t, "success", data.Status)

testutil.Assert(t, len(data.Data.Groups) == expectedRulegroupCount, fmt.Sprintf("expected there to be %d rule groups", expectedRulegroupCount))
}

func rulegroupCorrectData(t *testing.T, ctx context.Context, endpoint string) {
req, err := http.NewRequestWithContext(ctx, "GET", "http://"+endpoint+"/api/v1/rules", ioutil.NopCloser(bytes.NewReader(nil)))
testutil.Ok(t, err)
Expand All @@ -108,10 +162,7 @@ func rulegroupCorrectData(t *testing.T, ctx context.Context, endpoint string) {
body, err := ioutil.ReadAll(resp.Body)
testutil.Ok(t, err)

var data struct {
Status string
Data *rulespb.RuleGroups
}
var data = rulesResp{}

testutil.Ok(t, json.Unmarshal(body, &data))
testutil.Equals(t, "success", data.Status)
Expand Down Expand Up @@ -317,12 +368,18 @@ func TestRule(t *testing.T) {
rulegroupCorrectData(t, ctx, r.HTTPEndpoint())
})

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.
t.Run("signal reload works", func(t *testing.T) {
// Add a new rule via sending sighup
createRuleFile(t, fmt.Sprintf("%s/newrule.yaml", rulesPath), testAlertRuleAddedLaterSignal)
reloadRulesSignal(t, r)
checkReloadSuccessful(t, ctx, r.HTTPEndpoint(), 4)
})

t.Run("http reload works", func(t *testing.T) {
// Add a new rule via /-/reload.
createRuleFile(t, fmt.Sprintf("%s/newrule.yaml", rulesPath), testAlertRuleAddedLaterWebHandler)
reloadRulesHTTP(t, ctx, r.HTTPEndpoint())
checkReloadSuccessful(t, ctx, r.HTTPEndpoint(), 3)
})

queryAndAssertSeries(t, ctx, q.HTTPEndpoint(), "ALERTS", promclient.QueryOptions{
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.22.0-rc.0
docker pull quay.io/thanos/thanos:v0.22.0
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.22.0-rc.0 --help
docker run --rm quay.io/thanos/thanos:v0.22.0 --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.22.0-rc.0 \
quay.io/thanos/thanos:v0.22.0 \
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.22.0-rc.0 \
quay.io/thanos/thanos:v0.22.0 \
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.22.0-rc.0 \
quay.io/thanos/thanos:v0.22.0 \
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.22.0-rc.0 \
quay.io/thanos/thanos:v0.22.0 \
query \
--http-address 0.0.0.0:29090 \
--query.replica-label replica \
Expand Down
2 changes: 1 addition & 1 deletion tutorials/katacoda/thanos/2-lts/courseBase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

docker pull minio/minio:RELEASE.2019-01-31T00-31-19Z
docker pull quay.io/prometheus/prometheus:v2.20.0
docker pull quay.io/thanos/thanos:v0.22.0-rc.0
docker pull quay.io/thanos/thanos:v0.22.0
docker pull quay.io/thanos/thanosbench:v0.2.0-rc.1

mkdir /root/editor
4 changes: 2 additions & 2 deletions tutorials/katacoda/thanos/2-lts/step1.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Similar to previous course, let's setup global view querying with sidecar:
docker run -d --net=host --rm \
--name prometheus-0-eu1-sidecar \
-u root \
quay.io/thanos/thanos:v0.22.0-rc.0 \
quay.io/thanos/thanos:v0.22.0 \
sidecar \
--http-address 0.0.0.0:19090 \
--grpc-address 0.0.0.0:19190 \
Expand All @@ -130,7 +130,7 @@ so we will make sure we point the Querier to the gRPC endpoints of the sidecar:
```
docker run -d --net=host --rm \
--name querier \
quay.io/thanos/thanos:v0.22.0-rc.0 \
quay.io/thanos/thanos:v0.22.0 \
query \
--http-address 0.0.0.0:9091 \
--query.replica-label replica \
Expand Down
2 changes: 1 addition & 1 deletion tutorials/katacoda/thanos/2-lts/step2.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ docker run -d --net=host --rm \
-v /root/prom-eu1:/prometheus \
--name prometheus-0-eu1-sidecar \
-u root \
quay.io/thanos/thanos:v0.22.0-rc.0 \
quay.io/thanos/thanos:v0.22.0 \
sidecar \
--tsdb.path /prometheus \
--objstore.config-file /etc/thanos/minio-bucket.yaml \
Expand Down
6 changes: 3 additions & 3 deletions tutorials/katacoda/thanos/2-lts/step3.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ In this step, we will learn about Thanos Store Gateway and how to deploy it.

Let's take a look at all the Thanos commands:

```docker run --rm quay.io/thanos/thanos:v0.22.0-rc.0 --help```{{execute}}
```docker run --rm quay.io/thanos/thanos:v0.22.0 --help```{{execute}}

You should see multiple commands that solve different purposes, block storage based long-term storage for Prometheus.

Expand All @@ -32,7 +32,7 @@ You can read more about [Store](https://thanos.io/tip/components/store.md/) here
docker run -d --net=host --rm \
-v /root/editor/bucket_storage.yaml:/etc/thanos/minio-bucket.yaml \
--name store-gateway \
quay.io/thanos/thanos:v0.22.0-rc.0 \
quay.io/thanos/thanos:v0.22.0 \
store \
--objstore.config-file /etc/thanos/minio-bucket.yaml \
--http-address 0.0.0.0:19091 \
Expand All @@ -49,7 +49,7 @@ Currently querier does not know about store yet. Let's change it by adding Store
docker stop querier && \
docker run -d --net=host --rm \
--name querier \
quay.io/thanos/thanos:v0.22.0-rc.0 \
quay.io/thanos/thanos:v0.22.0 \
query \
--http-address 0.0.0.0:9091 \
--query.replica-label replica \
Expand Down
2 changes: 1 addition & 1 deletion tutorials/katacoda/thanos/2-lts/step4.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Click below snippet to start the Compactor.
docker run -d --net=host --rm \
-v /root/editor/bucket_storage.yaml:/etc/thanos/minio-bucket.yaml \
--name thanos-compact \
quay.io/thanos/thanos:v0.22.0-rc.0 \
quay.io/thanos/thanos:v0.22.0 \
compact \
--wait --wait-interval 30s \
--consistency-delay 0s \
Expand Down
2 changes: 1 addition & 1 deletion tutorials/katacoda/thanos/3-receiver/courseBase.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

docker pull quay.io/prometheus/prometheus:v2.27.0
docker pull quay.io/thanos/thanos:v0.22.0-rc.0
docker pull quay.io/thanos/thanos:v0.22.0

mkdir /root/editor
4 changes: 2 additions & 2 deletions tutorials/katacoda/thanos/3-receiver/step2.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ docker run -d --rm \
-v $(pwd)/receive-data:/receive/data \
--net=host \
--name receive \
quay.io/thanos/thanos:v0.22.0-rc.0 \
quay.io/thanos/thanos:v0.22.0 \
receive \
--tsdb.path "/receive/data" \
--grpc-address 127.0.0.1:10907 \
Expand Down Expand Up @@ -76,7 +76,7 @@ Next, let us run a `Thanos Query` instance:
docker run -d --rm \
--net=host \
--name query \
quay.io/thanos/thanos:v0.22.0-rc.0 \
quay.io/thanos/thanos:v0.22.0 \
query \
--http-address "0.0.0.0:39090" \
--store "127.0.0.1:10907"
Expand Down
2 changes: 1 addition & 1 deletion tutorials/katacoda/thanos/6-query-caching/courseBase.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash

docker pull quay.io/prometheus/prometheus:v2.22.2
docker pull quay.io/thanos/thanos:v0.22.0-rc.0
docker pull quay.io/thanos/thanos:v0.22.0
docker pull yannrobert/docker-nginx
4 changes: 2 additions & 2 deletions tutorials/katacoda/thanos/6-query-caching/step1.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ docker run -d --net=host --rm \
-v $(pwd)/prometheus"${i}".yml:/etc/prometheus/prometheus.yml \
--name prometheus-sidecar"${i}" \
-u root \
quay.io/thanos/thanos:v0.22.0-rc.0 \
quay.io/thanos/thanos:v0.22.0 \
sidecar \
--http-address=0.0.0.0:1909"${i}" \
--grpc-address=0.0.0.0:1919"${i}" \
Expand All @@ -129,7 +129,7 @@ And now, let's deploy Thanos Querier to have a global overview on our services.
```
docker run -d --net=host --rm \
--name querier \
quay.io/thanos/thanos:v0.22.0-rc.0 \
quay.io/thanos/thanos:v0.22.0 \
query \
--http-address 0.0.0.0:10912 \
--grpc-address 0.0.0.0:10901 \
Expand Down
2 changes: 1 addition & 1 deletion tutorials/katacoda/thanos/6-query-caching/step2.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ And deploy Query Frontend:
docker run -d --net=host --rm \
-v $(pwd)/frontend.yml:/etc/thanos/frontend.yml \
--name query-frontend \
quay.io/thanos/thanos:v0.22.0-rc.0 \
quay.io/thanos/thanos:v0.22.0 \
query-frontend \
--http-address 0.0.0.0:20902 \
--query-frontend.compress-responses \
Expand Down
2 changes: 1 addition & 1 deletion tutorials/katacoda/thanos/7-multi-tenancy/courseBase.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

docker pull quay.io/prometheus/prometheus:v2.20.0
docker pull quay.io/thanos/thanos:v0.22.0-rc.0
docker pull quay.io/thanos/thanos:v0.22.0
docker pull quay.io/thanos/prom-label-proxy:v0.3.0-rc.0-ext1
docker pull caddy:2.2.1

Expand Down
10 changes: 5 additions & 5 deletions tutorials/katacoda/thanos/7-multi-tenancy/step1.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ docker run -d --net=host --rm \
-v $(pwd)/editor/prometheus0_fruit.yml:/etc/prometheus/prometheus.yml \
--name prometheus-0-sidecar-fruit \
-u root \
quay.io/thanos/thanos:v0.22.0-rc.0 \
quay.io/thanos/thanos:v0.22.0 \
sidecar \
--http-address 0.0.0.0:19090 \
--grpc-address 0.0.0.0:19190 \
Expand Down Expand Up @@ -120,7 +120,7 @@ docker run -d --net=host --rm \
-v $(pwd)/editor/prometheus0_veggie.yml:/etc/prometheus/prometheus.yml \
--name prometheus-0-sidecar-veggie \
-u root \
quay.io/thanos/thanos:v0.22.0-rc.0 \
quay.io/thanos/thanos:v0.22.0 \
sidecar \
--http-address 0.0.0.0:19091 \
--grpc-address 0.0.0.0:19191 \
Expand Down Expand Up @@ -152,7 +152,7 @@ docker run -d --net=host --rm \
-v $(pwd)/editor/prometheus1_veggie.yml:/etc/prometheus/prometheus.yml \
--name prometheus-01-sidecar-veggie \
-u root \
quay.io/thanos/thanos:v0.22.0-rc.0 \
quay.io/thanos/thanos:v0.22.0 \
sidecar \
--http-address 0.0.0.0:19092 \
--grpc-address 0.0.0.0:19192 \
Expand All @@ -170,7 +170,7 @@ Fruit:
```
docker run -d --net=host --rm \
--name querier-fruit \
quay.io/thanos/thanos:v0.22.0-rc.0 \
quay.io/thanos/thanos:v0.22.0 \
query \
--http-address 0.0.0.0:29091 \
--grpc-address 0.0.0.0:29191 \
Expand All @@ -183,7 +183,7 @@ Veggie:
```
docker run -d --net=host --rm \
--name querier-veggie \
quay.io/thanos/thanos:v0.22.0-rc.0 \
quay.io/thanos/thanos:v0.22.0 \
query \
--http-address 0.0.0.0:29092 \
--grpc-address 0.0.0.0:29192 \
Expand Down
2 changes: 1 addition & 1 deletion tutorials/katacoda/thanos/7-multi-tenancy/step2.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ docker stop querier-fruit && docker stop querier-veggie
```
docker run -d --net=host --rm \
--name querier-multi \
quay.io/thanos/thanos:v0.22.0-rc.0 \
quay.io/thanos/thanos:v0.22.0 \
query \
--http-address 0.0.0.0:29090 \
--grpc-address 0.0.0.0:29190 \
Expand Down
Loading