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

Upgrade to Go1.18 #13201

Merged
merged 5 commits into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all 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 .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ experimental:
templates:
job_template: &job_template
docker:
- image: datadog/datadog-agent-runner-circle:go11711
- image: datadog/datadog-agent-runner-circle:go1185
environment:
USE_SYSTEM_LIBS: "1"
working_directory: /go/src/github.com/DataDog/datadog-agent
Expand Down
2 changes: 1 addition & 1 deletion .circleci/images/runner/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ RUN set -ex \
ssh

# Golang
ENV GIMME_GO_VERSION 1.17.11
ENV GIMME_GO_VERSION 1.18.5
ENV GOROOT /root/.gimme/versions/go$GIMME_GO_VERSION.linux.amd64
ENV GOPATH /go
ENV PATH $GOROOT/bin:$GOPATH/bin:$PATH
Expand Down
12 changes: 6 additions & 6 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ variables:
S3_DSD6_URI: s3://dsd6-staging
RELEASE_VERSION_6: nightly
RELEASE_VERSION_7: nightly-a7
DATADOG_AGENT_BUILDIMAGES: v9405677-746a71d
DATADOG_AGENT_BUILDERS: v8333476-cd1c34b
DATADOG_AGENT_WINBUILDIMAGES: v9405677-746a71d
DATADOG_AGENT_ARMBUILDIMAGES: v9405677-746a71d
DATADOG_AGENT_SYSPROBE_BUILDIMAGES: v8364396-f91ff4f
DATADOG_AGENT_NIKOS_BUILDIMAGES: v8364396-f91ff4f
DATADOG_AGENT_BUILDIMAGES: v9472974-a8f8b46
DATADOG_AGENT_BUILDERS: v9531714-74df2d8
DATADOG_AGENT_WINBUILDIMAGES: v9472974-a8f8b46
DATADOG_AGENT_ARMBUILDIMAGES: v9472974-a8f8b46
DATADOG_AGENT_SYSPROBE_BUILDIMAGES: v9472974-a8f8b46
DATADOG_AGENT_NIKOS_BUILDIMAGES: v9472974-a8f8b46
DATADOG_AGENT_EMBEDDED_PATH: /opt/datadog-agent/embedded
DOCKER_X64_BUILDER: v2718644-9ce6565-18.09.6-py3
NIKOS_INSTALL_DIR: /opt/datadog-agent/embedded/nikos
Expand Down
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.17.11
1.18.5
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ and development, is located under [the docs directory](docs) of the present repo
## Getting started

