Skip to content

Commit

Permalink
Backport of Update go version to 1.19 into release/1.14.x (#15139)
Browse files Browse the repository at this point in the history
This pull request was automerged via backport-assistant
  • Loading branch information
hc-github-team-consul-core committed Oct 24, 2022
1 parent 0602b98 commit 35fb3cb
Show file tree
Hide file tree
Showing 66 changed files with 378 additions and 768 deletions.
3 changes: 3 additions & 0 deletions .changelog/15090.txt
@@ -0,0 +1,3 @@
```release-note:note
deps: Upgrade to use Go 1.19.2
```
2 changes: 1 addition & 1 deletion .circleci/bash_env.sh
Expand Up @@ -6,5 +6,5 @@ export GIT_DIRTY=$(test -n "`git status --porcelain`" && echo "+CHANGES" || true
export GIT_IMPORT=github.com/hashicorp/consul/version
# we're using this for build date because it's stable across platform builds
# the env -i and -noprofile are used to ensure we don't try to recursively call this profile when starting bash
export GIT_DATE=$(env -i /bin/bash --noprofile -norc ${CIRCLE_WORKING_DIRECTORY}/build-support/scripts/build-date.sh)
export GIT_DATE=$(env -i /bin/bash --noprofile -norc /home/circleci/project/build-support/scripts/build-date.sh)
export GOLDFLAGS="-X ${GIT_IMPORT}.GitCommit=${GIT_COMMIT}${GIT_DIRTY} -X ${GIT_IMPORT}.BuildDate=${GIT_DATE}"
24 changes: 11 additions & 13 deletions .circleci/config.yml
Expand Up @@ -22,7 +22,7 @@ references:
S3_ARTIFACT_BUCKET: consul-dev-artifacts-v2
BASH_ENV: .circleci/bash_env.sh
VAULT_BINARY_VERSION: 1.9.4
GO_VERSION: 1.18.1
GO_VERSION: 1.19.2
envoy-versions: &supported_envoy_versions
- &default_envoy_version "1.20.7"
- "1.21.5"
Expand All @@ -35,7 +35,7 @@ references:
images:
# When updating the Go version, remember to also update the versions in the
# workflows section for go-test-lib jobs.
go: &GOLANG_IMAGE docker.mirror.hashicorp.services/cimg/go:1.18.1
go: &GOLANG_IMAGE docker.mirror.hashicorp.services/cimg/go:1.19.2
ember: &EMBER_IMAGE docker.mirror.hashicorp.services/circleci/node:14-browsers
ubuntu: &UBUNTU_CI_IMAGE ubuntu-2004:202201-02
cache:
Expand Down Expand Up @@ -130,8 +130,6 @@ commands:
steps:
- attach_workspace:
at: /home/circleci/go/bin
- run: sudo apt-get update --allow-releaseinfo-change-suite --allow-releaseinfo-change-version && sudo apt-get install -y rsyslog
- run: sudo service rsyslog start
- run: go mod download
- run:
name: go test
Expand Down Expand Up @@ -1069,26 +1067,26 @@ workflows:
- dev-build: *filter-ignore-non-go-branches
- go-test:
requires: [dev-build]
- go-test-lib:
name: "go-test-api go1.17"
path: api
go-version: "1.17"
requires: [dev-build]
- go-test-lib:
name: "go-test-api go1.18"
path: api
go-version: "1.18"
requires: [dev-build]
- go-test-lib:
name: "go-test-sdk go1.17"
path: sdk
go-version: "1.17"
<<: *filter-ignore-non-go-branches
name: "go-test-api go1.19"
path: api
go-version: "1.19"
requires: [ dev-build ]
- go-test-lib:
name: "go-test-sdk go1.18"
path: sdk
go-version: "1.18"
<<: *filter-ignore-non-go-branches
- go-test-lib:
name: "go-test-sdk go1.19"
path: sdk
go-version: "1.19"
<<: *filter-ignore-non-go-branches
- go-test-race: *filter-ignore-non-go-branches
- go-test-32bit: *filter-ignore-non-go-branches
- noop
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/build.yml
Expand Up @@ -71,15 +71,15 @@ jobs:
strategy:
matrix:
include:
- {go: "1.18.1", goos: "linux", goarch: "386"}
- {go: "1.18.1", goos: "linux", goarch: "amd64"}
- {go: "1.18.1", goos: "linux", goarch: "arm"}
- {go: "1.18.1", goos: "linux", goarch: "arm64"}
- {go: "1.18.1", goos: "freebsd", goarch: "386"}
- {go: "1.18.1", goos: "freebsd", goarch: "amd64"}
- {go: "1.18.1", goos: "windows", goarch: "386"}
- {go: "1.18.1", goos: "windows", goarch: "amd64"}
- {go: "1.18.1", goos: "solaris", goarch: "amd64"}
- {go: "1.19.2", goos: "linux", goarch: "386"}
- {go: "1.19.2", goos: "linux", goarch: "amd64"}
- {go: "1.19.2", goos: "linux", goarch: "arm"}
- {go: "1.19.2", goos: "linux", goarch: "arm64"}
- {go: "1.19.2", goos: "freebsd", goarch: "386"}
- {go: "1.19.2", goos: "freebsd", goarch: "amd64"}
- {go: "1.19.2", goos: "windows", goarch: "386"}
- {go: "1.19.2", goos: "windows", goarch: "amd64"}
- {go: "1.19.2", goos: "solaris", goarch: "amd64"}
fail-fast: true

name: Go ${{ matrix.go }} ${{ matrix.goos }} ${{ matrix.goarch }} build
Expand Down Expand Up @@ -172,7 +172,7 @@ jobs:
matrix:
goos: [ darwin ]
goarch: [ "amd64", "arm64" ]
go: [ "1.18.1" ]
go: [ "1.19.2" ]
fail-fast: true

name: Go ${{ matrix.go }} ${{ matrix.goos }} ${{ matrix.goarch }} build
Expand Down
3 changes: 3 additions & 0 deletions .golangci.yml
Expand Up @@ -37,6 +37,9 @@ issues:
- linters: [staticcheck]
text: 'SA1019: "github.com/golang/protobuf/ptypes" is deprecated: Well-known types have specialized functionality directly injected into the generated packages for each message type. See the deprecation notice for each function for the suggested alternative.'

- linters: [staticcheck]
text: 'SA1019: "io/ioutil" has been deprecated since Go 1.16'

# An argument that always receives the same value is often not a problem.
- linters: [unparam]
text: 'always receives'
Expand Down
1 change: 0 additions & 1 deletion acl/errors.go
Expand Up @@ -63,7 +63,6 @@ func IsErrPermissionDenied(err error) bool {

// Arguably this should be some sort of union type.
// The usage of Cause and the rest of the fields is entirely disjoint.
//
type PermissionDeniedError struct {
Cause string

Expand Down
2 changes: 1 addition & 1 deletion agent/auto-config/auto_config.go
Expand Up @@ -225,7 +225,7 @@ func (ac *AutoConfig) introToken() (string, error) {

// recordInitialConfiguration is responsible for recording the AutoConfigResponse from
// the AutoConfig.InitialConfiguration RPC. It is an all-in-one function to do the following
// * update the Agent token in the token store
// - update the Agent token in the token store
func (ac *AutoConfig) recordInitialConfiguration(resp *pbautoconf.AutoConfigResponse) error {
ac.autoConfigResponse = resp

Expand Down
8 changes: 4 additions & 4 deletions agent/cache-types/connect_ca_leaf.go
Expand Up @@ -262,10 +262,10 @@ func (c *ConnectCALeaf) rootWatcher(ctx context.Context) {
//
// Somewhat arbitrarily the current strategy looks like this:
//
// 0 60% 90%
// Issued [------------------------------|===============|!!!!!] Expires
// 72h TTL: 0 ~43h ~65h
// 1h TTL: 0 36m 54m
// 0 60% 90%
// Issued [------------------------------|===============|!!!!!] Expires
// 72h TTL: 0 ~43h ~65h
// 1h TTL: 0 36m 54m
//
// Where |===| is the soft renewal period where we jitter for the first attempt
// and |!!!| is the danger zone where we just try immediately.
Expand Down
1 change: 1 addition & 0 deletions agent/cache-types/rpc.go
Expand Up @@ -3,6 +3,7 @@ package cachetype
// RPC is an interface that an RPC client must implement. This is a helper
// interface that is implemented by the agent delegate so that Type
// implementations can request RPC access.
//
//go:generate mockery --name RPC --inpackage
type RPC interface {
RPC(method string, args interface{}, reply interface{}) error
Expand Down
1 change: 1 addition & 0 deletions agent/cache/request.go
Expand Up @@ -8,6 +8,7 @@ import (
//
// This interface is typically implemented by request structures in
// the agent/structs package.
//
//go:generate mockery --name Request --inpackage
type Request interface {
// CacheInfo returns information used for caching this request.
Expand Down
1 change: 1 addition & 0 deletions agent/cache/type.go
Expand Up @@ -5,6 +5,7 @@ import (
)

// Type implements the logic to fetch certain types of data.
//
//go:generate mockery --name Type --inpackage
type Type interface {
// Fetch fetches a single unique item.
Expand Down
11 changes: 5 additions & 6 deletions agent/checks/check_test.go
Expand Up @@ -17,16 +17,17 @@ import (
"testing"
"time"

"github.com/hashicorp/go-uuid"
"github.com/stretchr/testify/require"
"golang.org/x/net/http2"
"golang.org/x/net/http2/h2c"

"github.com/hashicorp/consul/agent/mock"
"github.com/hashicorp/consul/agent/structs"
"github.com/hashicorp/consul/api"
"github.com/hashicorp/consul/sdk/freeport"
"github.com/hashicorp/consul/sdk/testutil"
"github.com/hashicorp/consul/sdk/testutil/retry"
"github.com/hashicorp/go-uuid"
"github.com/stretchr/testify/require"
http2 "golang.org/x/net/http2"
"golang.org/x/net/http2/h2c"
)

func uniqueID() string {
Expand Down Expand Up @@ -300,8 +301,6 @@ func TestCheckHTTP(t *testing.T) {
{code: 429, status: api.HealthWarning},

// critical
{code: 150, status: api.HealthCritical},
{code: 199, status: api.HealthCritical},
{code: 300, status: api.HealthCritical},
{code: 400, status: api.HealthCritical},
{code: 500, status: api.HealthCritical},
Expand Down
2 changes: 1 addition & 1 deletion agent/config/file_watcher.go
Expand Up @@ -47,7 +47,7 @@ type FileWatcherEvent struct {
Filenames []string
}

//NewFileWatcher create a file watcher that will watch all the files/folders from configFiles
// NewFileWatcher create a file watcher that will watch all the files/folders from configFiles
// if success a fileWatcher will be returned and a nil error
// otherwise an error and a nil fileWatcher are returned
func NewFileWatcher(configFiles []string, logger hclog.Logger) (Watcher, error) {
Expand Down
7 changes: 5 additions & 2 deletions agent/configentry/config_entry.go
Expand Up @@ -6,9 +6,12 @@ import (
)

// KindName is a value type useful for maps. You can use:
// map[KindName]Payload
//
// map[KindName]Payload
//
// instead of:
// map[string]map[string]Payload
//
// map[string]map[string]Payload
type KindName struct {
Kind string
Name string
Expand Down
5 changes: 3 additions & 2 deletions agent/connect/common_names.go
Expand Up @@ -45,9 +45,10 @@ func CompactUID() (string, error) {
// specific purpose.
//
// Format is:
// {provider}-{uniqueID_first8}.{pri|sec}.ca.<trust_domain_first_8>.consul
//
// trust domain is truncated to keep the whole name short
// {provider}-{uniqueID_first8}.{pri|sec}.ca.<trust_domain_first_8>.consul
//
// trust domain is truncated to keep the whole name short
func CACN(provider, uniqueID, trustDomain string, primaryDC bool) string {
providerSan := invalidDNSNameChars.ReplaceAllString(strings.ToLower(provider), "")
typ := "pri"
Expand Down
20 changes: 10 additions & 10 deletions agent/consul/acl.go
Expand Up @@ -225,19 +225,19 @@ type ACLResolverSettings struct {
// - Resolving roles remotely via an ACL.RoleResolve RPC
//
// Remote Resolution:
// Remote resolution can be done synchronously or asynchronously depending
// on the ACLDownPolicy in the Config passed to the resolver.
//
// When the down policy is set to async-cache and we have already cached values
// then go routines will be spawned to perform the RPCs in the background
// and then will update the cache with either the positive or negative result.
// Remote resolution can be done synchronously or asynchronously depending
// on the ACLDownPolicy in the Config passed to the resolver.
//
// When the down policy is set to extend-cache or the token/policy/role is not already
// cached then the same go routines are spawned to do the RPCs in the background.
// However in this mode channels are created to receive the results of the RPC
// and are registered with the resolver. Those channels are immediately read/blocked
// upon.
// When the down policy is set to async-cache and we have already cached values
// then go routines will be spawned to perform the RPCs in the background
// and then will update the cache with either the positive or negative result.
//
// When the down policy is set to extend-cache or the token/policy/role is not already
// cached then the same go routines are spawned to do the RPCs in the background.
// However in this mode channels are created to receive the results of the RPC
// and are registered with the resolver. Those channels are immediately read/blocked
// upon.
type ACLResolver struct {
config ACLResolverSettings
logger hclog.Logger
Expand Down
27 changes: 13 additions & 14 deletions agent/consul/acl_endpoint.go
Expand Up @@ -13,8 +13,8 @@ import (
"github.com/armon/go-metrics/prometheus"
"github.com/hashicorp/go-bexpr"
"github.com/hashicorp/go-hclog"
memdb "github.com/hashicorp/go-memdb"
uuid "github.com/hashicorp/go-uuid"
"github.com/hashicorp/go-memdb"
"github.com/hashicorp/go-uuid"

"github.com/hashicorp/consul/acl"
"github.com/hashicorp/consul/acl/resolver"
Expand Down Expand Up @@ -108,19 +108,18 @@ type ACL struct {
// fileBootstrapResetIndex retrieves the reset index specified by the administrator from
// the file on disk.
//
// Q: What is the bootstrap reset index?
// A: If you happen to lose acess to all tokens capable of ACL management you need a way
// to get back into your system. This allows an admin to write the current
// bootstrap "index" into a special file on disk to override the mechanism preventing
// a second token bootstrap. The index will be retrieved by a API call to /v1/acl/bootstrap
// When already bootstrapped this API will return the reset index necessary within
// the error response. Once set in the file, the bootstrap API can be used again to
// get a new token.
//
// Q: Why is the reset index not in the config?
// A: We want to be able to remove the reset index once we have used it. This prevents
// accidentally allowing bootstrapping yet again after a snapshot restore.
// Q: What is the bootstrap reset index?
// A: If you happen to lose acess to all tokens capable of ACL management you need a way
// to get back into your system. This allows an admin to write the current
// bootstrap "index" into a special file on disk to override the mechanism preventing
// a second token bootstrap. The index will be retrieved by a API call to /v1/acl/bootstrap
// When already bootstrapped this API will return the reset index necessary within
// the error response. Once set in the file, the bootstrap API can be used again to
// get a new token.
//
// Q: Why is the reset index not in the config?
// A: We want to be able to remove the reset index once we have used it. This prevents
// accidentally allowing bootstrapping yet again after a snapshot restore.
func (a *ACL) fileBootstrapResetIndex() uint64 {
// Determine the file path to check
path := filepath.Join(a.srv.config.DataDir, aclBootstrapReset)
Expand Down
1 change: 0 additions & 1 deletion agent/consul/authmethod/kubeauth/testing.go
Expand Up @@ -27,7 +27,6 @@ import (
//
// - POST /apis/authentication.k8s.io/v1/tokenreviews
// - GET /api/v1/namespaces/<NAMESPACE>/serviceaccounts/<NAME>
//
type TestAPIServer struct {
srv *httptest.Server
caCert string
Expand Down
4 changes: 2 additions & 2 deletions agent/consul/helper_test.go
Expand Up @@ -127,7 +127,7 @@ type clientOrServer interface {

// joinLAN is a convenience function for
//
// member.JoinLAN("127.0.0.1:"+leader.config.SerfLANConfig.MemberlistConfig.BindPort)
// member.JoinLAN("127.0.0.1:"+leader.config.SerfLANConfig.MemberlistConfig.BindPort)
func joinLAN(t *testing.T, member clientOrServer, leader *Server) {
t.Helper()
joinLANWithOptions(t, member, leader, true)
Expand Down Expand Up @@ -184,7 +184,7 @@ func joinLANWithOptions(t *testing.T, member clientOrServer, leader *Server, doM

// joinWAN is a convenience function for
//
// member.JoinWAN("127.0.0.1:"+leader.config.SerfWANConfig.MemberlistConfig.BindPort)
// member.JoinWAN("127.0.0.1:"+leader.config.SerfWANConfig.MemberlistConfig.BindPort)
func joinWAN(t *testing.T, member, leader *Server) {
t.Helper()
joinWANWithOptions(t, member, leader, true)
Expand Down

0 comments on commit 35fb3cb

Please sign in to comment.