Skip to content

Commit

Permalink
[7.17](backport #36000) upgrade Go to 1.20.6 (#36869)
Browse files Browse the repository at this point in the history
* upgrade Go to 1.20.6 (#36000)

* upgrade Go to 1.20.5

* ignore known issue with go tool cover

* capture cover output and check it for errors

* debug

* wip

* move ragel files to root directory

the //line directives used to point to the original "ragel" files were creating problems for the coverage tool. They were being reported without the 'parser/' directory. Causing the go tool cover to look for the wrong files and therefore failing.
Moving it all to the root directory fixes the problem.

* upgrade to go1.20.6

* .

* Revert "move ragel files to root directory"

This reverts commit 2b6a159.

* remove debug

* disable //line directives

* goimport

(cherry picked from commit a278734)

# Conflicts:
#	.go-version
#	.golangci.yml
#	Vagrantfile
#	auditbeat/Dockerfile
#	dev-tools/kubernetes/filebeat/Dockerfile.debug
#	dev-tools/kubernetes/heartbeat/Dockerfile.debug
#	dev-tools/kubernetes/metricbeat/Dockerfile.debug
#	dev-tools/mage/gotest.go
#	filebeat/input/syslog/rfc5424_parser.go
#	heartbeat/Dockerfile
#	libbeat/docs/version.asciidoc
#	libbeat/reader/syslog/rfc3164_test.go
#	libbeat/reader/syslog/rfc5424_test.go
#	metricbeat/Dockerfile
#	metricbeat/module/http/_meta/Dockerfile
#	metricbeat/module/nats/_meta/Dockerfile
#	packetbeat/Dockerfile
#	x-pack/functionbeat/Dockerfile
#	x-pack/metricbeat/module/stan/_meta/Dockerfile

* Resolve conflicts.

* Remove extra entries in CHANGELOG.next.asciidoc

* Remove extra files.

* Fix test coverage report in cef parser

* Run mage fmt

---------

Co-authored-by: Anderson Queiroz <[email protected]>
Co-authored-by: Craig MacKenzie <[email protected]>
  • Loading branch information
3 people committed Oct 24, 2023
1 parent 679a8f1 commit 124d238
Show file tree
Hide file tree
Showing 20 changed files with 327 additions and 261 deletions.
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.19.12
1.20.6
8 changes: 4 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ linters-settings:

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

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

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

stylecheck:
# Select the Go version to target. The default is '1.13'.
go: "1.19.12"
go: "1.20.6"
# 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.19.12"
go: "1.20.6"

gosec:
excludes:
Expand Down
4 changes: 2 additions & 2 deletions auditbeat/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19.12
FROM golang:1.20.6

RUN \
apt-get update \
Expand All @@ -11,7 +11,7 @@ RUN \
&& rm -rf /var/lib/apt/lists/*

# Use a virtualenv to avoid the PEP668 "externally managed environment" error caused by conflicts
# with the system Python installation. golang:1.19.10 uses Debian 12 which now enforces PEP668.
# with the system Python installation. golang:1.20.6 uses Debian 12 which now enforces PEP668.
ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
Expand Down
21 changes: 21 additions & 0 deletions dev-tools/kubernetes/filebeat/Dockerfile.debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM golang:1.20.6 as builder

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

ENV CGO_ENABLED=0

RUN go install github.com/go-delve/delve/cmd/[email protected]

COPY build/filebeat-debugger /usr/share/filebeat/filebeat-debugger

FROM alpine:3.15

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

WORKDIR /usr/share/filebeat

COPY --from=builder /go/bin/dlv /go/bin/dlv
COPY --from=builder /usr/share/filebeat/filebeat-debugger /usr/share/filebeat/filebeat-debugger

ENTRYPOINT ["dlv", "--headless", "--listen=:56268", "--api-version=2", "--log", "--log-output", "debugger", "exec", "/usr/share/filebeat/filebeat-debugger", "--"]
CMD [ "-e" ]
21 changes: 21 additions & 0 deletions dev-tools/kubernetes/heartbeat/Dockerfile.debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM golang:1.20.6 as builder

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

ENV CGO_ENABLED=0

RUN go install github.com/go-delve/delve/cmd/[email protected]

COPY build/heartbeat-debugger /usr/share/heartbeat/heartbeat-debugger

FROM alpine:3.16

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

WORKDIR /usr/share/heartbeat

COPY --from=builder /go/bin/dlv /go/bin/dlv
COPY --from=builder /usr/share/heartbeat/heartbeat-debugger /usr/share/heartbeat/heartbeat-debugger

ENTRYPOINT ["dlv", "--headless", "--listen=:56268", "--api-version=2", "--log", "--log-output", "debugger", "exec", "/usr/share/heartbeat/heartbeat-debugger", "--"]
CMD [ "-e" ]
21 changes: 21 additions & 0 deletions dev-tools/kubernetes/metricbeat/Dockerfile.debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM golang:1.20.6 as builder

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

ENV CGO_ENABLED=0

RUN go install github.com/go-delve/delve/cmd/[email protected]

COPY build/metricbeat-debugger /usr/share/metricbeat/metricbeat-debugger

FROM alpine:3.15

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

WORKDIR /usr/share/metricbeat

COPY --from=builder /go/bin/dlv /go/bin/dlv
COPY --from=builder /usr/share/metricbeat/metricbeat-debugger /usr/share/metricbeat/metricbeat-debugger

ENTRYPOINT ["dlv", "--headless", "--listen=:56268", "--api-version=2", "--log", "--log-output", "debugger", "exec", "/usr/share/metricbeat/metricbeat-debugger", "--"]
CMD [ "-e" ]
9 changes: 6 additions & 3 deletions dev-tools/mage/gotest.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func DefaultTestBinaryArgs() TestBinaryArgs {
}

// GoTestIntegrationForModule executes the Go integration tests sequentially.
// Currently all test cases must be present under "./module" directory.
// Currently, all test cases must be present under "./module" directory.
//
// Motivation: previous implementation executed all integration tests at once,
// causing high CPU load, high memory usage and resulted in timeouts.
Expand Down Expand Up @@ -295,13 +295,16 @@ func GoTest(ctx context.Context, params GoTestArgs) error {
// Generate a HTML code coverage report.
var htmlCoverReport string
if params.CoverageProfileFile != "" {

htmlCoverReport = strings.TrimSuffix(params.CoverageProfileFile,
filepath.Ext(params.CoverageProfileFile)) + ".html"

coverToHTML := sh.RunCmd("go", "tool", "cover",
"-html="+params.CoverageProfileFile,
"-o", htmlCoverReport)
if err = coverToHTML(); err != nil {
return errors.Wrap(err, "failed to write HTML code coverage report")

if err := coverToHTML(); err != nil {
return fmt.Errorf("failed to write HTML code coverage report: %w", err)
}
}

Expand Down
20 changes: 10 additions & 10 deletions dev-tools/mage/gotest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,41 +210,41 @@ var wantTestAssertOutput = `(?sm:
Error Trace: gotest_test.go:\d+.*
Error: Should be true.*
Test: TestGoTest_Helper_AssertOutput/assert_fails.*
--- FAIL: TestGoTest_Helper_AssertOutput/assert_fails .*
=== FAIL: dev-tools/mage TestGoTest_Helper_AssertOutput/assert_with_message .*
gotest_test.go:\d+:.*
Error Trace: gotest_test.go:\d+.*
Error: Should be true.*
Test: TestGoTest_Helper_AssertOutput/assert_with_message.*
Messages: My message.*
--- FAIL: TestGoTest_Helper_AssertOutput/assert_with_message .*
=== FAIL: dev-tools/mage TestGoTest_Helper_AssertOutput/assert_with_messagef .*
gotest_test.go:\d+:.*
Error Trace: gotest_test.go:\d+.*
Error: Should be true.*
Test: TestGoTest_Helper_AssertOutput/assert_with_messagef.*
Messages: My message with arguments: 42.*
--- FAIL: TestGoTest_Helper_AssertOutput/assert_with_messagef .*
=== FAIL: dev-tools/mage TestGoTest_Helper_AssertOutput/require_fails .*
gotest_test.go:\d+:.*
Error Trace: gotest_test.go:\d+.*
Error: Should be true.*
Test: TestGoTest_Helper_AssertOutput/require_fails.*
--- FAIL: TestGoTest_Helper_AssertOutput/require_fails .*
=== FAIL: dev-tools/mage TestGoTest_Helper_AssertOutput/require_with_message .*
gotest_test.go:\d+:.*
Error Trace: gotest_test.go:\d+.*
Error: Should be true.*
Test: TestGoTest_Helper_AssertOutput/require_with_message.*
Messages: My message.*
--- FAIL: TestGoTest_Helper_AssertOutput/require_with_message .*
=== FAIL: dev-tools/mage TestGoTest_Helper_AssertOutput/require_with_messagef .*
gotest_test.go:\d+:.*
Error Trace: gotest_test.go:\d+.*
Error: Should be true.*
Test: TestGoTest_Helper_AssertOutput/require_with_messagef.*
Messages: My message with arguments: 42.*
--- FAIL: TestGoTest_Helper_AssertOutput/require_with_messagef .*
=== FAIL: dev-tools/mage TestGoTest_Helper_AssertOutput/equals_map .*
gotest_test.go:\d+:.*
Error Trace: gotest_test.go:\d+.*
Expand Down Expand Up @@ -306,17 +306,17 @@ var wantTestLogOutput = `(?sm:
gotest_test.go:\d+: printf style log message: 42.*
gotest_test.go:\d+: Log should fail.*
gotest_test.go:\d+: Log should fail with printf style log: 23.*
--- FAIL: TestGoTest_Helper_LogOutput/on_error.*
=== FAIL: dev-tools/mage TestGoTest_Helper_LogOutput/on_fatal.*
gotest_test.go:\d+: Log message should be printed.*
gotest_test.go:\d+: printf style log message: 42.*
gotest_test.go:\d+: Log should fail.*
--- FAIL: TestGoTest_Helper_LogOutput/on_fatal.*
=== FAIL: dev-tools/mage TestGoTest_Helper_LogOutput/on_fatalf.*
gotest_test.go:\d+: Log message should be printed.*
gotest_test.go:\d+: printf style log message: 42.*
gotest_test.go:\d+: Log should fail with printf style log: 42.*
--- FAIL: TestGoTest_Helper_LogOutput/on_fatalf.*
=== FAIL: dev-tools/mage TestGoTest_Helper_LogOutput/with_newlines.*
gotest_test.go:\d+: Log.*
message.*
Expand All @@ -336,7 +336,7 @@ var wantTestLogOutput = `(?sm:
style.*
log:.*
42.*
--- FAIL: TestGoTest_Helper_LogOutput/with_newlines.*
=== FAIL: dev-tools/mage TestGoTest_Helper_LogOutput.*
DONE 5 tests, 5 failures in.*
)`
Expand Down
8 changes: 4 additions & 4 deletions filebeat/input/syslog/format_check.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 124d238

Please sign in to comment.