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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NET-4968] Upgrade Go to 1.21 #20062

Merged
merged 2 commits into from
Jan 12, 2024
Merged

[NET-4968] Upgrade Go to 1.21 #20062

merged 2 commits into from
Jan 12, 2024

Conversation

zalimeni
Copy link
Member

@zalimeni zalimeni commented Dec 22, 2023

Description

Upgrade Go to 1.21.

This is needed in advance of the EOL of Go 1.20 ~Feb. 1. The ideal timing is before our next patch release scheduled for the end of January.

A follow-up change will introduce toolchain directives to pin to the latest version; the hope is to use a root-level go.work to accomplish this, which requires some additional changes to support. See #20058 for more context.

That PR should set this change up to cleanly backport and sync without intervention 馃馃徎

Testing & Reproduction steps

Tests continue to pass, and Go 1.21 can be observed as the output of get-go-version.

PR Checklist

  • updated test coverage
  • external facing docs updated
  • appropriate backport labels added
  • not a security concern

@zalimeni zalimeni force-pushed the zalimeni/use-go-version-file branch 4 times, most recently from d02fcc3 to 9379260 Compare January 3, 2024 17:18
@zalimeni zalimeni force-pushed the zalimeni/go-1.21 branch 2 times, most recently from 6e5b640 to 31ea777 Compare January 3, 2024 20:53
GOLANGCI_LINT_VERSION='v1.51.1'
GOLANGCI_LINT_VERSION='v1.55.2'
Copy link
Member Author

Choose a reason for hiding this comment

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

Needed for compatibility w/ Go 1.21

Comment on lines -101 to +108
list-type: denylist
include-go-root: true
# A list of packages for the list type specified.
# Default: []
packages:
- net/rpc
# A list of packages for the list type specified.
# Specify an error message to output when a denied package is used.
# Default: []
packages-with-error-message:
- net/rpc: "only use forked copy in github.com/hashicorp/consul-net-rpc/net/rpc"
- github.com/golang/protobuf: "only use google.golang.org/protobuf"
rules:
main:
listMode: lax
deny:
- pkg: net/rpc
desc: "only use forked copy in github.com/hashicorp/consul-net-rpc/net/rpc"
- pkg: github.com/golang/protobuf
desc: "only use google.golang.org/protobuf"
Copy link
Member Author

Choose a reason for hiding this comment

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

See golangci/golangci-lint#3906. Some other projects disabled this linter or replaced w/ another tool like Semgrep in response, but since we use custom rules and don't yet use Semgrep, I tried to adapt ours in-place.

@zalimeni zalimeni force-pushed the zalimeni/go-1.21 branch 4 times, most recently from d25fe6c to eb9e190 Compare January 4, 2024 16:48
@zalimeni zalimeni changed the title Upgrade Go to 1.21 [NET-4968] Upgrade Go to 1.21 Jan 5, 2024
Base automatically changed from zalimeni/use-go-version-file to main January 8, 2024 22:18
@zalimeni zalimeni added backport/1.15 This release series is no longer active on CE. Use backport/ent/1.15. backport/1.16 This release series is no longer active on CE. Use backport/ent/1.16. backport/1.17 This release series is no longer active on CE. Use backport/ent/1.17. labels Jan 11, 2024
@zalimeni zalimeni marked this pull request as ready for review January 12, 2024 01:31
@@ -0,0 +1,3 @@
```release-note:improvement
Upgrade to use Go 1.21.6.
Copy link
Member Author

Choose a reason for hiding this comment

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

@curtbushko FYI for K8s + DP bumps, we got 1.21.6 earlier this week

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.
Comment on lines -411 to +412
go-test-api-1-19:
go-test-api-backwards-compatibility:
name: go-test-api-${{ needs.get-go-version.outputs.go-version-previous }}
Copy link
Member Author

@zalimeni zalimeni Jan 12, 2024

Choose a reason for hiding this comment

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

Prior art: #10488

The second commit in this PR (e71ae3a) automates the version selection so we don't have to remember to bump it every time we upgrade the minor version of Go.

@@ -446,17 +449,19 @@ jobs:
consul-license: ${{secrets.CONSUL_LICENSE}}
datadog-api-key: "${{ !endsWith(github.repository, '-enterprise') && secrets.DATADOG_API_KEY || '' }}"

go-test-sdk-1-19:
go-test-sdk-backwards-compatibility:
Copy link
Member

Choose a reason for hiding this comment

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

I love this. No more twiddling versions whenever we update the go major version.

@@ -138,6 +138,7 @@ func destinationRulesByPort(allPorts []string, destinationRules []*pbauth.Destin
return out
}

//nolint:unparam
Copy link
Member

Choose a reason for hiding this comment

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

Just curious but why was this necessary. AFAICT allPorts and dr are both used in the function.

Copy link
Member

Choose a reason for hiding this comment

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

Or is the linter even smarter and figuring out that one of the two is always nil based on other code.

Copy link
Member Author

@zalimeni zalimeni Jan 12, 2024

Choose a reason for hiding this comment

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

I believe the latter - that was my best explanation for why it suddenly started failing on the linter upgrade (same question you asked led me to notice the same)

Copy link
Contributor

@curtbushko curtbushko left a comment

Choose a reason for hiding this comment

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

Looks great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/1.15 This release series is no longer active on CE. Use backport/ent/1.15. backport/1.16 This release series is no longer active on CE. Use backport/ent/1.16. backport/1.17 This release series is no longer active on CE. Use backport/ent/1.17.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants