Skip to content

Commit 73f8907

Browse files
committed
Updated TSDB with fixes.
Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>
1 parent b37482f commit 73f8907

File tree

6 files changed

+24
-18
lines changed

6 files changed

+24
-18
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ require (
7676
// See https://github.com/thanos-io/thanos/issues/1415
7777
replace (
7878
// Make sure Cortex is not forcing us to some other Prometheus version.
79-
// TODO: This points to https://github.com/prometheus/prometheus/pull/7069. Remove and point to master once merged.
80-
github.com/prometheus/prometheus => github.com/prometheus/prometheus v1.8.2-0.20200802085738-31929b83d50e
79+
// TODO: This points to https://github.com/prometheus/prometheus/pull/7069. Remove and point to master once it's merged.
80+
github.com/prometheus/prometheus => github.com/prometheus/prometheus v1.8.2-0.20200803103256-28c5cfaf0d41
8181
k8s.io/klog => k8s.io/klog v0.3.1
8282
k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30
8383
)

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -884,8 +884,8 @@ github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+Gx
884884
github.com/prometheus/procfs v0.0.11/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
885885
github.com/prometheus/procfs v0.1.3 h1:F0+tqvhOksq22sc6iCHF5WGlWjdwj92p0udFh1VFBS8=
886886
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
887-
github.com/prometheus/prometheus v1.8.2-0.20200802085738-31929b83d50e h1:g6GmYlaCAw5nM9RCQDpKnp3A4Wd9wYnMyp48o/V+JLg=
888-
github.com/prometheus/prometheus v1.8.2-0.20200802085738-31929b83d50e/go.mod h1:i1KZsZmyDTJRvnR7zE8z/u2v+tkpPjoiPpnWp6nwhr0=
887+
github.com/prometheus/prometheus v1.8.2-0.20200803103256-28c5cfaf0d41 h1:B8N7vJYp54bfHYlmzmPLhZ6UGX+JS/+gxO212qCauYQ=
888+
github.com/prometheus/prometheus v1.8.2-0.20200803103256-28c5cfaf0d41/go.mod h1:i1KZsZmyDTJRvnR7zE8z/u2v+tkpPjoiPpnWp6nwhr0=
889889
github.com/rafaeljusto/redigomock v0.0.0-20190202135759-257e089e14a1/go.mod h1:JaY6n2sDr+z2WTsXkOmNRUfDy6FN0L6Nk7x06ndm4tY=
890890
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
891891
github.com/retailnext/hllpp v1.0.1-0.20180308014038-101a6d2f8b52/go.mod h1:RDpi1RftBQPUCDRw6SmxeaREsAaRKnOclghuzp/WRzc=

pkg/rules/manager.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,10 @@ func NewManager(
144144
return m
145145
}
146146

147+
// Run is non blocking, in opposite to TSDB manager, which is blocking.
147148
func (m *Manager) Run() {
148149
for _, mgr := range m.mgrs {
149-
mgr.Run()
150+
go mgr.Run()
150151
}
151152
}
152153

@@ -155,8 +156,8 @@ func (m *Manager) Stop() {
155156
mgr.Stop()
156157
}
157158
}
158-
159159
func (m *Manager) protoRuleGroups() []*rulespb.RuleGroup {
160+
160161
rg := m.RuleGroups()
161162
res := make([]*rulespb.RuleGroup, 0, len(rg))
162163
for _, g := range rg {

pkg/rules/manager_test.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,14 @@ func (n nopAppender) Commit() error {
3737
func (n nopAppender) Rollback() error { return nil }
3838
func (n nopAppender) Appender() (storage.Appender, error) { return n, nil }
3939

40+
type nopQueryable struct{}
41+
42+
func (n nopQueryable) Querier(_ context.Context, _, _ int64) (storage.Querier, error) {
43+
return storage.NoopQuerier(), nil
44+
}
45+
4046
// Regression test against https://github.com/thanos-io/thanos/issues/1779.
41-
func TestRun(t *testing.T) {
47+
func TestRun_Subqueries(t *testing.T) {
4248
dir, err := ioutil.TempDir("", "test_rule_run")
4349
testutil.Ok(t, err)
4450
defer func() { testutil.Ok(t, os.RemoveAll(dir)) }()
@@ -65,6 +71,7 @@ groups:
6571
Logger: log.NewLogfmtLogger(os.Stderr),
6672
Context: context.Background(),
6773
Appendable: nopAppendable{},
74+
Queryable: nopQueryable{},
6875
},
6976
func(partialResponseStrategy storepb.PartialResponseStrategy) rules.QueryFunc {
7077
return func(ctx context.Context, q string, t time.Time) (vectors promql.Vector, e error) {
@@ -77,17 +84,16 @@ groups:
7784
},
7885
labels.FromStrings("replica", "1"),
7986
)
80-
testutil.Ok(t, thanosRuleMgr.Update(10*time.Second, []string{filepath.Join(dir, "rule.yaml")}))
87+
testutil.Ok(t, thanosRuleMgr.Update(1*time.Second, []string{filepath.Join(dir, "rule.yaml")}))
8188

8289
thanosRuleMgr.Run()
8390
defer thanosRuleMgr.Stop()
8491

8592
select {
86-
case <-time.After(2 * time.Minute):
93+
case <-time.After(1 * time.Minute):
8794
t.Fatal("timeout while waiting on rule manager query evaluation")
8895
case <-queryDone:
8996
}
90-
9197
testutil.Equals(t, "rate(some_metric[1h:5m] offset 1d)", query)
9298
}
9399

@@ -160,7 +166,8 @@ groups:
160166
nil,
161167
dir,
162168
rules.ManagerOptions{
163-
Logger: log.NewLogfmtLogger(os.Stderr),
169+
Logger: log.NewLogfmtLogger(os.Stderr),
170+
Queryable: nopQueryable{},
164171
},
165172
func(partialResponseStrategy storepb.PartialResponseStrategy) rules.QueryFunc {
166173
return func(ctx context.Context, q string, t time.Time) (promql.Vector, error) {
@@ -287,7 +294,8 @@ func TestManager_Rules(t *testing.T) {
287294
nil,
288295
dir,
289296
rules.ManagerOptions{
290-
Logger: log.NewLogfmtLogger(os.Stderr),
297+
Logger: log.NewLogfmtLogger(os.Stderr),
298+
Queryable: nopQueryable{},
291299
},
292300
func(partialResponseStrategy storepb.PartialResponseStrategy) rules.QueryFunc {
293301
return func(ctx context.Context, q string, t time.Time) (promql.Vector, error) {

pkg/store/storepb/testutil/series.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func CreateHeadWithSeries(t testing.TB, j int, opts HeadGenOptions) (*tsdb.Head,
6969
testutil.Ok(t, err)
7070
}
7171

72-
h, err := tsdb.NewHead(nil, nil, w, 10000000, tsdbDir, nil, tsdb.DefaultStripeSize, nil)
72+
h, err := tsdb.NewHead(nil, nil, w, tsdb.DefaultBlockDuration, tsdbDir, nil, tsdb.DefaultStripeSize, nil)
7373
testutil.Ok(t, err)
7474

7575
app := h.Appender()

pkg/store/tsdb_test.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,16 +196,14 @@ func TestTSDBStore_LabelNames(t *testing.T) {
196196
}
197197

198198
tsdbStore := NewTSDBStore(nil, nil, db, component.Rule, labels.FromStrings("region", "eu-west"))
199-
200199
for _, tc := range []struct {
201200
title string
202201
labels []string
203202
expectedNames []string
204203
}{
205204
{
206-
title: "no label in tsdb",
207-
labels: []string{},
208-
expectedNames: []string{},
205+
title: "no label in tsdb",
206+
labels: []string{},
209207
},
210208
{
211209
title: "add one label",
@@ -251,7 +249,6 @@ func TestTSDBStore_LabelValues(t *testing.T) {
251249
}
252250

253251
tsdbStore := NewTSDBStore(nil, nil, db, component.Rule, labels.FromStrings("region", "eu-west"))
254-
255252
for _, tc := range []struct {
256253
title string
257254
addedLabels []string

0 commit comments

Comments
 (0)