From de49748bef0d39a04cd8e0f63a55775b6d20d2b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gy=C3=B6rgy=20Krajcsovits?= Date: Wed, 15 May 2024 19:20:16 +0200 Subject: [PATCH] Remove label selector string quoting from mimir-prometheus MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reverting https://github.com/prometheus/prometheus/pull/14068 because it is causing unforseen complications with LBAC in GEM. Signed-off-by: György Krajcsovits --- go.mod | 2 +- go.sum | 4 +-- .../prometheus/model/labels/matcher.go | 27 ++----------------- vendor/modules.txt | 4 +-- 4 files changed, 7 insertions(+), 30 deletions(-) diff --git a/go.mod b/go.mod index 96af6459b83..63b82fb2861 100644 --- a/go.mod +++ b/go.mod @@ -257,7 +257,7 @@ require ( ) // Using a fork of Prometheus with Mimir-specific changes. -replace github.com/prometheus/prometheus => github.com/grafana/mimir-prometheus v0.0.0-20240515135245-e5b85c151ba8 +replace github.com/prometheus/prometheus => github.com/grafana/mimir-prometheus v0.0.0-20240515171138-a3ac8a4266ca // Replace memberlist with our fork which includes some fixes that haven't been // merged upstream yet: diff --git a/go.sum b/go.sum index 036bae6db33..70221c2109a 100644 --- a/go.sum +++ b/go.sum @@ -517,8 +517,8 @@ github.com/grafana/gomemcache v0.0.0-20240229205252-cd6a66d6fb56 h1:X8IKQ0wu40wp github.com/grafana/gomemcache v0.0.0-20240229205252-cd6a66d6fb56/go.mod h1:PGk3RjYHpxMM8HFPhKKo+vve3DdlPUELZLSDEFehPuU= github.com/grafana/memberlist v0.3.1-0.20220714140823-09ffed8adbbe h1:yIXAAbLswn7VNWBIvM71O2QsgfgW9fRXZNR0DXe6pDU= github.com/grafana/memberlist v0.3.1-0.20220714140823-09ffed8adbbe/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= -github.com/grafana/mimir-prometheus v0.0.0-20240515135245-e5b85c151ba8 h1:XmqfG3buFH0G/ns/DXnyMx46LITUEENXjZ84f7YAUy0= -github.com/grafana/mimir-prometheus v0.0.0-20240515135245-e5b85c151ba8/go.mod h1:ZlD3SoAHSwXK5VGLHv78Jh5kOpgSLaQAzt9gxq76fLM= +github.com/grafana/mimir-prometheus v0.0.0-20240515171138-a3ac8a4266ca h1:4JoJnC0wQ83X1uFzpvjFxdDOtT6Y15vKFXLNK1U4YHQ= +github.com/grafana/mimir-prometheus v0.0.0-20240515171138-a3ac8a4266ca/go.mod h1:ZlD3SoAHSwXK5VGLHv78Jh5kOpgSLaQAzt9gxq76fLM= github.com/grafana/opentracing-contrib-go-stdlib v0.0.0-20230509071955-f410e79da956 h1:em1oddjXL8c1tL0iFdtVtPloq2hRPen2MJQKoAWpxu0= github.com/grafana/opentracing-contrib-go-stdlib v0.0.0-20230509071955-f410e79da956/go.mod h1:qtI1ogk+2JhVPIXVc6q+NHziSmy2W5GbdQZFUHADCBU= github.com/grafana/pyroscope-go/godeltaprof v0.1.6 h1:nEdZ8louGAplSvIJi1HVp7kWvFvdiiYg3COLlTwJiFo= diff --git a/vendor/github.com/prometheus/prometheus/model/labels/matcher.go b/vendor/github.com/prometheus/prometheus/model/labels/matcher.go index 8e220e392d8..1282f80d639 100644 --- a/vendor/github.com/prometheus/prometheus/model/labels/matcher.go +++ b/vendor/github.com/prometheus/prometheus/model/labels/matcher.go @@ -14,8 +14,7 @@ package labels import ( - "bytes" - "strconv" + "fmt" ) // MatchType is an enum for label matching types. @@ -79,29 +78,7 @@ func MustNewMatcher(mt MatchType, name, val string) *Matcher { } func (m *Matcher) String() string { - // Start a buffer with a pre-allocated size on stack to cover most needs. - var bytea [1024]byte - b := bytes.NewBuffer(bytea[:0]) - - if m.shouldQuoteName() { - b.Write(strconv.AppendQuote(b.AvailableBuffer(), m.Name)) - } else { - b.WriteString(m.Name) - } - b.WriteString(m.Type.String()) - b.Write(strconv.AppendQuote(b.AvailableBuffer(), m.Value)) - - return b.String() -} - -func (m *Matcher) shouldQuoteName() bool { - for i, c := range m.Name { - if c == '_' || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (i > 0 && c >= '0' && c <= '9') { - continue - } - return true - } - return false + return fmt.Sprintf("%s%s%q", m.Name, m.Type, m.Value) } // Matches returns whether the matcher matches the given string value. diff --git a/vendor/modules.txt b/vendor/modules.txt index 796eba19c88..c73d8e72e55 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -935,7 +935,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.99.0 => github.com/grafana/mimir-prometheus v0.0.0-20240515135245-e5b85c151ba8 +# github.com/prometheus/prometheus v1.99.0 => github.com/grafana/mimir-prometheus v0.0.0-20240515171138-a3ac8a4266ca ## explicit; go 1.21 github.com/prometheus/prometheus/config github.com/prometheus/prometheus/discovery @@ -1550,7 +1550,7 @@ sigs.k8s.io/kustomize/kyaml/yaml/walk sigs.k8s.io/yaml sigs.k8s.io/yaml/goyaml.v2 sigs.k8s.io/yaml/goyaml.v3 -# github.com/prometheus/prometheus => github.com/grafana/mimir-prometheus v0.0.0-20240515135245-e5b85c151ba8 +# github.com/prometheus/prometheus => github.com/grafana/mimir-prometheus v0.0.0-20240515171138-a3ac8a4266ca # github.com/hashicorp/memberlist => github.com/grafana/memberlist v0.3.1-0.20220714140823-09ffed8adbbe # gopkg.in/yaml.v3 => github.com/colega/go-yaml-yaml v0.0.0-20220720105220-255a8d16d094 # github.com/grafana/regexp => github.com/grafana/regexp v0.0.0-20221005093135-b4c2bcb0a4b6