From fc86cf5f23e87e1fde5f431a4474e31230289d00 Mon Sep 17 00:00:00 2001 From: Michael Hoffmann Date: Sun, 14 Jan 2024 14:17:28 +0100 Subject: [PATCH 1/3] VERSION: cut release 0.34.0-rc.0 Signed-off-by: Michael Hoffmann --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index cd748687dc..3a7113aa08 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.35.0-dev +0.34.0-rc.0 From df467f7e5a3f6526d8054b600f8e68b29e9b13e0 Mon Sep 17 00:00:00 2001 From: Michael Hoffmann Date: Sat, 20 Jan 2024 18:08:23 +0100 Subject: [PATCH 2/3] VERSION: cut release 0.34.0-rc.1 Signed-off-by: Michael Hoffmann --- CHANGELOG.md | 1 + VERSION | 2 +- pkg/store/acceptance_test.go | 23 +++++++++++++++++++++++ pkg/store/bucket.go | 5 +++-- pkg/store/prometheus.go | 36 ++++++++++++++++++++++-------------- pkg/store/tsdb.go | 29 +++++++++++++++++++---------- 6 files changed, 69 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 76137ab4de..3b4287ae5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re - [#7011](https://github.com/thanos-io/thanos/pull/7011) Query Frontend: queries with negative offset should check whether it is cacheable or not. - [#6874](https://github.com/thanos-io/thanos/pull/6874) Sidecar: fix labels returned by 'api/v1/series' in presence of conflicting external and inner labels. - [#7009](https://github.com/thanos-io/thanos/pull/7009) Rule: Fix spacing error in URL. +- [#7082](https://github.com/thanos-io/thanos/pull/7082) Stores: fix label values edge case when requesting external label values with matchers ### Added diff --git a/VERSION b/VERSION index 3a7113aa08..733479ba3f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.34.0-rc.0 +0.34.0-rc.1 diff --git a/pkg/store/acceptance_test.go b/pkg/store/acceptance_test.go index 34abc649ab..dae3e503c1 100644 --- a/pkg/store/acceptance_test.go +++ b/pkg/store/acceptance_test.go @@ -255,6 +255,29 @@ func testStoreAPIsAcceptance(t *testing.T, startStore startStoreFn) { }, }, }, + { + desc: "series matcher on other labels when requesting external labels", + appendFn: func(app storage.Appender) { + _, err := app.Append(0, labels.FromStrings("__name__", "up", "foo", "bar", "job", "C"), 0, 0) + testutil.Ok(t, err) + _, err = app.Append(0, labels.FromStrings("__name__", "up", "foo", "baz", "job", "C"), 0, 0) + testutil.Ok(t, err) + + testutil.Ok(t, app.Commit()) + }, + labelValuesCalls: []labelValuesCallCase{ + { + start: timestamp.FromTime(minTime), + end: timestamp.FromTime(maxTime), + label: "region", + matchers: []storepb.LabelMatcher{ + {Type: storepb.LabelMatcher_EQ, Name: "__name__", Value: "up"}, + {Type: storepb.LabelMatcher_EQ, Name: "job", Value: "C"}, + }, + expectedValues: []string{"eu-west"}, + }, + }, + }, { // Testcases taken from https://github.com/prometheus/prometheus/blob/95e705612c1d557f1681bd081a841b78f93ee158/tsdb/querier_test.go#L1898 desc: "matching behavior", diff --git a/pkg/store/bucket.go b/pkg/store/bucket.go index fd4fb7392c..7bd1647f66 100644 --- a/pkg/store/bucket.go +++ b/pkg/store/bucket.go @@ -1947,8 +1947,9 @@ func (s *BucketStore) LabelValues(ctx context.Context, req *storepb.LabelValuesR continue } - // If we have series matchers, add != "" matcher, to only select series that have given label name. - if len(reqSeriesMatchersNoExtLabels) > 0 { + // If we have series matchers and the Label is not an external one, add != "" matcher + // to only select series that have given label name. + if len(reqSeriesMatchersNoExtLabels) > 0 && !b.extLset.Has(req.Label) { m, err := labels.NewMatcher(labels.MatchNotEqual, req.Label, "") if err != nil { return nil, status.Error(codes.InvalidArgument, err.Error()) diff --git a/pkg/store/prometheus.go b/pkg/store/prometheus.go index 197364ca04..eea0334dd0 100644 --- a/pkg/store/prometheus.go +++ b/pkg/store/prometheus.go @@ -108,6 +108,11 @@ func NewPrometheusStore( return p, nil } +func (p *PrometheusStore) labelCallsSupportMatchers() bool { + version, parseErr := semver.Parse(p.promVersion()) + return parseErr == nil && version.GTE(baseVer) +} + // Info returns store information about the Prometheus instance. // NOTE(bwplotka): MaxTime & MinTime are not accurate nor adjusted dynamically. // This is fine for now, but might be needed in future. @@ -656,8 +661,7 @@ func (p *PrometheusStore) LabelNames(ctx context.Context, r *storepb.LabelNamesR } var lbls []string - version, parseErr := semver.Parse(p.promVersion()) - if len(matchers) == 0 || (parseErr == nil && version.GTE(baseVer)) { + if len(matchers) == 0 || p.labelCallsSupportMatchers() { lbls, err = p.client.LabelNamesInGRPC(ctx, p.base, matchers, r.Start, r.End) if err != nil { return nil, err @@ -707,23 +711,27 @@ func (p *PrometheusStore) LabelValues(ctx context.Context, r *storepb.LabelValue return &storepb.LabelValuesResponse{}, nil } - // First check for matching external label which has priority. - if l := extLset.Get(r.Label); l != "" { - for _, m := range matchers { - if !m.Matches(l) { - return &storepb.LabelValuesResponse{}, nil - } - } - return &storepb.LabelValuesResponse{Values: []string{l}}, nil - } - var ( sers []map[string]string vals []string ) - version, parseErr := semver.Parse(p.promVersion()) - if len(matchers) == 0 || (parseErr == nil && version.GTE(baseVer)) { + // If we request label values for an external label while selecting an additional matcher for other label values + if val := extLset.Get(r.Label); val != "" { + if len(matchers) == 0 { + return &storepb.LabelValuesResponse{Values: []string{val}}, nil + } + sers, err = p.client.SeriesInGRPC(ctx, p.base, matchers, r.Start, r.End) + if err != nil { + return nil, err + } + if len(sers) > 0 { + return &storepb.LabelValuesResponse{Values: []string{val}}, nil + } + return &storepb.LabelValuesResponse{}, nil + } + + if len(matchers) == 0 || p.labelCallsSupportMatchers() { vals, err = p.client.LabelValuesInGRPC(ctx, p.base, r.Label, matchers, r.Start, r.End) if err != nil { return nil, err diff --git a/pkg/store/tsdb.go b/pkg/store/tsdb.go index 8953946a29..0b860b0675 100644 --- a/pkg/store/tsdb.go +++ b/pkg/store/tsdb.go @@ -339,26 +339,35 @@ func (s *TSDBStore) LabelValues(ctx context.Context, r *storepb.LabelValuesReque if err != nil { return nil, status.Error(codes.InvalidArgument, err.Error()) } - if !match { return &storepb.LabelValuesResponse{}, nil } - if v := s.getExtLset().Get(r.Label); v != "" { - for _, m := range matchers { - if !m.Matches(v) { - return &storepb.LabelValuesResponse{}, nil - } - } - return &storepb.LabelValuesResponse{Values: []string{v}}, nil - } - q, err := s.db.ChunkQuerier(r.Start, r.End) if err != nil { return nil, status.Error(codes.Internal, err.Error()) } defer runutil.CloseWithLogOnErr(s.logger, q, "close tsdb querier label values") + // If we request label values for an external label while selecting an additional matcher for other label values + if val := s.getExtLset().Get(r.Label); val != "" { + if len(matchers) == 0 { + return &storepb.LabelValuesResponse{Values: []string{val}}, nil + } + + hints := &storage.SelectHints{ + Start: r.Start, + End: r.End, + Func: "series", + } + set := q.Select(ctx, false, hints, matchers...) + + for set.Next() { + return &storepb.LabelValuesResponse{Values: []string{val}}, nil + } + return &storepb.LabelValuesResponse{}, nil + } + res, _, err := q.LabelValues(ctx, r.Label, matchers...) if err != nil { return nil, status.Error(codes.Internal, err.Error()) From 18d740f2921ab9dfc4fe5c4650bf21cd6d7a1c64 Mon Sep 17 00:00:00 2001 From: Michael Hoffmann Date: Fri, 26 Jan 2024 22:45:53 +0100 Subject: [PATCH 3/3] CHANGELOG: cut release 0.34 (#7095) Signed-off-by: Michael Hoffmann --- CHANGELOG.md | 2 +- VERSION | 2 +- docs/release-process.md | 1 + website/hugo.yaml | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b4287ae5a..bc376f9ca4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re ### Removed -## [v0.34.0](https://github.com/thanos-io/thanos/tree/release-0.34) - release in progress +## [v0.34.0](https://github.com/thanos-io/thanos/tree/release-0.34) - 26.01.24 ### Fixed diff --git a/VERSION b/VERSION index 733479ba3f..85e60ed180 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.34.0-rc.1 +0.34.0 diff --git a/docs/release-process.md b/docs/release-process.md index 5ea9080378..6aff7b50a0 100644 --- a/docs/release-process.md +++ b/docs/release-process.md @@ -23,6 +23,7 @@ Release shepherd responsibilities: | Release | Time of first RC | Shepherd (GitHub handle) | |---------|------------------|-------------------------------| +| v0.34.0 | 2024.01.14 | `@MichaHoffmann` | | v0.33.0 | 2023.10.24 | `@MichaHoffmann` | | v0.32.0 | 2023.08.23 | `@saswatamcode` | | v0.31.0 | 2023.03.23 | `@fpetkovski` | diff --git a/website/hugo.yaml b/website/hugo.yaml index cae16ff499..834d758b9c 100644 --- a/website/hugo.yaml +++ b/website/hugo.yaml @@ -28,6 +28,7 @@ permalinks: # TODO(bwplotka): Move to mdox + fixes to ensure we don't need to manually do this. # For now we added few entries for advance. tip: "/:sections/:filename.md" + v0.34: "/:sections/:filename.md" v0.33: "/:sections/:filename.md" v0.32: "/:sections/:filename.md" v0.31: "/:sections/:filename.md"