Skip to content

Commit 76b5de5

Browse files
authored
[NET-4968] Upgrade Go to 1.21 (#20062)
* Upgrade Go to 1.21 * ci: detect Go backwards compatibility test version automatically For our submodules and other places we choose to test against previous Go versions, detect this version automatically from the current one rather than hard-coding it.
1 parent 1e351e2 commit 76b5de5

File tree

9 files changed

+48
-29
lines changed

9 files changed

+48
-29
lines changed

.changelog/20062.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:improvement
2+
Upgrade to use Go 1.21.6.
3+
```

.github/workflows/go-tests.yml

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -408,17 +408,19 @@ jobs:
408408
consul-license: ${{secrets.CONSUL_LICENSE}}
409409
datadog-api-key: "${{ !endsWith(github.repository, '-enterprise') && secrets.DATADOG_API_KEY || '' }}"
410410

411-
go-test-api-1-19:
411+
go-test-api-backwards-compatibility:
412+
name: go-test-api-${{ needs.get-go-version.outputs.go-version-previous }}
412413
needs:
413414
- setup
415+
- get-go-version
414416
- dev-build
415417
uses: ./.github/workflows/reusable-unit.yml
416418
with:
417419
directory: api
418420
runs-on: ${{ needs.setup.outputs.compute-large }}
419421
repository-name: ${{ github.repository }}
420422
go-tags: "${{ github.event.repository.name == 'consul-enterprise' && 'consulent consuldev' || '' }}"
421-
go-version: "1.19"
423+
go-version: ${{ needs.get-go-version.outputs.go-version-previous }}
422424
permissions:
423425
id-token: write # NOTE: this permission is explicitly required for Vault auth.
424426
contents: read
@@ -427,17 +429,18 @@ jobs:
427429
consul-license: ${{secrets.CONSUL_LICENSE}}
428430
datadog-api-key: "${{ !endsWith(github.repository, '-enterprise') && secrets.DATADOG_API_KEY || '' }}"
429431

430-
go-test-api-1-20:
432+
go-test-api:
431433
needs:
432434
- setup
435+
- get-go-version
433436
- dev-build
434437
uses: ./.github/workflows/reusable-unit.yml
435438
with:
436439
directory: api
437440
runs-on: ${{ needs.setup.outputs.compute-large }}
438441
repository-name: ${{ github.repository }}
439442
go-tags: "${{ github.event.repository.name == 'consul-enterprise' && 'consulent consuldev' || '' }}"
440-
go-version: "1.20"
443+
go-version: ${{ needs.get-go-version.outputs.go-version }}
441444
permissions:
442445
id-token: write # NOTE: this permission is explicitly required for Vault auth.
443446
contents: read
@@ -446,17 +449,19 @@ jobs:
446449
consul-license: ${{secrets.CONSUL_LICENSE}}
447450
datadog-api-key: "${{ !endsWith(github.repository, '-enterprise') && secrets.DATADOG_API_KEY || '' }}"
448451

449-
go-test-sdk-1-19:
452+
go-test-sdk-backwards-compatibility:
453+
name: go-test-sdk-${{ needs.get-go-version.outputs.go-version-previous }}
450454
needs:
451455
- setup
456+
- get-go-version
452457
- dev-build
453458
uses: ./.github/workflows/reusable-unit.yml
454459
with:
455460
directory: sdk
456461
runs-on: ${{ needs.setup.outputs.compute-large }}
457462
repository-name: ${{ github.repository }}
458463
go-tags: "${{ github.event.repository.name == 'consul-enterprise' && 'consulent consuldev' || '' }}"
459-
go-version: "1.19"
464+
go-version: ${{ needs.get-go-version.outputs.go-version-previous }}
460465
permissions:
461466
id-token: write # NOTE: this permission is explicitly required for Vault auth.
462467
contents: read
@@ -465,17 +470,18 @@ jobs:
465470
consul-license: ${{secrets.CONSUL_LICENSE}}
466471
datadog-api-key: "${{ !endsWith(github.repository, '-enterprise') && secrets.DATADOG_API_KEY || '' }}"
467472

468-
go-test-sdk-1-20:
473+
go-test-sdk:
469474
needs:
470475
- setup
476+
- get-go-version
471477
- dev-build
472478
uses: ./.github/workflows/reusable-unit.yml
473479
with:
474480
directory: sdk
475481
runs-on: ${{ needs.setup.outputs.compute-large }}
476482
repository-name: ${{ github.repository }}
477483
go-tags: "${{ github.event.repository.name == 'consul-enterprise' && 'consulent consuldev' || '' }}"
478-
go-version: "1.20"
484+
go-version: ${{ needs.get-go-version.outputs.go-version }}
479485
permissions:
480486
id-token: write # NOTE: this permission is explicitly required for Vault auth.
481487
contents: read
@@ -521,10 +527,10 @@ jobs:
521527
- go-test-race
522528
- go-test-envoyextensions
523529
- go-test-troubleshoot
524-
- go-test-api-1-19
525-
- go-test-api-1-20
526-
- go-test-sdk-1-19
527-
- go-test-sdk-1-20
530+
- go-test-api-backwards-compatibility
531+
- go-test-api
532+
- go-test-sdk-backwards-compatibility
533+
- go-test-sdk
528534
- go-test-32bit
529535
# - go-test-s390x
530536
runs-on: ${{ fromJSON(needs.setup.outputs.compute-small) }}

.github/workflows/reusable-get-go-version.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@ on:
66
go-version:
77
description: "The Go version detected by this workflow"
88
value: ${{ jobs.get-go-version.outputs.go-version }}
9+
go-version-previous:
10+
description: "The Go version (MAJOR.MINOR) prior to the current one, used for backwards compatibility testing"
11+
value: ${{ jobs.get-go-version.outputs.go-version-previous }}
912

1013
jobs:
1114
get-go-version:
1215
name: "Determine Go toolchain version"
1316
runs-on: ubuntu-latest
1417
outputs:
1518
go-version: ${{ steps.get-go-version.outputs.go-version }}
19+
go-version-previous: ${{ steps.get-go-version.outputs.go-version-previous }}
1620
steps:
1721
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
1822
- name: Determine Go version
@@ -32,3 +36,7 @@ jobs:
3236
GO_VERSION=$(head -n 1 .go-version)
3337
echo "Building with Go ${GO_VERSION}"
3438
echo "go-version=${GO_VERSION}" >> $GITHUB_OUTPUT
39+
GO_MINOR_VERSION=${GO_VERSION%.*}
40+
GO_VERSION_PREVIOUS="${GO_MINOR_VERSION%.*}.$((${GO_MINOR_VERSION#*.}-1))"
41+
echo "Previous version ${GO_VERSION_PREVIOUS}"
42+
echo "go-version-previous=${GO_VERSION_PREVIOUS}" >> $GITHUB_OUTPUT

.github/workflows/reusable-lint.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,12 @@ jobs:
5151
with:
5252
go-version: ${{ inputs.go-version }}
5353
- run: go env
54+
- name: Set golangci-lint version
55+
run: echo "GOLANGCI_LINT_VERSION=$(make --no-print-directory print-GOLANGCI_LINT_VERSION)" >> $GITHUB_ENV
5456
- name: lint-${{ matrix.directory }}
5557
uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299 # v3.6.0
5658
with:
5759
working-directory: ${{ matrix.directory }}
58-
version: v1.51.1
60+
version: ${{ env.GOLANGCI_LINT_VERSION }}
5961
args: --build-tags="${{ env.GOTAGS }}" -v
6062
skip-cache: true

.go-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.20.12
1+
1.21.6

.golangci.yml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,14 @@ linters-settings:
9898
- google.golang.org/protobuf
9999

100100
depguard:
101-
list-type: denylist
102-
include-go-root: true
103-
# A list of packages for the list type specified.
104-
# Default: []
105-
packages:
106-
- net/rpc
107-
# A list of packages for the list type specified.
108-
# Specify an error message to output when a denied package is used.
109-
# Default: []
110-
packages-with-error-message:
111-
- net/rpc: "only use forked copy in github.com/hashicorp/consul-net-rpc/net/rpc"
112-
- github.com/golang/protobuf: "only use google.golang.org/protobuf"
101+
rules:
102+
main:
103+
listMode: lax
104+
deny:
105+
- pkg: net/rpc
106+
desc: "only use forked copy in github.com/hashicorp/consul-net-rpc/net/rpc"
107+
- pkg: github.com/golang/protobuf
108+
desc: "only use google.golang.org/protobuf"
113109

114110
run:
115111
timeout: 10m

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ GO_MODULES := $(shell find . -name go.mod -exec dirname {} \; | grep -v "proto-g
1010
# These version variables can either be a valid string for "go install <module>@<version>"
1111
# or the string @DEV to imply use what is currently installed locally.
1212
###
13-
GOLANGCI_LINT_VERSION='v1.51.1'
13+
GOLANGCI_LINT_VERSION='v1.55.2'
1414
MOCKERY_VERSION='v2.37.1'
1515
BUF_VERSION='v1.26.0'
1616

api/api_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -717,8 +717,11 @@ func TestAPI_ClientTLSOptions(t *testing.T) {
717717

718718
// Should fail
719719
_, err = client.Agent().Self()
720-
if err == nil || !strings.Contains(err.Error(), "bad certificate") {
721-
t.Fatal(err)
720+
// Check for one of the possible cert error messages
721+
// See https://cs.opensource.google/go/go/+/62a994837a57a7d0c58bb364b580a389488446c9
722+
if err == nil || !(strings.Contains(err.Error(), "tls: bad certificate") ||
723+
strings.Contains(err.Error(), "tls: certificate required")) {
724+
t.Fatalf("expected tls certificate error, but got '%v'", err)
722725
}
723726
})
724727

internal/mesh/internal/controllers/sidecarproxy/builder/local_app.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ func destinationRulesByPort(allPorts []string, destinationRules []*pbauth.Destin
138138
return out
139139
}
140140

141+
//nolint:unparam
141142
func convertDestinationRule(allPorts []string, dr *pbauth.DestinationRule) ([]string, DestinationRule) {
142143
ports := make(map[string]struct{})
143144
if len(dr.PortNames) > 0 {

0 commit comments

Comments
 (0)