Skip to content

Commit bddbb44

Browse files
committed
fix breaking changes
Signed-off-by: alanprot <alanprot@gmail.com>
1 parent 1f43751 commit bddbb44

9 files changed

+16
-21
lines changed

pkg/api/handlers.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package api
33
import (
44
"context"
55
"encoding/json"
6+
"github.com/prometheus/prometheus/promql"
67
"html/template"
78
"net/http"
89
"path"
@@ -159,7 +160,7 @@ func NewQuerierHandler(
159160
cfg Config,
160161
queryable storage.SampleAndChunkQueryable,
161162
exemplarQueryable storage.ExemplarQueryable,
162-
engine v1.QueryEngine,
163+
engine promql.QueryEngine,
163164
distributor Distributor,
164165
reg prometheus.Registerer,
165166
logger log.Logger,

pkg/cortex/cortex.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"context"
66
"flag"
77
"fmt"
8+
"github.com/prometheus/prometheus/promql"
89
"net/http"
910
"os"
1011
"reflect"
@@ -15,7 +16,6 @@ import (
1516
"github.com/pkg/errors"
1617
"github.com/prometheus/client_golang/prometheus"
1718
prom_storage "github.com/prometheus/prometheus/storage"
18-
v1 "github.com/prometheus/prometheus/web/api/v1"
1919
"github.com/weaveworks/common/server"
2020
"github.com/weaveworks/common/signals"
2121
"google.golang.org/grpc/health/grpc_health_v1"
@@ -303,7 +303,7 @@ type Cortex struct {
303303
RuntimeConfig *runtimeconfig.Manager
304304
QuerierQueryable prom_storage.SampleAndChunkQueryable
305305
ExemplarQueryable prom_storage.ExemplarQueryable
306-
QuerierEngine v1.QueryEngine
306+
QuerierEngine promql.QueryEngine
307307
QueryFrontendTripperware tripperware.Tripperware
308308

309309
Ruler *ruler.Ruler

pkg/cortex/modules.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
"github.com/prometheus/prometheus/promql"
1616
"github.com/prometheus/prometheus/rules"
1717
prom_storage "github.com/prometheus/prometheus/storage"
18-
v1 "github.com/prometheus/prometheus/web/api/v1"
1918
"github.com/thanos-io/objstore"
2019
"github.com/thanos-io/promql-engine/engine"
2120
"github.com/thanos-io/promql-engine/logicalplan"
@@ -556,7 +555,7 @@ func (t *Cortex) initRuler() (serv services.Service, err error) {
556555
if t.Cfg.ExternalPusher != nil && t.Cfg.ExternalQueryable != nil {
557556
rulerRegisterer := prometheus.WrapRegistererWith(prometheus.Labels{"engine": "ruler"}, prometheus.DefaultRegisterer)
558557

559-
var queryEngine v1.QueryEngine
558+
var queryEngine promql.QueryEngine
560559
opts := promql.EngineOpts{
561560
Logger: util_log.Logger,
562561
Reg: rulerRegisterer,

pkg/querier/blocks_store_queryable_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"github.com/prometheus/prometheus/promql"
2020
"github.com/prometheus/prometheus/storage"
2121
"github.com/prometheus/prometheus/tsdb/chunkenc"
22-
v1 "github.com/prometheus/prometheus/web/api/v1"
2322
"github.com/stretchr/testify/assert"
2423
"github.com/stretchr/testify/mock"
2524
"github.com/stretchr/testify/require"
@@ -1512,7 +1511,7 @@ func TestBlocksStoreQuerier_PromQLExecution(t *testing.T) {
15121511
}
15131512
for _, thanosEngine := range []bool{false, true} {
15141513
t.Run(fmt.Sprintf("thanos engine enabled=%t", thanosEngine), func(t *testing.T) {
1515-
var queryEngine v1.QueryEngine
1514+
var queryEngine promql.QueryEngine
15161515
if thanosEngine {
15171516
queryEngine = engine.New(engine.Opts{
15181517
EngineOpts: opts,

pkg/querier/chunk_store_queryable_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"github.com/prometheus/common/model"
1212
"github.com/prometheus/prometheus/model/labels"
1313
"github.com/prometheus/prometheus/promql"
14-
v1 "github.com/prometheus/prometheus/web/api/v1"
1514
"github.com/stretchr/testify/require"
1615
"github.com/thanos-io/promql-engine/engine"
1716
"github.com/thanos-io/promql-engine/logicalplan"
@@ -35,7 +34,7 @@ func TestChunkQueryable(t *testing.T) {
3534
for _, encoding := range encodings {
3635
for _, query := range queries {
3736
t.Run(fmt.Sprintf("%s/%s/%s/ thanos engine enabled = %t", testcase.name, encoding.name, query.query, thanosEngine), func(t *testing.T) {
38-
var queryEngine v1.QueryEngine
37+
var queryEngine promql.QueryEngine
3938
if thanosEngine {
4039
queryEngine = engine.New(engine.Opts{
4140
EngineOpts: opts,

pkg/querier/error_translate_queryable_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func TestApiStatusCodes(t *testing.T) {
136136
}
137137
}
138138

139-
func createPrometheusAPI(q storage.SampleAndChunkQueryable, engine v1.QueryEngine) *route.Router {
139+
func createPrometheusAPI(q storage.SampleAndChunkQueryable, engine promql.QueryEngine) *route.Router {
140140
api := v1.NewAPI(
141141
engine,
142142
q,

pkg/querier/querier.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"github.com/prometheus/prometheus/promql"
1919
"github.com/prometheus/prometheus/storage"
2020
"github.com/prometheus/prometheus/util/annotations"
21-
v1 "github.com/prometheus/prometheus/web/api/v1"
2221
"github.com/thanos-io/promql-engine/engine"
2322
"github.com/thanos-io/promql-engine/logicalplan"
2423
"github.com/thanos-io/thanos/pkg/strutil"
@@ -162,7 +161,7 @@ func getChunksIteratorFunction(cfg Config) chunkIteratorFunc {
162161
}
163162

164163
// New builds a queryable and promql engine.
165-
func New(cfg Config, limits *validation.Overrides, distributor Distributor, stores []QueryableWithFilter, reg prometheus.Registerer, logger log.Logger) (storage.SampleAndChunkQueryable, storage.ExemplarQueryable, v1.QueryEngine) {
164+
func New(cfg Config, limits *validation.Overrides, distributor Distributor, stores []QueryableWithFilter, reg prometheus.Registerer, logger log.Logger) (storage.SampleAndChunkQueryable, storage.ExemplarQueryable, promql.QueryEngine) {
166165
iteratorFunc := getChunksIteratorFunction(cfg)
167166

168167
distributorQueryable := newDistributorQueryable(distributor, cfg.IngesterMetadataStreaming, iteratorFunc, cfg.QueryIngestersWithin, cfg.QueryStoreForLabels)
@@ -193,7 +192,7 @@ func New(cfg Config, limits *validation.Overrides, distributor Distributor, stor
193192
})
194193
maxConcurrentMetric.Set(float64(cfg.MaxConcurrent))
195194

196-
var queryEngine v1.QueryEngine
195+
var queryEngine promql.QueryEngine
197196
opts := promql.EngineOpts{
198197
Logger: logger,
199198
Reg: reg,

pkg/querier/querier_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"github.com/prometheus/prometheus/storage"
1919
"github.com/prometheus/prometheus/tsdb"
2020
"github.com/prometheus/prometheus/util/annotations"
21-
v1 "github.com/prometheus/prometheus/web/api/v1"
2221
"github.com/stretchr/testify/assert"
2322
"github.com/stretchr/testify/mock"
2423
"github.com/stretchr/testify/require"
@@ -253,7 +252,7 @@ func TestShouldSortSeriesIfQueryingMultipleQueryables(t *testing.T) {
253252
MaxSamples: 1e6,
254253
Timeout: 1 * time.Minute,
255254
}
256-
var queryEngine v1.QueryEngine
255+
var queryEngine promql.QueryEngine
257256
if thanosEngine {
258257
queryEngine = engine.New(engine.Opts{
259258
EngineOpts: opts,
@@ -499,7 +498,7 @@ func TestQuerier(t *testing.T) {
499498
for _, iterators := range []bool{false, true} {
500499
iterators := iterators
501500
t.Run(fmt.Sprintf("%s/%s/iterators=%t", query.query, encoding.name, iterators), func(t *testing.T) {
502-
var queryEngine v1.QueryEngine
501+
var queryEngine promql.QueryEngine
503502
if thanosEngine {
504503
queryEngine = engine.New(engine.Opts{
505504
EngineOpts: opts,
@@ -648,7 +647,7 @@ func TestNoHistoricalQueryToIngester(t *testing.T) {
648647
for _, c := range testCases {
649648
cfg.QueryIngestersWithin = c.queryIngestersWithin
650649
t.Run(fmt.Sprintf("thanosEngine=%t,queryIngestersWithin=%v, test=%s", thanosEngine, c.queryIngestersWithin, c.name), func(t *testing.T) {
651-
var queryEngine v1.QueryEngine
650+
var queryEngine promql.QueryEngine
652651
if thanosEngine {
653652
queryEngine = engine.New(engine.Opts{
654653
EngineOpts: opts,
@@ -1223,7 +1222,7 @@ func mockDistibutorFor(t *testing.T, cs mockChunkStore, through model.Time) *Moc
12231222
return result
12241223
}
12251224

1226-
func testRangeQuery(t testing.TB, queryable storage.Queryable, queryEngine v1.QueryEngine, end model.Time, q query) *promql.Result {
1225+
func testRangeQuery(t testing.TB, queryable storage.Queryable, queryEngine promql.QueryEngine, end model.Time, q query) *promql.Result {
12271226
from, through, step := time.Unix(0, 0), end.Time(), q.step
12281227
ctx := user.InjectOrgID(context.Background(), "0")
12291228
query, err := queryEngine.NewRangeQuery(ctx, queryable, nil, q.query, from, through, step)

pkg/ruler/compat.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"github.com/prometheus/prometheus/promql/parser"
2020
"github.com/prometheus/prometheus/rules"
2121
"github.com/prometheus/prometheus/storage"
22-
v1 "github.com/prometheus/prometheus/web/api/v1"
2322
"github.com/weaveworks/common/httpgrpc"
2423
"github.com/weaveworks/common/user"
2524

@@ -158,7 +157,7 @@ type RulesLimits interface {
158157
// EngineQueryFunc returns a new engine query function by passing an altered timestamp.
159158
// Modified from Prometheus rules.EngineQueryFunc
160159
// https://github.com/prometheus/prometheus/blob/v2.39.1/rules/manager.go#L189.
161-
func EngineQueryFunc(engine v1.QueryEngine, q storage.Queryable, overrides RulesLimits, userID string, lookbackDelta time.Duration) rules.QueryFunc {
160+
func EngineQueryFunc(engine promql.QueryEngine, q storage.Queryable, overrides RulesLimits, userID string, lookbackDelta time.Duration) rules.QueryFunc {
162161
return func(ctx context.Context, qs string, t time.Time) (promql.Vector, error) {
163162
// Enforce the max query length.
164163
maxQueryLength := overrides.MaxQueryLength(userID)
@@ -299,7 +298,7 @@ type RulesManager interface {
299298
// ManagerFactory is a function that creates new RulesManager for given user and notifier.Manager.
300299
type ManagerFactory func(ctx context.Context, userID string, notifier *notifier.Manager, logger log.Logger, reg prometheus.Registerer) RulesManager
301300

302-
func DefaultTenantManagerFactory(cfg Config, p Pusher, q storage.Queryable, engine v1.QueryEngine, overrides RulesLimits, evalMetrics *RuleEvalMetrics, reg prometheus.Registerer) ManagerFactory {
301+
func DefaultTenantManagerFactory(cfg Config, p Pusher, q storage.Queryable, engine promql.QueryEngine, overrides RulesLimits, evalMetrics *RuleEvalMetrics, reg prometheus.Registerer) ManagerFactory {
303302
// Wrap errors returned by Queryable to our wrapper, so that we can distinguish between those errors
304303
// and errors returned by PromQL engine. Errors from Queryable can be either caused by user (limits) or internal errors.
305304
// Errors from PromQL are always "user" errors.

0 commit comments

Comments
 (0)