Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Go 1.22.5 #40082

Merged
merged 18 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.21.11
1.22.4
8 changes: 4 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ linters-settings:

gosimple:
# Select the Go version to target. The default is '1.13'.
go: "1.21.11"
go: "1.22.4"

nakedret:
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
Expand All @@ -142,19 +142,19 @@ linters-settings:

staticcheck:
# Select the Go version to target. The default is '1.13'.
go: "1.21.11"
go: "1.22.4"
checks: ["all"]

stylecheck:
# Select the Go version to target. The default is '1.13'.
go: "1.21.11"
go: "1.22.4"
# Disabled:
# ST1005: error strings should not be capitalized
checks: ["all", "-ST1005"]

unused:
# Select the Go version to target. The default is '1.13'.
go: "1.21.11"
go: "1.22.4"

gosec:
excludes:
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]

*Affecting all Beats*

- Update Go version to 1.22.4. {pull}40082[40082]

*Auditbeat*


Expand Down
2 changes: 1 addition & 1 deletion auditbeat/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21.11
FROM golang:1.22.4

RUN \
apt-get update \
Expand Down
6 changes: 3 additions & 3 deletions auditbeat/module/file_integrity/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ func TestConfig(t *testing.T) {
assert.EqualValues(t, 1024*1024*1024, c.MaxFileSizeBytes)
assert.EqualValues(t, 1024*1024*10, c.ScanRateBytesPerSec)
assert.Len(t, c.ExcludeFiles, 2)
assert.EqualValues(t, `\.DS_Store(?-m:$)`, c.ExcludeFiles[0].String())
assert.EqualValues(t, `\.swp(?-m:$)`, c.ExcludeFiles[1].String())
assert.EqualValues(t, `(?-m:\.DS_Store$)`, c.ExcludeFiles[0].String())
assert.EqualValues(t, `(?-m:\.swp$)`, c.ExcludeFiles[1].String())
assert.Len(t, c.IncludeFiles, 1)
assert.EqualValues(t, `\.ssh/(?-m:$)`, c.IncludeFiles[0].String())
assert.EqualValues(t, `(?-m:\.ssh/$)`, c.IncludeFiles[0].String())
assert.Len(t, c.FileParsers, 2)
}

Expand Down
2 changes: 1 addition & 1 deletion dev-tools/kubernetes/filebeat/Dockerfile.debug
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21.11 as builder
FROM golang:1.22.4 as builder

ENV PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/go/bin:/usr/local/go/bin

Expand Down
2 changes: 1 addition & 1 deletion dev-tools/kubernetes/heartbeat/Dockerfile.debug
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21.11 as builder
FROM golang:1.22.4 as builder

ENV PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/go/bin:/usr/local/go/bin

Expand Down
2 changes: 1 addition & 1 deletion dev-tools/kubernetes/metricbeat/Dockerfile.debug
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21.11 as builder
FROM golang:1.22.4 as builder

ENV PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/go/bin:/usr/local/go/bin

