From c9624c18ccca780dafc7d2d14c74073cfb22f7f2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 19 Dec 2024 01:15:57 -0800 Subject: [PATCH 1/5] Bump the actions-dependencies group across 1 directory with 3 updates (#6441) Bumps the actions-dependencies group with 3 updates in the / directory: [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action), [actions/upload-artifact](https://github.com/actions/upload-artifact) and [github/codeql-action](https://github.com/github/codeql-action). Updates `docker/setup-buildx-action` from 3.7.1 to 3.8.0 - [Release notes](https://github.com/docker/setup-buildx-action/releases) - [Commits](https://github.com/docker/setup-buildx-action/compare/c47758b77c9736f4b2ef4073d4d51994fabfe349...6524bf65af31da8d45b59e8c27de4bd072b392f5) Updates `actions/upload-artifact` from 4.4.3 to 4.5.0 - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882...6f51ac03b9356f520e9adb1b1b7802705f340c2b) Updates `github/codeql-action` from 3.27.7 to 3.27.9 - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/babb554ede22fd5605947329c4d04d8e7a0b8155...df409f7d9260372bd5f19e5b04e83cb3c43714ae) --- updated-dependencies: - dependency-name: docker/setup-buildx-action dependency-type: direct:production update-type: version-update:semver-minor dependency-group: actions-dependencies - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-minor dependency-group: actions-dependencies - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch dependency-group: actions-dependencies ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/build-image.yml | 4 ++-- .github/workflows/scorecards.yml | 4 ++-- .github/workflows/test-build-deploy.yml | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index 9179b469fa..f7d54f1638 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -28,13 +28,13 @@ jobs: uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1 + uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0 - name: Save image run: make save-multiarch-build-image - name: Upload Docker Images Artifacts - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 + uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 with: name: build-image path: | diff --git a/.github/workflows/scorecards.yml b/.github/workflows/scorecards.yml index d70212b1d8..e7539e115f 100644 --- a/.github/workflows/scorecards.yml +++ b/.github/workflows/scorecards.yml @@ -55,7 +55,7 @@ jobs: # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF # format to the repository Actions tab. - name: "Upload artifact" - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v3.pre.node20 + uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v3.pre.node20 with: name: SARIF file path: results.sarif @@ -64,6 +64,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard (optional). # Commenting out will disable upload of results to your repo's Code Scanning dashboard - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@babb554ede22fd5605947329c4d04d8e7a0b8155 # v3.27.7 + uses: github/codeql-action/upload-sarif@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9 with: sarif_file: results.sarif diff --git a/.github/workflows/test-build-deploy.yml b/.github/workflows/test-build-deploy.yml index 92fd95b69e..683c4fa96f 100644 --- a/.github/workflows/test-build-deploy.yml +++ b/.github/workflows/test-build-deploy.yml @@ -93,15 +93,15 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@babb554ede22fd5605947329c4d04d8e7a0b8155 # v3.27.7 + uses: github/codeql-action/init@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9 with: languages: go - name: Autobuild - uses: github/codeql-action/autobuild@babb554ede22fd5605947329c4d04d8e7a0b8155 # v3.27.7 + uses: github/codeql-action/autobuild@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@babb554ede22fd5605947329c4d04d8e7a0b8155 # v3.27.7 + uses: github/codeql-action/analyze@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9 build: @@ -131,7 +131,7 @@ jobs: touch build-image/.uptodate make BUILD_IN_CONTAINER=false web-build - name: Upload Website Artifact - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 + uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 with: name: website public path: website/public/ @@ -143,7 +143,7 @@ jobs: - name: Create Docker Images Archive run: tar -cvf images.tar /tmp/images - name: Upload Docker Images Artifact - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 + uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 with: name: Docker Images path: ./images.tar From d6bfb77a6501c1fa675afbd1373d69b1d7a57c90 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 19 Dec 2024 14:09:22 +0000 Subject: [PATCH 2/5] Bump golang.org/x/net in the go-dependencies group across 1 directory Bumps the go-dependencies group with 1 update in the / directory: [golang.org/x/net](https://github.com/golang/net). Updates `golang.org/x/net` from 0.32.0 to 0.33.0 - [Commits](https://github.com/golang/net/compare/v0.32.0...v0.33.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor dependency-group: go-dependencies ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- vendor/modules.txt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 1a5920b422..02747cc65a 100644 --- a/go.mod +++ b/go.mod @@ -67,7 +67,7 @@ require ( go.opentelemetry.io/otel/sdk v1.33.0 go.opentelemetry.io/otel/trace v1.33.0 go.uber.org/atomic v1.11.0 - golang.org/x/net v0.32.0 + golang.org/x/net v0.33.0 golang.org/x/sync v0.10.0 golang.org/x/time v0.8.0 google.golang.org/grpc v1.68.1 diff --git a/go.sum b/go.sum index 8d74606c32..f32526746d 100644 --- a/go.sum +++ b/go.sum @@ -1933,8 +1933,8 @@ golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= -golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= -golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= diff --git a/vendor/modules.txt b/vendor/modules.txt index 08294793d7..9ab567eb08 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1312,7 +1312,7 @@ golang.org/x/exp/slices # golang.org/x/mod v0.21.0 ## explicit; go 1.22.0 golang.org/x/mod/semver -# golang.org/x/net v0.32.0 +# golang.org/x/net v0.33.0 ## explicit; go 1.18 golang.org/x/net/bpf golang.org/x/net/context From 0dcd5f46aa2e1c56a4158ba86d6a7f15fed40d8e Mon Sep 17 00:00:00 2001 From: Charlie Le <3375195+CharlieTLe@users.noreply.github.com> Date: Thu, 19 Dec 2024 07:59:50 -0800 Subject: [PATCH 3/5] Prep for v1.19.0 Signed-off-by: Charlie Le <3375195+CharlieTLe@users.noreply.github.com> --- RELEASE.md | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASE.md b/RELEASE.md index fb9b03bd65..85577bf52f 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -34,6 +34,7 @@ Our goal is to provide a new minor release every 6 weeks. This is a new process | v1.16.0 | 2023-11-05 | Ben Ye (@yeya24) | | v1.17.0 | 2024-04-25 | Ben Ye (@yeya24) | | v1.18.0 | 2024-08-16 | Daniel Blando (@danielblando) | +| v1.19.0 | 2025-01-15 | Charlie Le (@charlietle) | ## Release shepherd responsibilities From 5a7860830781670c58c8723d21a34af356f68236 Mon Sep 17 00:00:00 2001 From: Harry John Date: Fri, 20 Dec 2024 13:30:12 -0800 Subject: [PATCH 4/5] Fix @ modifier for subquery when split (#6450) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 🌲 Harry 🌊 John 🏔 --- CHANGELOG.md | 1 + pkg/querier/tripperware/queryrange/split_by_interval.go | 9 +++++++++ .../tripperware/queryrange/split_by_interval_test.go | 8 ++++++++ 3 files changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7da08bf6ea..12f25be2cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,7 @@ * [BUGFIX] Ring: update ring with new ip address when instance is lost, rejoins, but heartbeat is disabled. #6271 * [BUGFIX] Ingester: Fix regression on usage of cortex_ingester_queried_chunks. #6398 * [BUGFIX] Ingester: Fix possible race condition when `active series per LabelSet` is configured. #6409 +* [BUGFIX] Query Frontend: Fix @ modifier not being applied correctly on sub queries. #6450 ## 1.18.1 2024-10-14 diff --git a/pkg/querier/tripperware/queryrange/split_by_interval.go b/pkg/querier/tripperware/queryrange/split_by_interval.go index 7ff38f4ec3..064b53d760 100644 --- a/pkg/querier/tripperware/queryrange/split_by_interval.go +++ b/pkg/querier/tripperware/queryrange/split_by_interval.go @@ -110,6 +110,15 @@ func evaluateAtModifierFunction(query string, start, end int64) (string, error) } selector.StartOrEnd = 0 } + if selector, ok := n.(*parser.SubqueryExpr); ok { + switch selector.StartOrEnd { + case parser.START: + selector.Timestamp = &start + case parser.END: + selector.Timestamp = &end + } + selector.StartOrEnd = 0 + } return nil }) return expr.String(), err diff --git a/pkg/querier/tripperware/queryrange/split_by_interval_test.go b/pkg/querier/tripperware/queryrange/split_by_interval_test.go index e9cfd8526f..23989ac64a 100644 --- a/pkg/querier/tripperware/queryrange/split_by_interval_test.go +++ b/pkg/querier/tripperware/queryrange/split_by_interval_test.go @@ -377,6 +377,14 @@ func Test_evaluateAtModifier(t *testing.T) { [2m:]) [10m:])`, }, + { + in: `irate(kube_pod_info{namespace="test"}[1h:1m] @ start())`, + expected: `irate(kube_pod_info{namespace="test"}[1h:1m] @ 1546300.800)`, + }, + { + in: `irate(kube_pod_info{namespace="test"} @ end()[1h:1m] @ start())`, + expected: `irate(kube_pod_info{namespace="test"} @ 1646300.800 [1h:1m] @ 1546300.800)`, + }, { // parse error: @ modifier must be preceded by an instant vector selector or range vector selector or a subquery in: "sum(http_requests_total[5m]) @ 10.001", From 7b1ed512c105a259402eda73b46ad727e99c8789 Mon Sep 17 00:00:00 2001 From: Alan Protasio Date: Fri, 20 Dec 2024 18:25:56 -0800 Subject: [PATCH 5/5] Avoid over allocating strings.Builder when creating cache key for expanded postings (#6451) Signed-off-by: alanprot --- pkg/storage/tsdb/expanded_postings_cache.go | 9 +++--- .../tsdb/expanded_postings_cache_test.go | 31 +++++++++++++++++++ 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/pkg/storage/tsdb/expanded_postings_cache.go b/pkg/storage/tsdb/expanded_postings_cache.go index 921881b5c5..57027cf2a4 100644 --- a/pkg/storage/tsdb/expanded_postings_cache.go +++ b/pkg/storage/tsdb/expanded_postings_cache.go @@ -208,7 +208,7 @@ func (c *blocksPostingsForMatchersCache) fetchPostings(blockID ulid.ULID, ix tsd return nil, 0, err } - key := c.cacheKey(seed, blockID, ms...) + key := cacheKey(seed, blockID, ms...) promise, loaded := cache.getPromiseForKey(key, fetch) if loaded { c.metrics.CacheHits.WithLabelValues(cache.name).Inc() @@ -235,7 +235,7 @@ func (c *blocksPostingsForMatchersCache) getSeedForMetricName(metricName string) return c.seedByHash.getSeed(c.userId, metricName) } -func (c *blocksPostingsForMatchersCache) cacheKey(seed string, blockID ulid.ULID, ms ...*labels.Matcher) string { +func cacheKey(seed string, blockID ulid.ULID, ms ...*labels.Matcher) string { slices.SortFunc(ms, func(i, j *labels.Matcher) int { if i.Type != j.Type { return int(i.Type - j.Type) @@ -254,15 +254,16 @@ func (c *blocksPostingsForMatchersCache) cacheKey(seed string, blockID ulid.ULID sepLen = 1 ) - var size int + size := len(seed) + len(blockID.String()) + 2*sepLen for _, m := range ms { - size += len(seed) + len(blockID.String()) + len(m.Name) + len(m.Value) + typeLen + 2*sepLen + size += len(m.Name) + len(m.Value) + typeLen + sepLen } sb := strings.Builder{} sb.Grow(size) sb.WriteString(seed) sb.WriteByte('|') sb.WriteString(blockID.String()) + sb.WriteByte('|') for _, m := range ms { sb.WriteString(m.Name) sb.WriteString(m.Type.String()) diff --git a/pkg/storage/tsdb/expanded_postings_cache_test.go b/pkg/storage/tsdb/expanded_postings_cache_test.go index 6a9476072a..3517ec6e9c 100644 --- a/pkg/storage/tsdb/expanded_postings_cache_test.go +++ b/pkg/storage/tsdb/expanded_postings_cache_test.go @@ -8,12 +8,43 @@ import ( "testing" "time" + "github.com/oklog/ulid" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/testutil" + "github.com/prometheus/prometheus/model/labels" "github.com/stretchr/testify/require" "go.uber.org/atomic" ) +func TestCacheKey(t *testing.T) { + blockID := ulid.MustNew(1, nil) + seed := "seed123" + matchers := []*labels.Matcher{ + { + Type: labels.MatchEqual, + Name: "name_1", + Value: "value_1", + }, + { + Type: labels.MatchNotEqual, + Name: "name_2", + Value: "value_2", + }, + { + Type: labels.MatchRegexp, + Name: "name_3", + Value: "value_4", + }, + { + Type: labels.MatchNotRegexp, + Name: "name_5", + Value: "value_4", + }, + } + r := cacheKey(seed, blockID, matchers...) + require.Equal(t, "seed123|00000000010000000000000000|name_1=value_1|name_2!=value_2|name_3=~value_4|name_5!~value_4|", r) +} + func Test_ShouldFetchPromiseOnlyOnce(t *testing.T) { cfg := PostingsCacheConfig{ Enabled: true,