Skip to content

Commit cb85db0

Browse files
authored
Cortex upgrade v1.20.0 (#54)
* Upgrade to cortex v1.20.1 Use go 1.24 Signed-off-by: Friedrich Gonzalez <1517449+friedrichg@users.noreply.github.com> * Fix integration test Signed-off-by: Friedrich Gonzalez <1517449+friedrichg@users.noreply.github.com> * Update changelog Signed-off-by: Friedrich Gonzalez <1517449+friedrichg@users.noreply.github.com> * Fix integration tests Signed-off-by: Friedrich Gonzalez <1517449+friedrichg@users.noreply.github.com> * go mod tidy Signed-off-by: Friedrich Gonzalez <1517449+friedrichg@users.noreply.github.com> --------- Signed-off-by: Friedrich Gonzalez <1517449+friedrichg@users.noreply.github.com>
1 parent 8745609 commit cb85db0

3,379 files changed

Lines changed: 678874 additions & 195824 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/integration_test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ jobs:
1414
- uses: actions/checkout@v4
1515
- uses: actions/setup-go@v5
1616
with:
17-
go-version: 1.23
17+
go-version: 1.24
1818
- name: Start Cortex
1919
run: |
2020
docker run -d --name cortex \
2121
-p 9009:9009 \
2222
-v ${{ github.workspace }}/integration/cortex-config.yaml:/etc/cortex/config.yaml \
23-
cortexproject/cortex:v1.19.1 \
23+
cortexproject/cortex:v1.20.1 \
2424
-config.file=/etc/cortex/config.yaml \
2525
-target=all,alertmanager
2626
- name: Wait for Cortex

.github/workflows/validate_pr.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- uses: actions/checkout@v4
1515
- uses: actions/setup-go@v5
1616
with:
17-
go-version: 1.23
17+
go-version: 1.24
1818
cache: false
1919
- name: golangci-lint
2020
uses: golangci/golangci-lint-action@v6
@@ -27,7 +27,7 @@ jobs:
2727
- uses: actions/checkout@v4
2828
- uses: actions/setup-go@v5
2929
with:
30-
go-version: 1.23
30+
go-version: 1.24
3131
- name: Unit Tests
3232
run: make test
3333
build:
@@ -37,6 +37,6 @@ jobs:
3737
- uses: actions/checkout@v4
3838
- uses: actions/setup-go@v5
3939
with:
40-
go-version: 1.23
40+
go-version: 1.24
4141
- name: Build All
4242
run: make all

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
Order should be `CHANGE`, `FEATURE`, `ENHANCEMENT`, and `BUGFIX`
44

5+
## v0.20.0
6+
* [CHANGE] Upgrade cortex to v1.20.1
7+
* [CHANGE] Upgrade Go to 1.24
8+
59
## v0.19.0
610
* [CHANGE] Upgrade cortex to v1.19.1
711
* [CHANGE] Upgrade Go to 1.23

changelogs/v0.20.0.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# v0.20.0 Release
2+
3+
## Changes
4+
5+
* [CHANGE] Upgrade cortex to v1.20.1
6+
* [CHANGE] Upgrade Go to 1.24
7+
8+
## Installation
9+
10+
## cortextool
11+
12+
```console
13+
# download the binary (adapt os and arch as needed)
14+
$ curl -fSL -o "cortextool" "https://github.com/cortexproject/cortex-tools/releases/download/v0.20.0/cortextool_0.20.0_linux_x86_64"
15+
16+
# make it executable
17+
$ chmod a+x "cortextool"
18+
19+
# have fun :)
20+
$ ./cortextool --help
21+
```
22+
23+
## benchtool
24+
25+
```console
26+
# download the binary (adapt os and arch as needed)
27+
$ curl -fSL -o "benchtool" "https://github.com/cortexproject/cortex-tools/releases/download/v0.20.0/benchtool_0.20.0_linux_x86_64"
28+
29+
# make it executable
30+
$ chmod a+x "benchtool"
31+
32+
# have fun :)
33+
$ ./benchtool --help
34+
```

cmd/blockscopy/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
"github.com/go-kit/log"
2020
"github.com/go-kit/log/level"
2121
"github.com/grafana/dskit/concurrency"
22-
"github.com/oklog/ulid"
22+
"github.com/oklog/ulid/v2"
2323
"github.com/pkg/errors"
2424
"github.com/prometheus/client_golang/prometheus"
2525
"github.com/prometheus/client_golang/prometheus/promauto"

go.mod

Lines changed: 170 additions & 117 deletions
Large diffs are not rendered by default.

go.sum

Lines changed: 489 additions & 323 deletions
Large diffs are not rendered by default.

integration/integration_test.go

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
"github.com/prometheus/prometheus/promql/parser"
2626
"github.com/prometheus/prometheus/storage/remote"
2727
"github.com/stretchr/testify/require"
28-
"gopkg.in/yaml.v3"
2928

3029
"github.com/cortexproject/cortex-tools/pkg/backfill"
3130
"github.com/cortexproject/cortex-tools/pkg/bench"
@@ -50,10 +49,10 @@ func newClient(t *testing.T) *client.CortexClient {
5049
return c
5150
}
5251

53-
func ruleNode(record, expr string) rulefmt.RuleNode {
54-
return rulefmt.RuleNode{
55-
Record: yaml.Node{Kind: yaml.ScalarNode, Value: record},
56-
Expr: yaml.Node{Kind: yaml.ScalarNode, Value: expr},
52+
func rule(record, expr string) rulefmt.Rule {
53+
return rulefmt.Rule{
54+
Record: record,
55+
Expr: expr,
5756
}
5857
}
5958

@@ -64,8 +63,8 @@ func TestRulesLoadListDelete(t *testing.T) {
6463
namespace := "test_namespace"
6564
group := rwrulefmt.RuleGroup{}
6665
group.Name = "test_rule_group"
67-
group.Rules = []rulefmt.RuleNode{
68-
ruleNode("summed_up", "sum(up)"),
66+
group.Rules = []rulefmt.Rule{
67+
rule("summed_up", "sum(up)"),
6968
}
7069

7170
err := c.CreateRuleGroup(ctx, namespace, group)
@@ -106,9 +105,9 @@ func TestRulesMultipleGroups(t *testing.T) {
106105

107106
namespace := "multi_group_namespace"
108107
groups := []rwrulefmt.RuleGroup{
109-
{RuleGroup: rulefmt.RuleGroup{Name: "group_a", Rules: []rulefmt.RuleNode{ruleNode("metric_a", "sum(up)")}}},
110-
{RuleGroup: rulefmt.RuleGroup{Name: "group_b", Rules: []rulefmt.RuleNode{ruleNode("metric_b", "count(up)")}}},
111-
{RuleGroup: rulefmt.RuleGroup{Name: "group_c", Rules: []rulefmt.RuleNode{ruleNode("metric_c", "avg(up)")}}},
108+
{RuleGroup: rulefmt.RuleGroup{Name: "group_a", Rules: []rulefmt.Rule{rule("metric_a", "sum(up)")}}},
109+
{RuleGroup: rulefmt.RuleGroup{Name: "group_b", Rules: []rulefmt.Rule{rule("metric_b", "count(up)")}}},
110+
{RuleGroup: rulefmt.RuleGroup{Name: "group_c", Rules: []rulefmt.Rule{rule("metric_c", "avg(up)")}}},
112111
}
113112

114113
for _, g := range groups {
@@ -407,11 +406,11 @@ func (i *timeSeriesIterator) Labels() labels.Labels {
407406
return i.labels
408407
}
409408
series := i.ts[i.posSeries]
410-
i.labels = make(labels.Labels, len(series.Labels))
411-
for idx := range series.Labels {
412-
i.labels[idx].Name = series.Labels[idx].Name
413-
i.labels[idx].Value = series.Labels[idx].Value
409+
b := labels.NewBuilder(labels.EmptyLabels())
410+
for _, l := range series.Labels {
411+
b.Set(l.Name, l.Value)
414412
}
413+
i.labels = b.Labels()
415414
i.labelsSeriesPos = i.posSeries
416415
return i.labels
417416
}

pkg/analyse/ruler.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ func ParseMetricsInRuleGroup(mir *MetricsInRuler, group rwrulefmt.RuleGroup, ns
3131
)
3232

3333
for _, rule := range group.Rules {
34-
if rule.Record.Value != "" {
35-
ruleMetrics[rule.Record.Value] = struct{}{}
34+
if rule.Record != "" {
35+
ruleMetrics[rule.Record] = struct{}{}
3636
}
3737

38-
query := rule.Expr.Value
38+
query := rule.Expr
3939
expr, err := parser.ParseExpr(query)
4040
if err != nil {
4141
parseErrors = append(parseErrors, errors.Wrapf(err, "query=%v", query))

pkg/backfill/backfill.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import (
44
"context"
55
"fmt"
66
"io"
7+
"log/slog"
78
"strconv"
89
"strings"
910
"text/tabwriter"
1011
"time"
1112

1213
"github.com/alecthomas/units"
13-
"github.com/go-kit/log"
1414
"github.com/pkg/errors"
1515
"github.com/prometheus/common/model"
1616
"github.com/prometheus/prometheus/model/labels"
@@ -87,7 +87,7 @@ func CreateBlocks(input IteratorCreator, mint, maxt int64, maxSamplesInAppender
8787

8888
for t := mint; t <= maxt; t = t + blockDuration {
8989
err := func() error {
90-
w, err := tsdb.NewBlockWriter(log.NewNopLogger(), outputDir, blockDuration)
90+
w, err := tsdb.NewBlockWriter(slog.Default(), outputDir, blockDuration)
9191
if err != nil {
9292
return errors.Wrap(err, "block writer")
9393
}

0 commit comments

Comments
 (0)