Skip to content

Commit 3459574

Browse files
authored
Use golang 1.20 (#1567)
* Use golang 1.20 Signed-off-by: Pavol Loffay <[email protected]> * fix Signed-off-by: Pavol Loffay <[email protected]> * fix Signed-off-by: Pavol Loffay <[email protected]> * Fix Signed-off-by: Pavol Loffay <[email protected]> --------- Signed-off-by: Pavol Loffay <[email protected]>
1 parent 5984749 commit 3459574

File tree

13 files changed

+55
-39
lines changed

13 files changed

+55
-39
lines changed

.chloggen/golang119.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
2+
change_type: enhancement
3+
4+
# The name of the component, or a single word describing the area of concern, (e.g. operator, target allocator, github action)
5+
component: operator
6+
7+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
8+
note: Build operator, target-allocator and opAMP bridge with golang 1.20.
9+
10+
# One or more tracking issues related to the change
11+
issues: [1566]
12+
13+
# (Optional) One or more lines of additional information to render under the primary note.
14+
# These lines will be padded with 2 spaces and then inserted directly into the document.
15+
# Use pipe (|) for multiline entries.
16+
subtext:

.github/workflows/changelog.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- name: Setup Go
3434
uses: actions/setup-go@v3
3535
with:
36-
go-version: 1.19
36+
go-version: "1.20"
3737
- name: Cache Go
3838
id: go-cache
3939
uses: actions/cache@v3

.github/workflows/continuous-integration.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- name: Set up Go
1515
uses: actions/setup-go@v3
1616
with:
17-
go-version: 1.19
17+
go-version: "1.20"
1818

1919
- name: Check out code into the Go module directory
2020
uses: actions/checkout@v3
@@ -32,15 +32,15 @@ jobs:
3232
- name: Set up Go
3333
uses: actions/setup-go@v3
3434
with:
35-
go-version: 1.19
35+
go-version: "1.20"
3636
- name: Check out code into the Go module directory
3737
uses: actions/checkout@v3
3838

3939
- name: Lint
4040
uses: golangci/golangci-lint-action@v3
4141
with:
4242
args: -v --timeout 5m
43-
version: v1.48
43+
version: v1.51.2
4444
working-directory: ${{ matrix.workdir }}
4545

4646
security:

.github/workflows/e2e.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Set up Go
2525
uses: actions/setup-go@v3
2626
with:
27-
go-version: 1.19
27+
go-version: "1.20"
2828

2929
- name: Check out code into the Go module directory
3030
uses: actions/checkout@v3

.github/workflows/release.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
- name: Set up Go
1111
uses: actions/setup-go@v3
1212
with:
13-
go-version: 1.19
13+
go-version: "1.20"
1414

1515
- uses: actions/checkout@v3
1616

.github/workflows/scorecard.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Set up Go
2222
uses: actions/setup-go@v3
2323
with:
24-
go-version: 1.19
24+
go-version: "1.20"
2525

2626
- name: Check out code into the Go module directory
2727
uses: actions/checkout@v3

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the manager binary
2-
FROM golang:1.19 as builder
2+
FROM golang:1.20 as builder
33

44
WORKDIR /workspace
55
# Copy the Go Modules manifests

cmd/operator-opamp-bridge/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the operator-opamp-bridge binary
2-
FROM golang:1.19-alpine as builder
2+
FROM golang:1.20-alpine as builder
33

44
WORKDIR /app
55

cmd/operator-opamp-bridge/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/open-telemetry/opentelemetry-operator/cmd/operator-opamp-bridge
22

3-
go 1.19
3+
go 1.20
44

55
require (
66
github.com/go-logr/logr v1.2.3

cmd/otel-allocator/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the otel-allocator binary
2-
FROM golang:1.19-alpine as builder
2+
FROM golang:1.20-alpine as builder
33

44
WORKDIR /app
55

cmd/otel-allocator/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/open-telemetry/opentelemetry-operator/cmd/otel-allocator
22

3-
go 1.19
3+
go 1.20
44

55
require (
66
github.com/buraksezer/consistent v0.10.0

cmd/otel-allocator/server/bench_test.go

+26-26
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
)
3232

3333
func BenchmarkServerTargetsHandler(b *testing.B) {
34-
rand.Seed(time.Now().UnixNano())
34+
random := rand.New(rand.NewSource(time.Now().UnixNano())) // nolint: gosec
3535
var table = []struct {
3636
numCollectors int
3737
numJobs int
@@ -58,8 +58,8 @@ func BenchmarkServerTargetsHandler(b *testing.B) {
5858
b.Run(fmt.Sprintf("%s_num_cols_%d_num_jobs_%d", allocatorName, v.numCollectors, v.numJobs), func(b *testing.B) {
5959
b.ReportAllocs()
6060
for i := 0; i < b.N; i++ {
61-
randomJob := rand.Intn(v.numJobs) //nolint: gosec
62-
randomCol := rand.Intn(v.numCollectors) //nolint: gosec
61+
randomJob := random.Intn(v.numJobs) //nolint: gosec
62+
randomCol := random.Intn(v.numCollectors) //nolint: gosec
6363
request := httptest.NewRequest("GET", fmt.Sprintf("/jobs/test-job-%d/targets?collector_id=collector-%d", randomJob, randomCol), nil)
6464
w := httptest.NewRecorder()
6565
s.server.Handler.ServeHTTP(w, request)
@@ -70,14 +70,14 @@ func BenchmarkServerTargetsHandler(b *testing.B) {
7070
}
7171

7272
func BenchmarkScrapeConfigsHandler(b *testing.B) {
73-
rand.Seed(time.Now().UnixNano())
73+
random := rand.New(rand.NewSource(time.Now().UnixNano())) // nolint: gosec
7474
s := &Server{
7575
logger: logger,
7676
}
7777

7878
tests := []int{0, 5, 10, 50, 100, 500}
7979
for _, n := range tests {
80-
data := makeNScrapeConfigs(n)
80+
data := makeNScrapeConfigs(*random, n)
8181
assert.NoError(b, s.UpdateScrapeConfigResponse(data))
8282

8383
b.Run(fmt.Sprintf("%d_targets", n), func(b *testing.B) {
@@ -94,7 +94,7 @@ func BenchmarkScrapeConfigsHandler(b *testing.B) {
9494
}
9595

9696
func BenchmarkCollectorMapJSONHandler(b *testing.B) {
97-
rand.Seed(time.Now().UnixNano())
97+
random := rand.New(rand.NewSource(time.Now().UnixNano())) // nolint: gosec
9898
s := &Server{
9999
logger: logger,
100100
}
@@ -137,7 +137,7 @@ func BenchmarkCollectorMapJSONHandler(b *testing.B) {
137137
},
138138
}
139139
for _, tc := range tests {
140-
data := makeNCollectorJSON(tc.numCollectors, tc.numTargets)
140+
data := makeNCollectorJSON(*random, tc.numCollectors, tc.numTargets)
141141
b.Run(fmt.Sprintf("%d_collectors_%d_targets", tc.numCollectors, tc.numTargets), func(b *testing.B) {
142142
b.ReportAllocs()
143143
for i := 0; i < b.N; i++ {
@@ -149,7 +149,7 @@ func BenchmarkCollectorMapJSONHandler(b *testing.B) {
149149
}
150150

151151
func BenchmarkTargetItemsJSONHandler(b *testing.B) {
152-
rand.Seed(time.Now().UnixNano())
152+
random := rand.New(rand.NewSource(time.Now().UnixNano())) // nolint: gosec
153153
s := &Server{
154154
logger: logger,
155155
}
@@ -196,7 +196,7 @@ func BenchmarkTargetItemsJSONHandler(b *testing.B) {
196196
},
197197
}
198198
for _, tc := range tests {
199-
data := makeNTargetItems(tc.numTargets, tc.numLabels)
199+
data := makeNTargetItems(*random, tc.numTargets, tc.numLabels)
200200
b.Run(fmt.Sprintf("%d_targets_%d_labels", tc.numTargets, tc.numLabels), func(b *testing.B) {
201201
b.ReportAllocs()
202202
for i := 0; i < b.N; i++ {
@@ -209,22 +209,22 @@ func BenchmarkTargetItemsJSONHandler(b *testing.B) {
209209

210210
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_/")
211211

212-
func randSeq(n int) string {
212+
func randSeq(random rand.Rand, n int) string {
213213
b := make([]rune, n)
214214
for i := range b {
215-
b[i] = letters[rand.Intn(len(letters))] //nolint:gosec
215+
b[i] = letters[random.Intn(len(letters))] //nolint:gosec
216216
}
217217
return string(b)
218218
}
219219

220-
func makeNScrapeConfigs(n int) map[string]*promconfig.ScrapeConfig {
220+
func makeNScrapeConfigs(random rand.Rand, n int) map[string]*promconfig.ScrapeConfig {
221221
items := make(map[string]*promconfig.ScrapeConfig, n)
222222
for i := 0; i < n; i++ {
223-
items[randSeq(20)] = &promconfig.ScrapeConfig{
224-
JobName: randSeq(20),
223+
items[randSeq(random, 20)] = &promconfig.ScrapeConfig{
224+
JobName: randSeq(random, 20),
225225
ScrapeInterval: model.Duration(30 * time.Second),
226226
ScrapeTimeout: model.Duration(time.Minute),
227-
MetricsPath: randSeq(50),
227+
MetricsPath: randSeq(random, 50),
228228
SampleLimit: 5,
229229
TargetLimit: 200,
230230
LabelLimit: 20,
@@ -235,34 +235,34 @@ func makeNScrapeConfigs(n int) map[string]*promconfig.ScrapeConfig {
235235
return items
236236
}
237237

238-
func makeNCollectorJSON(numCollectors, numItems int) map[string]collectorJSON {
238+
func makeNCollectorJSON(random rand.Rand, numCollectors, numItems int) map[string]collectorJSON {
239239
items := make(map[string]collectorJSON, numCollectors)
240240
for i := 0; i < numCollectors; i++ {
241-
items[randSeq(20)] = collectorJSON{
242-
Link: randSeq(120),
243-
Jobs: makeNTargetItems(numItems, 50),
241+
items[randSeq(random, 20)] = collectorJSON{
242+
Link: randSeq(random, 120),
243+
Jobs: makeNTargetItems(random, numItems, 50),
244244
}
245245
}
246246
return items
247247
}
248248

249-
func makeNTargetItems(numItems, numLabels int) []*target.Item {
249+
func makeNTargetItems(random rand.Rand, numItems, numLabels int) []*target.Item {
250250
items := make([]*target.Item, 0, numItems)
251251
for i := 0; i < numItems; i++ {
252252
items = append(items, target.NewItem(
253-
randSeq(80),
254-
randSeq(150),
255-
makeNNewLabels(numLabels),
256-
randSeq(30),
253+
randSeq(random, 80),
254+
randSeq(random, 150),
255+
makeNNewLabels(random, numLabels),
256+
randSeq(random, 30),
257257
))
258258
}
259259
return items
260260
}
261261

262-
func makeNNewLabels(n int) model.LabelSet {
262+
func makeNNewLabels(random rand.Rand, n int) model.LabelSet {
263263
labels := make(map[model.LabelName]model.LabelValue, n)
264264
for i := 0; i < n; i++ {
265-
labels[model.LabelName(randSeq(20))] = model.LabelValue(randSeq(20))
265+
labels[model.LabelName(randSeq(random, 20))] = model.LabelValue(randSeq(random, 20))
266266
}
267267
return labels
268268
}

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/open-telemetry/opentelemetry-operator
22

3-
go 1.19
3+
go 1.20
44

55
retract v1.51.0
66

0 commit comments

Comments
 (0)