To build the Agent you need:
* [Go](https://golang.org/doc/install) 1.17 or later. You'll also need to set your `$GOPATH` and have `$GOPATH/bin` in your path.
* [Go](https://golang.org/doc/install) 1.18 or later. You'll also need to set your `$GOPATH` and have `$GOPATH/bin` in your path.
* Python 3.7+ along with development libraries for tooling. You will also need Python 2.7 if you are building the Agent with Python 2 support.
* Python dependencies. You may install these with `pip install -r requirements.txt`
This will also pull in [Invoke](http://www.pyinvoke.org) if not yet installed.
Expand Down
6 changes: 3 additions & 3 deletions devenv/scripts/Install-DevEnv.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ Write-Host -ForegroundColor Yellow -BackgroundColor DarkGreen '- Installing Gola
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'

Write-Host -ForegroundColor Green "Installing go 1.17.11"
Write-Host -ForegroundColor Green "Installing go 1.18.5"

$gozip = "https://dl.google.com/go/go1.17.11.windows-amd64.zip"
$gozip = "https://dl.google.com/go/go1.18.5.windows-amd64.zip"
if ($Env:TARGET_ARCH -eq "x86") {
$gozip = "https://dl.google.com/go/go1.17.11.windows-386.zip"
$gozip = "https://dl.google.com/go/go1.18.5.windows-386.zip"
}

$out = 'c:\go.zip'
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/agent_dev_env.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ variables (see Invoke docs for more details).

## Golang

You must [install Golang](https://golang.org/doc/install) version `1.17.11` or
You must [install Golang](https://golang.org/doc/install) version `1.18.5` or
higher. Make sure that `$GOPATH/bin` is in your `$PATH` otherwise `invoke`
cannot use any additional tool it might need.

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/DataDog/datadog-agent

go 1.17
go 1.18
paulcacheux marked this conversation as resolved.
Show resolved Hide resolved

// v0.8.0 was tagged long ago, and appared on pkg.go.dev. We do not want any tagged version
// to appear there. The trick to accomplish this is to make a new version (in this case v0.9.0)
Expand Down
2 changes: 1 addition & 1 deletion internal/tools/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/DataDog/datadog-agent/internal/tools

go 1.17
go 1.18

require (
github.com/frapposelli/wwhrd v0.4.0
Expand Down
2 changes: 1 addition & 1 deletion internal/tools/independent-lint/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/DataDog/datadog-agent/cmd/independent-lint

go 1.17
go 1.18

require golang.org/x/mod v0.5.1

Expand Down
2 changes: 1 addition & 1 deletion internal/tools/modparser/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/DataDog/datadog-agent/internal/tools/modparser

go 1.17
go 1.18

require (
github.com/stretchr/testify v1.7.0
Expand Down
2 changes: 1 addition & 1 deletion internal/tools/modparser/testdata/match/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/DataDog/datadog-agent/internal/tools/modparser/testdata/match

go 1.17
go 1.18

require (
github.com/DataDog/datadog-agent/pkg/test v0.65.3
Expand Down
2 changes: 1 addition & 1 deletion internal/tools/modparser/testdata/nomatch/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/DataDog/datadog-agent/internal/tools/modparser/testdata/nomatch

go 1.17
go 1.18

require (
github.com/DataDog/datadog-not-agent/pkg/test v0.65.3
Expand Down
2 changes: 1 addition & 1 deletion internal/tools/proto/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/DataDog/datadog-agent/internal/tools/proto

go 1.17
go 1.18

require (
github.com/golang/mock v1.5.0
Expand Down
1 change: 1 addition & 0 deletions pkg/dogstatsd/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

// Package dogstatsd implements DogStatsD.
package dogstatsd

import (
Expand Down
7 changes: 3 additions & 4 deletions pkg/dogstatsd/parse_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package dogstatsd
import (
"bytes"
"fmt"
"math"

"github.com/DataDog/datadog-agent/pkg/util/log"
)
Expand Down Expand Up @@ -92,9 +93,7 @@ func parseHeader(rawHeader []byte) (eventHeader, error) {

// Convert title length to workable type and do a basic validity check on value
titleLength, err := parseInt64(rawTitleLength)
// Before Go 1.17, we can use the following trick to define MaxInt
const MaxInt = ^uint(0) >> 1
if err != nil || titleLength < 0 || titleLength > int64(MaxInt) {
if err != nil || titleLength < 0 || titleLength > int64(math.MaxInt) {
return eventHeader{}, fmt.Errorf("invalid event header: %q", rawHeader)
}

Expand All @@ -105,7 +104,7 @@ func parseHeader(rawHeader []byte) (eventHeader, error) {

// Convert text length to workable type and do a basic validity check on value
textLength, err := parseInt64(rawTextLength)
if err != nil || textLength < 0 || textLength > int64(MaxInt) {
if err != nil || textLength < 0 || textLength > int64(math.MaxInt) {
return eventHeader{}, fmt.Errorf("invalid event header: %q", rawHeader)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/otlp/model/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/DataDog/datadog-agent/pkg/otlp/model

go 1.17
go 1.18

replace github.com/DataDog/datadog-agent/pkg/quantile => ../../quantile

Expand Down
2 changes: 1 addition & 1 deletion pkg/quantile/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/DataDog/datadog-agent/pkg/quantile

go 1.17
go 1.18

require (
github.com/DataDog/sketches-go v1.4.1
Expand Down
2 changes: 1 addition & 1 deletion pkg/remoteconfig/state/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/DataDog/datadog-agent/pkg/remoteconfig/state

go 1.17
go 1.18

require (
github.com/stretchr/testify v1.7.1
Expand Down
2 changes: 1 addition & 1 deletion pkg/security/secl/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/DataDog/datadog-agent/pkg/security/secl

go 1.17
go 1.18

require (
github.com/Masterminds/semver v1.5.0
Expand Down
2 changes: 1 addition & 1 deletion pkg/trace/agent/fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

//go:build go1.18
//go:build go1.18 && !windows

package agent

Expand Down
2 changes: 1 addition & 1 deletion pkg/trace/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/DataDog/datadog-agent/pkg/trace

go 1.17
go 1.18

// NOTE: Prefer using simple `require` directives instead of using `replace` if possible.
// See https://github.com/DataDog/datadog-agent/blob/main/docs/dev/gomodreplace.md
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/cgroups/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/DataDog/datadog-agent/pkg/util/cgroups

go 1.17
go 1.18

replace (
github.com/DataDog/datadog-agent/pkg/util/log => ../log
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/log/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/DataDog/datadog-agent/pkg/util/log

go 1.17
go 1.18

replace github.com/DataDog/datadog-agent/pkg/util/scrubber => ../scrubber

Expand Down
2 changes: 1 addition & 1 deletion pkg/util/scrubber/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/DataDog/datadog-agent/pkg/util/scrubber

go 1.17
go 1.18

require (
github.com/stretchr/testify v1.8.0
Expand Down
11 changes: 11 additions & 0 deletions releasenotes/notes/go1185-fd9d8b88c7c7a12e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Each section from every release note are combined when the
# CHANGELOG.rst is rendered. So the text needs to be worded so that
# it does not depend on any information only available in another
# section. This may mean repeating some details, but each section
# must be readable independently of the other.
#
# Each section note must be formatted as reStructuredText.
---
enhancements:
- |
Agents are now built with Go 1.18.5.
2 changes: 1 addition & 1 deletion test/e2e/containers/otlp_sender/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/DataDog/datadog-agent/tests/e2e/containers/otlp_sender

go 1.17
go 1.18

require (
go.opentelemetry.io/collector v0.51.0
Expand Down
2 changes: 1 addition & 1 deletion tools/gdb/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RUN rm -vf /etc/ssl/openssl.cnf
RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install -y gdb build-essential strace less vim

# Install go
RUN curl -fSL -o golang.tgz https://go.dev/dl/go1.17.11.linux-amd64.tar.gz
RUN curl -fSL -o golang.tgz https://go.dev/dl/go1.18.5.linux-amd64.tar.gz
RUN tar xzvf golang.tgz
RUN ln -s /go /goroot

Expand Down
2 changes: 1 addition & 1 deletion tools/retry_file_dump/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

module github.com/DataDog/datadog-agent/tools/retry_file_dump

go 1.17
go 1.18

require github.com/golang/protobuf v1.4.3

Expand Down