Skip to content

Commit

Permalink
upgrade Go to 1.20.6 (#36000)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
AndersonQ authored and mergify[bot] committed Oct 16, 2023
1 parent 69b29de commit 65bd306
Show file tree
Hide file tree
Showing 23 changed files with 918 additions and 181 deletions.
4 changes: 4 additions & 0 deletions .go-version
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
<<<<<<< HEAD
1.19.12
=======
1.20.6
>>>>>>> a278734f11 (upgrade Go to 1.20.6 (#36000))
33 changes: 33 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ linters-settings:

gosimple:
# Select the Go version to target. The default is '1.13'.
<<<<<<< HEAD
go: "1.19.12"
=======
go: "1.20.6"
>>>>>>> a278734f11 (upgrade Go to 1.20.6 (#36000))

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 +124,31 @@ linters-settings:

staticcheck:
# Select the Go version to target. The default is '1.13'.
<<<<<<< HEAD
go: "1.19.12"
=======
go: "1.20.6"
>>>>>>> a278734f11 (upgrade Go to 1.20.6 (#36000))
checks: ["all"]

stylecheck:
# Select the Go version to target. The default is '1.13'.
<<<<<<< HEAD
go: "1.19.12"
=======
go: "1.20.6"
>>>>>>> a278734f11 (upgrade Go to 1.20.6 (#36000))
# Disabled:
# ST1005: error strings should not be capitalized
checks: ["all", "-ST1005"]

unused:
# Select the Go version to target. The default is '1.13'.
<<<<<<< HEAD
go: "1.19.12"
=======
go: "1.20.6"
>>>>>>> a278734f11 (upgrade Go to 1.20.6 (#36000))

gosec:
excludes:
Expand All @@ -141,3 +157,20 @@ linters-settings:
- G401 # Detect the usage of DES, RC4, MD5 or SHA1: Used in non-crypto contexts.
- G501 # Import blocklist: crypto/md5: Used in non-crypto contexts.
- G505 # Import blocklist: crypto/sha1: Used in non-crypto contexts.
<<<<<<< HEAD
=======

prealloc:
# IMPORTANT: we don't recommend using this linter before doing performance profiling.
# For most programs usage of prealloc will be a premature optimization.

# Report pre-allocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
# Default: true
simple: false
# Report pre-allocation suggestions on range loops.
# Default: true
range-loops: true
# Report pre-allocation suggestions on for loops.
# Default: false
for-loops: true
>>>>>>> a278734f11 (upgrade Go to 1.20.6 (#36000))
3 changes: 2 additions & 1 deletion CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
==== Breaking changes

*Affecting all Beats*

- Fix status reporting to Elastic-Agent when output configuration is invalid running under Elastic-Agent {pull}35719[35719]
- Upgrade Go to 1.20.6 {pull}36000[36000]

*Auditbeat*

Expand Down
47 changes: 47 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ Vagrant.configure("2") do |config|
c.vm.provision "shell", inline: $unixProvision, privileged: false
end

<<<<<<< HEAD
config.vm.define "archlinux", autostart: false do |c|
c.vm.box = "archlinux/archlinux"
c.vm.network :forwarded_port, guest: 22, host: 2239, id: "ssh", auto_correct: true
Expand All @@ -328,4 +329,50 @@ Vagrant.configure("2") do |config|
c.vm.provision "shell", inline: linuxGvmProvision, privileged: false
c.vm.provision "shell", inline: "pacman -Sy && pacman -S --noconfirm make gcc python python-pip git"
end
=======
config.vm.define "beats" do |nodeconfig|
nodeconfig.vm.box = "ubuntu/jammy64"

# We deliberately set a fully-qualified domain name for the VM; it helps
# test the FQDN feature flag.
nodeconfig.vm.hostname = "beats-dev.elastic.dev.internal"

nodeconfig.vm.network "private_network",
hostname: true,
ip: "192.168.56.44" # only 192.168.56.0/21 range allowed: https://www.virtualbox.org/manual/ch06.html#network_hostonly
nodeconfig.vm.network "forwarded_port",
guest: 4244,
host: 4244,
id: "delve"

nodeconfig.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
vb.gui = false
vb.customize ["modifyvm", :id, "--vram", "128"]
# Customize the amount of memory on the VM:
vb.memory = "4096"
end

nodeconfig.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get install -y \
build-essential \
curl \
delve \
make \
unzip
vim \
wget
curl -sL -o /tmp/go#{GO_VERSION}.linux-amd64.tar.gz https://go.dev/dl/go#{GO_VERSION}.linux-amd64.tar.gz
tar -C /usr/local -xzf /tmp/go#{GO_VERSION}.linux-amd64.tar.gz
curl -sL -o /tmp/mage_1.15.0_Linux-64bit.tar.gz https://github.com/magefile/mage/releases/download/v1.15.0/mage_1.15.0_Linux-64bit.tar.gz
tar -C /tmp -xf /tmp/mage_1.15.0_Linux-64bit.tar.gz
mv /tmp/mage /usr/local/bin/mage
echo "alias ll='ls -la'" > /etc/profile.d/ll.sh
echo 'export PATH=$PATH:/usr/local/go/bin' > /etc/profile.d/go.sh
echo 'export PATH=$PATH:$(go env GOPATH)/bin' >> /etc/profile.d/go.sh
SHELL
end

>>>>>>> a278734f11 (upgrade Go to 1.20.6 (#36000))
end
6 changes: 5 additions & 1 deletion auditbeat/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<<<<<<< HEAD
FROM golang:1.19.12
=======
FROM golang:1.20.6
>>>>>>> a278734f11 (upgrade Go to 1.20.6 (#36000))

RUN \
apt-get update \
Expand All @@ -11,7 +15,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" ]
10 changes: 9 additions & 1 deletion 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,21 @@ 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)
<<<<<<< HEAD
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)
>>>>>>> a278734f11 (upgrade Go to 1.20.6 (#36000))
}
}

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 65bd306

Please sign in to comment.