Skip to content

Commit 1a4f92c

Browse files
committed
Upgrade to cortex v1.20.1
Use go 1.24 Signed-off-by: Friedrich Gonzalez <1517449+friedrichg@users.noreply.github.com>
1 parent 5e8f871 commit 1a4f92c

File tree

3,375 files changed

+678820
-195807
lines changed

Some content is hidden

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

3,375 files changed

+678820
-195807
lines changed

.github/workflows/validate_pr.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- uses: actions/checkout@v4
1313
- uses: actions/setup-go@v5
1414
with:
15-
go-version: 1.23
15+
go-version: 1.24
1616
cache: false
1717
- name: golangci-lint
1818
uses: golangci/golangci-lint-action@v6
@@ -25,7 +25,7 @@ jobs:
2525
- uses: actions/checkout@v4
2626
- uses: actions/setup-go@v5
2727
with:
28-
go-version: 1.23
28+
go-version: 1.24
2929
- name: Unit Tests
3030
run: make test
3131
build:
@@ -35,6 +35,6 @@ jobs:
3535
- uses: actions/checkout@v4
3636
- uses: actions/setup-go@v5
3737
with:
38-
go-version: 1.23
38+
go-version: 1.24
3939
- name: Build All
4040
run: make all

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: 169 additions & 116 deletions
Large diffs are not rendered by default.

go.sum

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

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
}

pkg/commands/block_gen.go

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package commands
22

33
import (
44
"context"
5+
"log/slog"
56
"os"
6-
"sort"
77
"time"
88

99
"github.com/go-kit/log"
@@ -96,7 +96,7 @@ func (f *BlockGenCommand) run(_ *kingpin.ParseContext) error {
9696

9797
currentBlockID = blockID(currentTs, blockSize)
9898
level.Info(logger).Log("msg", "starting new block", "block_id", currentBlockID, "blocks_left", lastBlockID-currentBlockID+1)
99-
w, err = tsdb.NewBlockWriter(log.NewNopLogger(), f.Cfg.BlockDir, blockSize)
99+
w, err = tsdb.NewBlockWriter(slog.Default(), f.Cfg.BlockDir, blockSize)
100100
if err != nil {
101101
return err
102102
}
@@ -108,13 +108,10 @@ func (f *BlockGenCommand) run(_ *kingpin.ParseContext) error {
108108
for _, s := range timeSeries {
109109
var ref storage.SeriesRef
110110

111-
labels := prompbLabelsToLabelsLabels(s.Labels)
112-
sort.Slice(labels, func(i, j int) bool {
113-
return labels[i].Name < labels[j].Name
114-
})
111+
lbls := prompbLabelsToLabelsLabels(s.Labels)
115112

116113
for _, sample := range s.Samples {
117-
ref, err = app.Append(ref, labels, sample.Timestamp, sample.Value)
114+
ref, err = app.Append(ref, lbls, sample.Timestamp, sample.Value)
118115
if err != nil {
119116
return err
120117
}
@@ -139,10 +136,9 @@ func blockID(ts, blockSize int64) int64 {
139136
}
140137

141138
func prompbLabelsToLabelsLabels(in []prompb.Label) labels.Labels {
142-
out := make(labels.Labels, len(in))
143-
for idx := range in {
144-
out[idx].Name = in[idx].Name
145-
out[idx].Value = in[idx].Value
139+
b := labels.NewBuilder(labels.EmptyLabels())
140+
for _, l := range in {
141+
b.Set(l.Name, l.Value)
146142
}
147-
return out
143+
return b.Labels()
148144
}

pkg/commands/bucket_validation.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ func (c *retryingBucketClient) withRetries(f func() error) error {
6060
}
6161
}
6262

63-
func (c *retryingBucketClient) Upload(ctx context.Context, name string, r io.Reader) error {
64-
return c.withRetries(func() error { return c.Bucket.Upload(ctx, name, r) })
63+
func (c *retryingBucketClient) Upload(ctx context.Context, name string, r io.Reader, opts ...objstore.ObjectUploadOption) error {
64+
return c.withRetries(func() error { return c.Bucket.Upload(ctx, name, r, opts...) })
6565
}
6666

6767
func (c *retryingBucketClient) Exists(ctx context.Context, name string) (bool, error) {

pkg/commands/remote_read.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,11 @@ func (i *timeSeriesIterator) Labels() (l labels.Labels) {
143143
}
144144

145145
series := i.ts[i.posSeries]
146-
i.labels = make(labels.Labels, len(series.Labels))
147-
for posLabel := range series.Labels {
148-
i.labels[posLabel].Name = series.Labels[posLabel].Name
149-
i.labels[posLabel].Value = series.Labels[posLabel].Value
146+
b := labels.NewBuilder(labels.EmptyLabels())
147+
for _, lbl := range series.Labels {
148+
b.Set(lbl.Name, lbl.Value)
150149
}
150+
i.labels = b.Labels()
151151
i.labelsSeriesPos = i.posSeries
152152
return i.labels
153153
}

pkg/commands/rules.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ func (r *RuleCommand) prepare(_ *kingpin.ParseContext) error {
653653
}
654654

655655
// Do not apply the aggregation label to excluded rule groups.
656-
applyTo := func(group rwrulefmt.RuleGroup, _ rulefmt.RuleNode) bool {
656+
applyTo := func(group rwrulefmt.RuleGroup, _ rulefmt.Rule) bool {
657657
_, excluded := r.aggregationLabelExcludedRuleGroupsList[group.Name]
658658
return !excluded
659659
}
@@ -774,11 +774,11 @@ func checkDuplicates(groups []rwrulefmt.RuleGroup) []compareRuleType {
774774
return duplicates
775775
}
776776

777-
func ruleMetric(rule rulefmt.RuleNode) string {
778-
if rule.Alert.Value != "" {
779-
return rule.Alert.Value
777+
func ruleMetric(rule rulefmt.Rule) string {
778+
if rule.Alert != "" {
779+
return rule.Alert
780780
}
781-
return rule.Record.Value
781+
return rule.Record
782782
}
783783

784784
// End taken from https://github.com/prometheus/prometheus/blob/8c8de46003d1800c9d40121b4a5e5de8582ef6e1/cmd/promtool/main.go#L403

0 commit comments

Comments
 (0)