Expand Down
2 changes: 1 addition & 1 deletion dev-tools/mage/crossbuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ func (b GolangCrossBuilder) Build() error {

// Ensure the proper platform is passed
// This fixes an issue where during arm64 linux build for the currently used docker image
// docker.elastic.co/beats-dev/golang-crossbuild:1.21.9-arm the image for amd64 arch is pulled
// docker.elastic.co/beats-dev/golang-crossbuild:1.22.4-arm the image for amd64 arch is pulled
// and causes problems when using native arch tools on the binaries that are built for arm64 arch.
if strings.HasPrefix(b.Platform, "linux/") {
args = append(args,
Expand Down
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module github.com/elastic/beats/v7

go 1.21.9

toolchain go1.21.11
go 1.22.4

require (
cloud.google.com/go/bigquery v1.55.0
Expand Down
2 changes: 1 addition & 1 deletion heartbeat/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21.11
FROM golang:1.22.4

RUN \
apt-get update \
Expand Down
2 changes: 1 addition & 1 deletion libbeat/docs/version.asciidoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
:stack-version: 8.15.0
:doc-branch: main
:go-version: 1.21.11
:go-version: 1.22.4
:release-state: unreleased
:python: 3.7
:docker: 1.12
Expand Down
2 changes: 1 addition & 1 deletion libbeat/processors/actions/drop_fields_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestNewDropFields(t *testing.T) {
assert.True(t, ok)
assert.Equal(t, []string{"third"}, processor.Fields)
assert.Equal(t, "<substring 'second'>", processor.RegexpFields[0].String())
assert.Equal(t, "field_(?-s:.)*1", processor.RegexpFields[1].String())
assert.Equal(t, "(?-s:field_.*1)", processor.RegexpFields[1].String())
})

t.Run("returns error when regexp field is badly written", func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21.11
FROM golang:1.22.4
COPY --from=docker:26.0.0-alpine3.19 /usr/local/bin/docker /usr/local/bin/

RUN \
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/http/_meta/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21.11
FROM golang:1.22.4

COPY test/main.go main.go

Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/nats/_meta/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ARG NATS_VERSION=2.0.4
FROM nats:$NATS_VERSION

# build stage
FROM golang:1.21.11 AS build-env
FROM golang:1.22.4 AS build-env
RUN apt-get install git mercurial gcc
RUN git clone https://github.com/nats-io/nats.go.git /nats-go
RUN cd /nats-go/examples/nats-bench && git checkout tags/v1.10.0 && go build .
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/vsphere/_meta/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG VSPHERE_GOLANG_VERSION
FROM golang:1.21.11
FROM golang:1.22.4

RUN apt-get install curl git
RUN go install github.com/vmware/govmomi/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion packetbeat/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21.11
FROM golang:1.22.4

RUN \
apt-get update \
Expand Down
2 changes: 1 addition & 1 deletion x-pack/functionbeat/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21.11
FROM golang:1.22.4

RUN \
apt-get update \
Expand Down
6 changes: 3 additions & 3 deletions x-pack/metricbeat/module/mssql/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ func NewConnection(uri string) (*sql.DB, error) {

// Check the connection before executing all queries to reduce the number
// of connection errors that we might encounter.
if err = db.Ping(); err != nil {
err = fmt.Errorf("error doing ping to db: %w", err)
}
//if err = db.Ping(); err != nil {
// err = fmt.Errorf("error doing ping to db: %w", err)
//}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Blocker]
I'm concerned it might not a safe option to remove this ping. sql.Open does not guarantee the connection to the DB works:

// Open may just validate its arguments without creating a connection
// to the database. To verify that the data source name is valid, call
// [DB.Ping].

and checking the driver we use, I only saw them parsing the connection string, not actually checking the connection.

In addition to that, the calls using mssql.NewConnection panic if there is an error. Thus, if I'm not missing something, the current design requires this check to ensure the connection works. If there is an error in the connection string, not a transient error that will fix itself, it'll either never be auto-fixed, the metrics will keeping throwing errors that might even be harder to understand or debug than if they were coming from mssql.NewConnection.

func init() {
mb.Registry.MustAddMetricSet("mssql", "performance", New,

func init() {
mb.Registry.MustAddMetricSet("mssql", "transaction_log", New,

I get it might better not make this check here, but then the metricsets using this connection should also be modified to better handle that situation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was only added for testing purposes, to see if it fixes the issue. Last thing I want to do is change code to update the golang version. It didn't fix the issue, so it should be reverted anyway.


return db, err
}
2 changes: 1 addition & 1 deletion x-pack/metricbeat/module/stan/_meta/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ARG STAN_VERSION=0.15.1
FROM nats-streaming:$STAN_VERSION

# build stage
FROM golang:1.21.11 AS build-env
FROM golang:1.22.4 AS build-env
RUN apt-get install git mercurial gcc
RUN git clone https://github.com/nats-io/stan.go.git /stan-go
RUN cd /stan-go/examples/stan-bench && git checkout tags/v0.5.2 && go build .
Expand Down
Loading