Skip to content

Commit 776b9fb

Browse files
authored
bump golang to v1.23 (#5683)
1 parent d59642e commit 776b9fb

File tree

19 files changed

+40
-26
lines changed

19 files changed

+40
-26
lines changed

Diff for: .github/workflows/ci.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,21 @@ jobs:
2727
# see https://github.community/t/github-sha-isnt-the-value-expected/17903/2
2828
# so we checkout the repo with `fetch-depth: 2` and let `codecov/codecov-action` to retrieve the real commit hash.
2929
- name: Check out code into the Go module directory
30-
uses: actions/checkout@v2
30+
uses: actions/checkout@v4
3131
with:
3232
path: go/src/github.com/${{ github.repository }}
3333
fetch-depth: 2
3434
- name: Set up Go
35-
uses: actions/setup-go@v3
35+
uses: actions/setup-go@v5
3636
with:
3737
go-version-file: go/src/github.com/${{ github.repository }}/go.mod
38-
go-version: 1.21.3
38+
cache-dependency-path: "**/*.sum"
3939
- name: Set vars
4040
run: |
4141
echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_ENV
4242
echo "GOMODCACHE=$(go env GOMODCACHE)" >> $GITHUB_ENV
4343
- name: Try to use build cache
44-
uses: actions/cache@v3
44+
uses: actions/cache@v4
4545
with:
4646
path: |
4747
${{ env.GOCACHE }}

Diff for: .golangci.yml

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ linters-settings:
2222
- G201 # Rule: SQL query construction using format string
2323
- G114 # Rule: Use of net/http serve function that has no support for setting timeouts
2424
- G112 # Rule: Potential slowloris attack
25+
- G115 # Rule: integer overflow conversion
26+
27+
govet:
28+
disable:
29+
- printf # non-constant format string in call
2530

2631
issues:
2732
exclude-rules:

Diff for: cmd/backup-manager/app/util/util.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ func ConstructBRGlobalOptionsForBackup(backup *v1alpha1.Backup) ([]string, error
175175
}
176176
args = append(args, storageArgs...)
177177

178-
if spec.TableFilter != nil && len(spec.TableFilter) > 0 {
178+
if len(spec.TableFilter) > 0 {
179179
for _, tableFilter := range spec.TableFilter {
180180
args = append(args, "--filter", tableFilter)
181181
}
@@ -204,7 +204,7 @@ func ConstructDumplingOptionsForBackup(backup *v1alpha1.Backup) []string {
204204
var args []string
205205
config := backup.Spec
206206

207-
if config.TableFilter != nil && len(config.TableFilter) > 0 {
207+
if len(config.TableFilter) > 0 {
208208
for _, tableFilter := range config.TableFilter {
209209
args = append(args, "--filter", tableFilter)
210210
}
@@ -244,7 +244,7 @@ func ConstructBRGlobalOptionsForRestore(restore *v1alpha1.Restore) ([]string, er
244244
}
245245
args = append(args, storageArgs...)
246246

247-
if config.TableFilter != nil && len(config.TableFilter) > 0 {
247+
if len(config.TableFilter) > 0 {
248248
for _, tableFilter := range config.TableFilter {
249249
args = append(args, "--filter", tableFilter)
250250
}

Diff for: cmd/http-service/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/pingcap/tidb-operator/http-service
22

3-
go 1.21
3+
go 1.23.1
44

55
require (
66
github.com/gin-gonic/gin v1.10.0

Diff for: docs/CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Prerequisites
44

5-
Please install [Go 1.21.x](https://go.dev/doc/install). If you want to run TiDB Operator locally, please also install the latest version of [Docker](https://www.docker.com/get-started/), [kind](https://kind.sigs.k8s.io/docs/user/quick-start/), [kubectl](https://kubernetes.io/docs/tasks/tools/#kubectl) and [Helm](https://helm.sh/docs/intro/quickstart/).
5+
Please install [Go 1.23.x](https://go.dev/doc/install). If you want to run TiDB Operator locally, please also install the latest version of [Docker](https://www.docker.com/get-started/), [kind](https://kind.sigs.k8s.io/docs/user/quick-start/), [kubectl](https://kubernetes.io/docs/tasks/tools/#kubectl) and [Helm](https://helm.sh/docs/intro/quickstart/).
66

77
## Workflow
88

Diff for: go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
module github.com/pingcap/tidb-operator
66

7-
go 1.21
7+
go 1.23.1
88

99
require (
1010
cloud.google.com/go/storage v1.30.1

Diff for: hack/lib.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ function hack::ensure_misspell() {
279279

280280
function hack::ensure_golangci_lint() {
281281
echo "Installing golangci_lint..."
282-
GOBIN=$OUTPUT_BIN go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54.2
282+
GOBIN=$OUTPUT_BIN go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.61.0
283283
}
284284

285285
function hack::ensure_controller_gen() {

Diff for: pkg/apis/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/pingcap/tidb-operator/pkg/apis
22

3-
go 1.21
3+
go 1.23.1
44

55
require (
66
github.com/BurntSushi/toml v0.3.1

Diff for: pkg/client/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/pingcap/tidb-operator/pkg/client
22

3-
go 1.21
3+
go 1.23.1
44

55
require (
66
github.com/pingcap/tidb-operator/pkg/apis v1.6.0

Diff for: pkg/controller/tidb_control.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func (c *defaultTiDBControl) GetInfo(tc *v1alpha1.TidbCluster, ordinal int32) (*
9393
return nil, err
9494
}
9595
if res.StatusCode != http.StatusOK {
96-
errMsg := fmt.Errorf(fmt.Sprintf("Error response %s:%v URL: %s", string(body), res.StatusCode, url))
96+
errMsg := fmt.Errorf("Error response %s:%v URL: %s", string(body), res.StatusCode, url)
9797
return nil, errMsg
9898
}
9999
info := DBInfo{}
@@ -132,7 +132,7 @@ func getBodyOK(httpClient *http.Client, apiURL string) ([]byte, error) {
132132
return nil, err
133133
}
134134
if res.StatusCode >= 400 {
135-
errMsg := fmt.Errorf(fmt.Sprintf("Error response %s:%v URL %s", string(body), res.StatusCode, apiURL))
135+
errMsg := fmt.Errorf("Error response %s:%v URL %s", string(body), res.StatusCode, apiURL)
136136
return nil, errMsg
137137
}
138138

Diff for: pkg/controller/tidb_control_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ o8O7UTMyQ7MUrPusaqsG/QuvppbdahOLzkVc0E5jUOL/dgSxsdOqc7EIxd94Cg65
7979
cQQSTMrQTbQLo5c=
8080
-----END CERTIFICATE-----
8181
`
82+
// nolint:gosec
8283
keyData string = `
8384
-----BEGIN EC PRIVATE KEY-----
8485
MHcCAQEEIFbUNEYv0ujI3dTLbnb5lTBfRxwst3lMROmRV2tN7NTroAoGCCqGSM49

Diff for: pkg/manager/member/scaler.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
package member
1515

1616
import (
17+
"errors"
1718
"fmt"
1819
"time"
1920

@@ -68,7 +69,7 @@ func (s *generalScaler) deleteDeferDeletingPVC(controller runtime.Object, member
6869
if err != nil {
6970
msg := fmt.Sprintf("%s %s/%s list pvc failed, selector: %s, err: %v", kind, ns, meta.GetName(), selector, err)
7071
klog.Error(msg)
71-
return skipReason, fmt.Errorf(msg)
72+
return skipReason, errors.New(msg)
7273
}
7374
if len(pvcs) == 0 {
7475
klog.Infof("%s %s/%s list pvc not found, selector: %s", kind, ns, meta.GetName(), selector)
@@ -116,12 +117,12 @@ func (s *generalScaler) updateDeferDeletingPVC(tc *v1alpha1.TidbCluster,
116117
if err != nil {
117118
msg := fmt.Sprintf("Cluster %s/%s list pvc failed, selector: %s, err: %v", ns, tc.Name, selector, err)
118119
klog.Error(msg)
119-
return fmt.Errorf(msg)
120+
return errors.New(msg)
120121
}
121122
if len(pvcs) == 0 {
122123
msg := fmt.Sprintf("Cluster %s/%s list pvc not found, selector: %s", ns, tc.Name, selector)
123124
klog.Error(msg)
124-
return fmt.Errorf(msg)
125+
return errors.New(msg)
125126
}
126127

127128
for _, pvc := range pvcs {

Diff for: pkg/util/http/httputil.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
package httputil
1515

1616
import (
17+
"errors"
1718
"fmt"
1819
"io"
1920
"net/http"
@@ -36,7 +37,7 @@ func ReadErrorBody(body io.Reader) (err error) {
3637
if err != nil {
3738
return err
3839
}
39-
return fmt.Errorf(string(bodyBytes))
40+
return errors.New(string(bodyBytes))
4041
}
4142

4243
// GetBodyOK returns the body or an error if the response is not okay

Diff for: tests/e2e/br/br.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,8 @@ func createTidbCluster(f *e2eframework.Framework, name string, version string, e
936936
func createLogBackupEnableTidbCluster(f *e2eframework.Framework, name string, version string, enableTLS bool, skipCA bool) error {
937937
ns := f.Namespace.Name
938938
// TODO: change to use tidbclusterutil like brutil
939-
tc := fixture.GetTidbCluster(ns, name, version)
939+
// NOTE(pdms): some cases will port forward pd service to get current ts, so we disable TSO microservice here
940+
tc := fixture.GetTidbClusterWithoutPDMS(ns, name, version)
940941
tc.Spec.PD.Replicas = 1
941942
tc.Spec.TiKV.Replicas = 1
942943
tc.Spec.TiDB.Replicas = 1

Diff for: tests/e2e/br/framework/br/wait.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,12 @@ func WaitForLogBackupReachTS(name, pdhost, expect string, timeout time.Duration)
192192
if err != nil {
193193
return false, err
194194
}
195-
if len(kvs) != 1 {
196-
return false, fmt.Errorf("get log backup checkpoint ts from pd %s failed", pdhost)
195+
if len(kvs) == 0 {
196+
// wait for log backup start
197+
return false, nil
198+
}
199+
if len(kvs) > 1 {
200+
return false, fmt.Errorf("get log backup checkpoint ts from pd %s failed, expect 1, got %d", pdhost, len(kvs))
197201
}
198202
checkpointTS := binary.BigEndian.Uint64(kvs[0].Value)
199203
expectTS, err := config.ParseTSString(expect)

Diff for: tests/examples/002-selfsigned-tls.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ source "${ROOT}/hack/lib.sh"
2020
source "${ROOT}/tests/examples/t.sh"
2121

2222
NS=$(basename ${0%.*})
23-
CERT_MANAGER_VERSION=1.12.2
23+
CERT_MANAGER_VERSION=1.15.1
2424

2525
PORT_FORWARD_PID=
2626

Diff for: tests/images/e2e/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2
2525
unzip awscliv2.zip && \
2626
./aws/install && \
2727
rm -r aws awscliv2.zip
28-
RUN curl -L "https://github.com/jetstack/cert-manager/releases/download/v1.12.2/cert-manager.yaml" -o "/cert-manager.yaml"
28+
RUN curl -L "https://github.com/jetstack/cert-manager/releases/download/v1.15.1/cert-manager.yaml" -o "/cert-manager.yaml"
2929
ADD minio /minio
3030

3131
ADD tidb-operator /charts/e2e/tidb-operator

Diff for: tests/images/kubekins-e2e/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM debian:buster-slim
22

3-
ARG GO_VERSION=1.21.3
3+
ARG GO_VERSION=1.23.1
44

55
# common util tools
66
RUN apt-get update && \

Diff for: tests/third_party/k8s/resource_usage_gatherer.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"bytes"
2424
"context"
2525
"encoding/json"
26+
"errors"
2627
"fmt"
2728
"math"
2829
"regexp"
@@ -592,7 +593,7 @@ func (g *ContainerResourceGatherer) StopAndSummarize(percentiles []int, constrai
592593
}
593594
}
594595
if len(violatedConstraints) > 0 {
595-
return &summary, fmt.Errorf(strings.Join(violatedConstraints, "\n"))
596+
return &summary, errors.New(strings.Join(violatedConstraints, "\n"))
596597
}
597598
return &summary, nil
598599
}

0 commit comments

Comments
 (0)