From 18137c6f65bedb03c86a0e955085e71f70df8630 Mon Sep 17 00:00:00 2001 From: Thomas Jackson Date: Wed, 10 Nov 2021 09:16:48 -0800 Subject: [PATCH] Update prom fork to fix parenexpr serialization Fixes #469 --- go.mod | 2 +- go.sum | 4 ++-- .../prometheus/prometheus/promql/engine.go | 17 +++++++++-------- .../prometheus/prometheus/promql/functions.go | 4 +++- vendor/modules.txt | 2 +- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index b398d72e3..01db8e97c 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( k8s.io/klog v1.0.0 ) -replace github.com/prometheus/prometheus => github.com/jacksontj/prometheus v1.8.1-0.20211101202829-02ea5c0e357f +replace github.com/prometheus/prometheus => github.com/jacksontj/prometheus v1.8.1-0.20211110171435-7f3ca7a64301 replace github.com/golang/glog => github.com/kubermatic/glog-gokit v0.0.0-20181129151237-8ab7e4c2d352 diff --git a/go.sum b/go.sum index eb29e6f4e..edcdf95cf 100644 --- a/go.sum +++ b/go.sum @@ -779,8 +779,8 @@ github.com/influxdata/roaring v0.4.13-0.20180809181101-fc520f41fab6/go.mod h1:bS github.com/influxdata/tdigest v0.0.2-0.20210216194612-fc98d27c9e8b/go.mod h1:Z0kXnxzbTC2qrx4NaIzYkE1k66+6oEDQTvL95hQFh5Y= github.com/influxdata/usage-client v0.0.0-20160829180054-6d3895376368/go.mod h1:Wbbw6tYNvwa5dlB6304Sd+82Z3f7PmVZHVKU637d4po= github.com/j-keck/arping v0.0.0-20160618110441-2cf9dc699c56/go.mod h1:ymszkNOg6tORTn+6F6j+Jc8TOr5osrynvN6ivFWZ2GA= -github.com/jacksontj/prometheus v1.8.1-0.20211101202829-02ea5c0e357f h1:GGdZ3ju6hny96GqIeFXEa/uDkFNTM6znW7eNwN+rN1c= -github.com/jacksontj/prometheus v1.8.1-0.20211101202829-02ea5c0e357f/go.mod h1:02eURgmH1YsgJ2TtWNUGMQMCnLxmtHH9nOgvYxIjGAo= +github.com/jacksontj/prometheus v1.8.1-0.20211110171435-7f3ca7a64301 h1:UwG9izR17qk2snZyBuUo/sd+w/9f+NhYE41pIMBgDGw= +github.com/jacksontj/prometheus v1.8.1-0.20211110171435-7f3ca7a64301/go.mod h1:02eURgmH1YsgJ2TtWNUGMQMCnLxmtHH9nOgvYxIjGAo= github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc= github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= diff --git a/vendor/github.com/prometheus/prometheus/promql/engine.go b/vendor/github.com/prometheus/prometheus/promql/engine.go index c2f7b2883..bdc286c6d 100644 --- a/vendor/github.com/prometheus/prometheus/promql/engine.go +++ b/vendor/github.com/prometheus/prometheus/promql/engine.go @@ -1241,7 +1241,9 @@ func (ev *evaluator) eval(expr parser.Expr) (parser.Value, storage.Warnings) { } unwrapParenExpr(&e.Param) - if s, ok := unwrapStepInvariantExpr(e.Param).(*parser.StringLiteral); ok { + param := unwrapStepInvariantExpr(e.Param) + unwrapParenExpr(¶m) + if s, ok := param.(*parser.StringLiteral); ok { return ev.rangeEval(initSeries, func(v []parser.Value, sh [][]EvalSeriesHelper, enh *EvalNodeHelper) (Vector, storage.Warnings) { return ev.aggregation(e.Op, sortedGrouping, e.Without, s.Val, v[0].(Vector), sh[0], enh), nil }, e.Expr) @@ -1263,6 +1265,7 @@ func (ev *evaluator) eval(expr parser.Expr) (parser.Value, storage.Warnings) { // a vector selector. unwrapParenExpr(&e.Args[0]) arg := unwrapStepInvariantExpr(e.Args[0]) + unwrapParenExpr(&arg) vs, ok := arg.(*parser.VectorSelector) if ok { return ev.rangeEval(nil, func(v []parser.Value, _ [][]EvalSeriesHelper, enh *EvalNodeHelper) (Vector, storage.Warnings) { @@ -1286,6 +1289,7 @@ func (ev *evaluator) eval(expr parser.Expr) (parser.Value, storage.Warnings) { for i := range e.Args { unwrapParenExpr(&e.Args[i]) a := unwrapStepInvariantExpr(e.Args[i]) + unwrapParenExpr(&a) if _, ok := a.(*parser.MatrixSelector); ok { matrixArgIndex = i matrixArg = true @@ -1328,7 +1332,10 @@ func (ev *evaluator) eval(expr parser.Expr) (parser.Value, storage.Warnings) { } } - sel := unwrapStepInvariantExpr(e.Args[matrixArgIndex]).(*parser.MatrixSelector) + unwrapParenExpr(&e.Args[matrixArgIndex]) + arg := unwrapStepInvariantExpr(e.Args[matrixArgIndex]) + unwrapParenExpr(&arg) + sel := arg.(*parser.MatrixSelector) selVS := sel.VectorSelector.(*parser.VectorSelector) ws, err := checkAndExpandSeriesSet(ev.ctx, sel) @@ -2570,12 +2577,6 @@ func preprocessExprHelper(expr parser.Expr, start, end time.Time) bool { } func newStepInvariantExpr(expr parser.Expr) parser.Expr { - if e, ok := expr.(*parser.ParenExpr); ok { - // Wrapping the inside of () makes it easy to unwrap the paren later. - // But this effectively unwraps the paren. - return newStepInvariantExpr(e.Expr) - - } return &parser.StepInvariantExpr{Expr: expr} } diff --git a/vendor/github.com/prometheus/prometheus/promql/functions.go b/vendor/github.com/prometheus/prometheus/promql/functions.go index d72b4caf6..cdc58c5d1 100644 --- a/vendor/github.com/prometheus/prometheus/promql/functions.go +++ b/vendor/github.com/prometheus/prometheus/promql/functions.go @@ -1092,5 +1092,7 @@ func createLabelsForAbsentFunction(expr parser.Expr) labels.Labels { } func stringFromArg(e parser.Expr) string { - return unwrapStepInvariantExpr(e).(*parser.StringLiteral).Val + tmp := unwrapStepInvariantExpr(e) // Unwrap StepInvariant + unwrapParenExpr(&tmp) // Optionally unwrap ParenExpr + return tmp.(*parser.StringLiteral).Val } diff --git a/vendor/modules.txt b/vendor/modules.txt index 8c2d3cf91..323af57d9 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -330,7 +330,7 @@ github.com/prometheus/exporter-toolkit/web github.com/prometheus/procfs github.com/prometheus/procfs/internal/fs github.com/prometheus/procfs/internal/util -# github.com/prometheus/prometheus v1.8.2-0.20210707132820-dc8f50559534 => github.com/jacksontj/prometheus v1.8.1-0.20211101202829-02ea5c0e357f +# github.com/prometheus/prometheus v1.8.2-0.20210707132820-dc8f50559534 => github.com/jacksontj/prometheus v1.8.1-0.20211110171435-7f3ca7a64301 github.com/prometheus/prometheus/config github.com/prometheus/prometheus/discovery github.com/prometheus/prometheus/discovery/aws