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

bump golang to v1.23 (#5683) #5753

Merged
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
8 changes: 4 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@ jobs:
# see https://github.community/t/github-sha-isnt-the-value-expected/17903/2
# so we checkout the repo with `fetch-depth: 2` and let `codecov/codecov-action` to retrieve the real commit hash.
- name: Check out code into the Go module directory
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
path: go/src/github.com/${{ github.repository }}
fetch-depth: 2
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version-file: go/src/github.com/${{ github.repository }}/go.mod
go-version: 1.21.3
cache-dependency-path: "**/*.sum"
- name: Set vars
run: |
echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_ENV
echo "GOMODCACHE=$(go env GOMODCACHE)" >> $GITHUB_ENV
- name: Try to use build cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
${{ env.GOCACHE }}
Expand Down
5 changes: 5 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ linters-settings:
- G201 # Rule: SQL query construction using format string
- G114 # Rule: Use of net/http serve function that has no support for setting timeouts
- G112 # Rule: Potential slowloris attack
- G115 # Rule: integer overflow conversion

govet:
disable:
- printf # non-constant format string in call

issues:
exclude-rules:
Expand Down
6 changes: 3 additions & 3 deletions cmd/backup-manager/app/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func ConstructBRGlobalOptionsForBackup(backup *v1alpha1.Backup) ([]string, error
}
args = append(args, storageArgs...)

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

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

if config.TableFilter != nil && len(config.TableFilter) > 0 {
if len(config.TableFilter) > 0 {
for _, tableFilter := range config.TableFilter {
args = append(args, "--filter", tableFilter)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/http-service/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/pingcap/tidb-operator/http-service

go 1.21
go 1.23.1

require (
github.com/gin-gonic/gin v1.10.0
Expand Down
2 changes: 1 addition & 1 deletion docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Prerequisites

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/).
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/).

## Workflow

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

module github.com/pingcap/tidb-operator

go 1.21
go 1.23.1

require (
cloud.google.com/go/storage v1.30.1
Expand Down
2 changes: 1 addition & 1 deletion hack/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ function hack::ensure_misspell() {

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

function hack::ensure_controller_gen() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/pingcap/tidb-operator/pkg/apis

go 1.21
go 1.23.1

require (
github.com/BurntSushi/toml v0.3.1
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/pingcap/tidb-operator/pkg/client

go 1.21
go 1.23.1

require (
github.com/pingcap/tidb-operator/pkg/apis v1.6.0
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/tidb_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (c *defaultTiDBControl) GetInfo(tc *v1alpha1.TidbCluster, ordinal int32) (*
return nil, err
}
if res.StatusCode != http.StatusOK {
errMsg := fmt.Errorf(fmt.Sprintf("Error response %s:%v URL: %s", string(body), res.StatusCode, url))
errMsg := fmt.Errorf("Error response %s:%v URL: %s", string(body), res.StatusCode, url)
return nil, errMsg
}
info := DBInfo{}
Expand Down Expand Up @@ -132,7 +132,7 @@ func getBodyOK(httpClient *http.Client, apiURL string) ([]byte, error) {
return nil, err
}
if res.StatusCode >= 400 {
errMsg := fmt.Errorf(fmt.Sprintf("Error response %s:%v URL %s", string(body), res.StatusCode, apiURL))
errMsg := fmt.Errorf("Error response %s:%v URL %s", string(body), res.StatusCode, apiURL)
return nil, errMsg
}

Expand Down
1 change: 1 addition & 0 deletions pkg/controller/tidb_control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ o8O7UTMyQ7MUrPusaqsG/QuvppbdahOLzkVc0E5jUOL/dgSxsdOqc7EIxd94Cg65
cQQSTMrQTbQLo5c=
-----END CERTIFICATE-----
`
// nolint:gosec
keyData string = `
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIFbUNEYv0ujI3dTLbnb5lTBfRxwst3lMROmRV2tN7NTroAoGCCqGSM49
Expand Down
7 changes: 4 additions & 3 deletions pkg/manager/member/scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package member

import (
"errors"
"fmt"
"time"

Expand Down Expand Up @@ -68,7 +69,7 @@ func (s *generalScaler) deleteDeferDeletingPVC(controller runtime.Object, member
if err != nil {
msg := fmt.Sprintf("%s %s/%s list pvc failed, selector: %s, err: %v", kind, ns, meta.GetName(), selector, err)
klog.Error(msg)
return skipReason, fmt.Errorf(msg)
return skipReason, errors.New(msg)
}
if len(pvcs) == 0 {
klog.Infof("%s %s/%s list pvc not found, selector: %s", kind, ns, meta.GetName(), selector)
Expand Down Expand Up @@ -116,12 +117,12 @@ func (s *generalScaler) updateDeferDeletingPVC(tc *v1alpha1.TidbCluster,
if err != nil {
msg := fmt.Sprintf("Cluster %s/%s list pvc failed, selector: %s, err: %v", ns, tc.Name, selector, err)
klog.Error(msg)
return fmt.Errorf(msg)
return errors.New(msg)
}
if len(pvcs) == 0 {
msg := fmt.Sprintf("Cluster %s/%s list pvc not found, selector: %s", ns, tc.Name, selector)
klog.Error(msg)
return fmt.Errorf(msg)
return errors.New(msg)
}

for _, pvc := range pvcs {
Expand Down
3 changes: 2 additions & 1 deletion pkg/util/http/httputil.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package httputil

import (
"errors"
"fmt"
"io"
"net/http"
Expand All @@ -36,7 +37,7 @@ func ReadErrorBody(body io.Reader) (err error) {
if err != nil {
return err
}
return fmt.Errorf(string(bodyBytes))
return errors.New(string(bodyBytes))
}

// GetBodyOK returns the body or an error if the response is not okay
Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/br/br.go
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,8 @@ func createTidbCluster(f *e2eframework.Framework, name string, version string, e
func createLogBackupEnableTidbCluster(f *e2eframework.Framework, name string, version string, enableTLS bool, skipCA bool) error {
ns := f.Namespace.Name
// TODO: change to use tidbclusterutil like brutil
tc := fixture.GetTidbCluster(ns, name, version)
// NOTE(pdms): some cases will port forward pd service to get current ts, so we disable TSO microservice here
tc := fixture.GetTidbClusterWithoutPDMS(ns, name, version)
tc.Spec.PD.Replicas = 1
tc.Spec.TiKV.Replicas = 1
tc.Spec.TiDB.Replicas = 1
Expand Down
8 changes: 6 additions & 2 deletions tests/e2e/br/framework/br/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,12 @@ func WaitForLogBackupReachTS(name, pdhost, expect string, timeout time.Duration)
if err != nil {
return false, err
}
if len(kvs) != 1 {
return false, fmt.Errorf("get log backup checkpoint ts from pd %s failed", pdhost)
if len(kvs) == 0 {
// wait for log backup start
return false, nil
}
if len(kvs) > 1 {
return false, fmt.Errorf("get log backup checkpoint ts from pd %s failed, expect 1, got %d", pdhost, len(kvs))
}
checkpointTS := binary.BigEndian.Uint64(kvs[0].Value)
expectTS, err := config.ParseTSString(expect)
Expand Down
2 changes: 1 addition & 1 deletion tests/examples/002-selfsigned-tls.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ source "${ROOT}/hack/lib.sh"
source "${ROOT}/tests/examples/t.sh"

NS=$(basename ${0%.*})
CERT_MANAGER_VERSION=1.12.2
CERT_MANAGER_VERSION=1.15.1

PORT_FORWARD_PID=

Expand Down
2 changes: 1 addition & 1 deletion tests/images/e2e/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2
unzip awscliv2.zip && \
./aws/install && \
rm -r aws awscliv2.zip
RUN curl -L "https://github.com/jetstack/cert-manager/releases/download/v1.12.2/cert-manager.yaml" -o "/cert-manager.yaml"
RUN curl -L "https://github.com/jetstack/cert-manager/releases/download/v1.15.1/cert-manager.yaml" -o "/cert-manager.yaml"
ADD minio /minio

ADD tidb-operator /charts/e2e/tidb-operator
Expand Down
2 changes: 1 addition & 1 deletion tests/images/kubekins-e2e/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM debian:buster-slim

ARG GO_VERSION=1.21.3
ARG GO_VERSION=1.23.1

# common util tools
RUN apt-get update && \
Expand Down
3 changes: 2 additions & 1 deletion tests/third_party/k8s/resource_usage_gatherer.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"math"
"regexp"
Expand Down Expand Up @@ -592,7 +593,7 @@ func (g *ContainerResourceGatherer) StopAndSummarize(percentiles []int, constrai
}
}
if len(violatedConstraints) > 0 {
return &summary, fmt.Errorf(strings.Join(violatedConstraints, "\n"))
return &summary, errors.New(strings.Join(violatedConstraints, "\n"))
}
return &summary, nil
}
Expand Down
Loading