From 54086663878c479eb3dc8968c0d3214119ee3300 Mon Sep 17 00:00:00 2001 From: beorn7 Date: Sat, 28 May 2016 19:45:35 +0200 Subject: [PATCH 1/2] Correctly stringify GROUP_x modifiers without labels Since rule evaluations work via String(), this fixes evaluation of rules containing GROUP_x modifiers without labels. This change is the minimal bugfix (so that we can release a fixed version without risk). It does not intend to implement any additional features (like allowing `GROUP_LEFT()` or `ON()` or even `ON` - see discussion in https://github.com/prometheus/prometheus/issues/1597 ). --- promql/printer.go | 15 ++++++++++----- promql/printer_test.go | 9 +++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/promql/printer.go b/promql/printer.go index 82ac53812f..d8b8a58c74 100644 --- a/promql/printer.go +++ b/promql/printer.go @@ -165,11 +165,16 @@ func (node *BinaryExpr) String() string { } else { matching = fmt.Sprintf(" ON(%s)", vm.MatchingLabels) } - if vm.Card == CardManyToOne { - matching += fmt.Sprintf(" GROUP_LEFT(%s)", vm.Include) - } - if vm.Card == CardOneToMany { - matching += fmt.Sprintf(" GROUP_RIGHT(%s)", vm.Include) + if vm.Card == CardManyToOne || vm.Card == CardOneToMany { + matching += " GROUP_" + if vm.Card == CardManyToOne { + matching += "LEFT" + } else { + matching += "RIGHT" + } + if len(vm.Include) > 0 { + matching += fmt.Sprintf("(%s)", vm.Include) + } } } return fmt.Sprintf("%s %s%s%s %s", node.LHS, node.Op, returnBool, matching, node.RHS) diff --git a/promql/printer_test.go b/promql/printer_test.go index e17774ac8c..c02e26ba60 100644 --- a/promql/printer_test.go +++ b/promql/printer_test.go @@ -39,6 +39,15 @@ func TestExprString(t *testing.T) { { in: `a - ON(b) c`, }, + { + in: `a - ON(b) GROUP_LEFT(x) c`, + }, + { + in: `a - ON(b) GROUP_LEFT(x, y) c`, + }, + { + in: `a - ON(b) GROUP_LEFT c`, + }, { in: `a - IGNORING(b) c`, }, From 592f02925ee131e821be3dab0680e412ac644f44 Mon Sep 17 00:00:00 2001 From: beorn7 Date: Sun, 29 May 2016 18:44:40 +0200 Subject: [PATCH 2/2] Cut 0.19.2 Note that this will be merged into the release-0.19 branch and only includes bug fixes, not other recent commits. This is low-risk and contains critical bug fixes and should therefore be released ASAP. --- CHANGELOG.md | 6 ++++++ VERSION | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13434b7967..c2edb1a774 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.19.2 / 2016-05-29 + +* [BUGFIX] Correctly handle `GROUP_LEFT` and `GROUP_RIGHT` without labels in + string representation of expressions and in rules. +* [BUGFIX] Use `-web.external-url` for new status endpoints. + ## 0.19.1 / 2016-05-25 * [BUGFIX] Handle service discovery panic affecting Kubernetes SD diff --git a/VERSION b/VERSION index 41915c7994..61e6e92d91 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.19.1 +0.19.2