From 344d4e80dcce4abf7b358ed54ec353657c50c40f Mon Sep 17 00:00:00 2001 From: Hoshea Date: Tue, 10 Dec 2024 17:16:52 +0800 Subject: [PATCH] Chore: use gcr images to avoid rate limit in CI (#180) --- .github/workflows/ci.yaml | 10 ++- .github/workflows/e2e.yaml | 7 ++- .golangci.yml | 61 +++++++++---------- Makefile | 2 +- cmd/operator/main.go | 2 +- cmd/overlay-gen/generators/util.go | 2 +- go.mod | 8 +-- go.sum | 17 ------ go.work | 2 +- go.work.sum | 18 ++++-- hack/lib/image.sh | 4 +- image/Dockerfile | 6 +- pkg/client/client.go | 2 +- pkg/client/fake.go | 2 +- pkg/client/fake_test.go | 3 +- pkg/controllers/pd/tasks/cm.go | 2 +- pkg/controllers/pd/tasks/pod.go | 2 +- pkg/controllers/tidb/tasks/pod.go | 2 +- pkg/controllers/tidbgroup/tasks/ctx.go | 2 +- .../tidbgroup/tasks/updater_test.go | 4 +- pkg/controllers/tiflash/tasks/pod.go | 4 +- pkg/controllers/tikvgroup/tasks/ctx.go | 2 +- pkg/overlay/overlay_test.go | 3 +- pkg/pdapi/v1/pd_config.go | 2 +- pkg/pdapi/v1/types.go | 2 +- pkg/timanager/informer.go | 2 +- pkg/timanager/manager.go | 6 +- pkg/timanager/manager_test.go | 4 +- pkg/timanager/poller_test.go | 5 +- pkg/utils/k8s/revision/controller_revision.go | 8 +-- pkg/utils/toml/toml.go | 1 - pkg/version/version.go | 4 +- tests/e2e/cluster/cluster.go | 11 ++-- tests/e2e/cluster/tls.go | 2 +- tests/e2e/config/restclientgetter.go | 2 +- tests/e2e/utils/data/cluster.go | 18 ++++++ tools/tools.go | 4 +- 37 files changed, 125 insertions(+), 113 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1289f77e45..f78d4bc9e8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -31,13 +31,20 @@ jobs: password: ${{ secrets.DOCKERHUB_TOKEN }} - uses: docker/setup-qemu-action@v3 + with: + image: gcr.io/pingcap-public/third-party/tonistiigi/binfmt:latest + - name: setup buildx context run: | docker context create builder + - uses: docker/setup-buildx-action@v3 with: platforms: linux/arm64,linux/amd64 endpoint: builder + driver-opts: | + image=gcr.io/pingcap-public/third-party/moby/buildkit:buildx-stable-1 + - name: image run: | V_PLATFORMS=linux/arm64,linux/amd64 make image @@ -54,6 +61,7 @@ jobs: - name: build run: | make build + lint: runs-on: self-hosted steps: @@ -97,5 +105,3 @@ jobs: - name: verify run: | make verify - - name: Check License Header - run: make check-license diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 427c2f4ba3..4de5bd7304 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -15,7 +15,6 @@ jobs: runs-on: self-hosted strategy: fail-fast: false - max-parallel: 3 # Avoid docker rate limit matrix: spec: - "Basic" @@ -39,13 +38,19 @@ jobs: password: ${{ secrets.DOCKERHUB_TOKEN }} - uses: docker/setup-qemu-action@v3 + with: + image: gcr.io/pingcap-public/third-party/tonistiigi/binfmt:latest + - name: setup buildx context run: | docker context create builder + - uses: docker/setup-buildx-action@v3 with: platforms: linux/arm64,linux/amd64 endpoint: builder + driver-opts: | + image=gcr.io/pingcap-public/third-party/moby/buildkit:buildx-stable-1 - name: E2E test env: diff --git a/.golangci.yml b/.golangci.yml index 89c3c9ae68..23b62e1794 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -71,41 +71,41 @@ linters-settings: linters: disable-all: true enable: - - bodyclose - - depguard - - dogsled - - dupl - - errcheck - - errorlint - - exportloopref - - funlen + # - bodyclose + # - depguard + # - dogsled + # - dupl + # - errcheck + # - errorlint + - copyloopvar + # - funlen - gocheckcompilerdirectives - - gochecknoinits - - goconst - - gocritic - - gocyclo + # - gochecknoinits + # - goconst + # - gocritic + # - gocyclo - godox - gofmt - goimports - - mnd + # - mnd - goprintffuncname - - gosec - - gosimple - - govet - - ineffassign - - lll - - misspell + # - gosec + # - gosimple + # - govet + # - ineffassign + # - lll + # - misspell - nakedret - - noctx - - nolintlint - - revive - - staticcheck - - stylecheck - - testifylint + # - noctx + # - nolintlint + # - revive + # - staticcheck + # - stylecheck + # - testifylint - unconvert - - unparam - - unused - - whitespace + # - unparam + # - unused + # - whitespace # This list of linters is not a recommendation (same thing for all this configuration file). # We intentionally use a limited set of linters. @@ -119,10 +119,5 @@ issues: - mnd - lll - # Ignore import error in tools.go, it's only for version management of tools. - - path: tools/tools.go - linters: [typecheck] - text: "import \"k8s.io/code-generator/cmd/register-gen\" is a program, not an importable package" - run: timeout: 15m diff --git a/Makefile b/Makefile index 7a3b99735c..ecc09f0930 100644 --- a/Makefile +++ b/Makefile @@ -172,7 +172,7 @@ bin/overlay-gen: GOLANGCI_LINT = $(BIN_DIR)/golangci-lint bin/golangci-lint: # DON'T track the version of this cmd by go.mod - $(ROOT)/hack/download.sh go_install $(GOLANGCI_LINT) github.com/golangci/golangci-lint/cmd/golangci-lint v1.59.1 "version --format=short" + $(ROOT)/hack/download.sh go_install $(GOLANGCI_LINT) github.com/golangci/golangci-lint/cmd/golangci-lint v1.62.2 "version --format=short" .PHONY: bin/kind KIND = $(BIN_DIR)/kind diff --git a/cmd/operator/main.go b/cmd/operator/main.go index 864628d036..1ae88d188c 100644 --- a/cmd/operator/main.go +++ b/cmd/operator/main.go @@ -91,7 +91,7 @@ func main() { ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) - utilruntime.PanicHandlers = append(utilruntime.PanicHandlers, func(ctx context.Context, e interface{}) { + utilruntime.PanicHandlers = append(utilruntime.PanicHandlers, func(ctx context.Context, e any) { metrics.ControllerPanic.WithLabelValues().Inc() }) diff --git a/cmd/overlay-gen/generators/util.go b/cmd/overlay-gen/generators/util.go index acd68781bb..ab47d14640 100644 --- a/cmd/overlay-gen/generators/util.go +++ b/cmd/overlay-gen/generators/util.go @@ -26,7 +26,7 @@ import ( "k8s.io/gengo/v2/types" ) -func DoLine(sw *generator.SnippetWriter, indent string, format string, args interface{}) { +func DoLine(sw *generator.SnippetWriter, indent string, format string, args any) { for range indent { sw.Do("\t", nil) } diff --git a/go.mod b/go.mod index 3b3110025a..e7f9b75156 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,6 @@ module github.com/pingcap/tidb-operator -go 1.22.0 - -toolchain go1.22.3 +go 1.23.0 require ( github.com/Masterminds/semver/v3 v3.3.0 @@ -71,7 +69,6 @@ require ( github.com/evanphx/json-patch/v5 v5.9.0 // indirect github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect github.com/fatih/camelcase v1.0.0 // indirect - github.com/fatih/color v1.17.0 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/fxamacker/cbor/v2 v2.7.0 // indirect github.com/go-errors/errors v1.4.2 // indirect @@ -80,7 +77,6 @@ require ( github.com/go-openapi/jsonreference v0.20.2 // indirect github.com/go-openapi/swag v0.22.4 // indirect github.com/go-task/slim-sprig/v3 v3.0.0 // indirect - github.com/gobuffalo/flect v1.0.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.4 // indirect @@ -99,8 +95,6 @@ require ( github.com/json-iterator/go v1.1.12 // indirect github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect github.com/mailru/easyjson v0.7.7 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.9 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect diff --git a/go.sum b/go.sum index e5ddd6a0a1..59dfaf001a 100644 --- a/go.sum +++ b/go.sum @@ -75,8 +75,6 @@ github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d h1:105gxyaGwC github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d/go.mod h1:ZZMPRZwes7CROmyNKgQzC3XPs6L/G2EJLHddWejkmf4= github.com/fatih/camelcase v1.0.0 h1:hxNvNX/xYBp0ovncs8WyWZrOrpBNub/JfaMvbURyft8= github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwoZc+/fpc= -github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= -github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E= @@ -98,8 +96,6 @@ github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpv github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg= github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= -github.com/gobuffalo/flect v1.0.2 h1:eqjPGSo2WmjgY2XlpGwo2NXgL3RucAKo4k4qQMNA5sA= -github.com/gobuffalo/flect v1.0.2/go.mod h1:A5msMlrHtLqh9umBSnvabjsMrCcCpAyzglnDvkbYKHs= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= @@ -165,11 +161,6 @@ github.com/lithammer/dedent v1.1.0 h1:VNzHMVCBNG1j0fh3OrsFRkVUwStdDArbgBWoPAffkt github.com/lithammer/dedent v1.1.0/go.mod h1:jrXYCQtgg0nJiN+StA2KgR7w6CiQNv9Fd/Z9BP0jIOc= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= -github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= -github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= -github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= -github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= @@ -193,12 +184,8 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J1GEMiLbxo1LJaP8RfCpH6pymGZus= github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= -github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= -github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= -github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= -github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA= github.com/onsi/ginkgo/v2 v2.19.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To= github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k= @@ -307,8 +294,6 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -365,8 +350,6 @@ gopkg.in/evanphx/json-patch.v4 v4.12.0 h1:n6jtcsulIzXPJaxegRbvFNNrZDjbij7ny3gmSP gopkg.in/evanphx/json-patch.v4 v4.12.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= diff --git a/go.work b/go.work index da16312850..0fc2262c12 100644 --- a/go.work +++ b/go.work @@ -1,4 +1,4 @@ -go 1.22.3 +go 1.23.0 use ( . diff --git a/go.work.sum b/go.work.sum index b168831fce..012cf779ef 100644 --- a/go.work.sum +++ b/go.work.sum @@ -604,8 +604,6 @@ github.com/daviddengcn/go-colortext v1.0.0 h1:ANqDyC0ys6qCSvuEK7l3g5RaehL/Xck9EX github.com/daviddengcn/go-colortext v1.0.0/go.mod h1:zDqEI5NVUop5QPpVJUxE9UO10hRnmkD5G4Pmri9+m4c= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= -github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0= -github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 h1:bWDMxwH3px2JBh6AyO7hdCn/PkvCZXii8TGj7sbtEbQ= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= @@ -632,6 +630,8 @@ github.com/envoyproxy/protoc-gen-validate v1.0.4/go.mod h1:qys6tmnRsYrQqIhm2bvKZ github.com/euank/go-kmsg-parser v2.0.0+incompatible h1:cHD53+PLQuuQyLZeriD1V/esuG4MuU0Pjs5y6iknohY= github.com/euank/go-kmsg-parser v2.0.0+incompatible/go.mod h1:MhmAMZ8V4CYH4ybgdRwPr2TU5ThnS43puaKEMpja1uw= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= +github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI= github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk= github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= @@ -683,6 +683,8 @@ github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= +github.com/gobuffalo/flect v1.0.2 h1:eqjPGSo2WmjgY2XlpGwo2NXgL3RucAKo4k4qQMNA5sA= +github.com/gobuffalo/flect v1.0.2/go.mod h1:A5msMlrHtLqh9umBSnvabjsMrCcCpAyzglnDvkbYKHs= github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU= github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM= github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og= @@ -899,7 +901,11 @@ github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.2/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg= @@ -942,7 +948,11 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= +github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= +github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/ginkgo/v2 v2.1.4/go.mod h1:um6tUpWM/cxCK3/FK8BXqEiUMUwRgSM4JXG47RKZmLU= github.com/onsi/ginkgo/v2 v2.4.0/go.mod h1:iHkDK1fKGcBoEHT5W7YBq4RFWaQulw+caOMkAt4OrFo= github.com/onsi/ginkgo/v2 v2.15.0/go.mod h1:HlxMHtYF57y6Dpf+mc5529KKmSq9h2FpCF+/ZkwUxKM= @@ -954,8 +964,6 @@ github.com/onsi/gomega v1.23.0/go.mod h1:Z/NWtiqwBrwUt4/2loMmHL63EDLnYHmVbuBpDr2 github.com/onsi/gomega v1.31.0/go.mod h1:DW9aCi7U6Yi40wNVAvT6kzFnEVEI5n3DloYBiKiT6zk= github.com/onsi/gomega v1.33.0 h1:snPCflnZrpMsy94p4lXVEkHo12lmPnc3vY5XBbreexE= github.com/onsi/gomega v1.33.0/go.mod h1:+925n5YtiFsLzzafLUHzVMBpvvRAzrydIBiSIxjX3wY= -github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= -github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/runc v1.1.4 h1:nRCz/8sKg6K6jgYAFLDlXzPeITBZJyX28DBVhWD+5dg= github.com/opencontainers/runc v1.1.4/go.mod h1:1J5XiS+vdZ3wCyZybsuxXZWGrgSr8fFJHLXuG2PsnNg= github.com/opencontainers/runc v1.1.12 h1:BOIssBaW1La0/qbNZHXOOa71dZfZEQOzW7dqQf3phss= @@ -1772,6 +1780,8 @@ gopkg.in/square/go-jose.v2 v2.2.2 h1:orlkJ3myw8CN1nVQHBFfloD+L3egixIa4FvUP6RosSA gopkg.in/square/go-jose.v2 v2.2.2/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/square/go-jose.v2 v2.6.0 h1:NGk74WTnPKBNUhNzQX7PYcTLUjoq7mzKk2OKbvwk2iI= gopkg.in/square/go-jose.v2 v2.6.0/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/warnings.v0 v0.1.1 h1:XM28wIgFzaBmeZ5dNHIpWLQpt/9DGKxk+rCg/22nnYE= gopkg.in/warnings.v0 v0.1.1/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= diff --git a/hack/lib/image.sh b/hack/lib/image.sh index 19a480072e..2b4b4bb977 100644 --- a/hack/lib/image.sh +++ b/hack/lib/image.sh @@ -98,8 +98,8 @@ function image:prepare() { echo "load tidb components' images into kind cluster" for component in pd tikv tidb tiflash; do for version in "$V_TIDB_CLUSTER_VERSION" "$V_TIDB_CLUSTER_VERSION_PREV"; do - docker pull pingcap/$component:"$version" -q && \ - $KIND load docker-image pingcap/$component:"$version" --name ${V_KIND_CLUSTER} + docker pull gcr.io/pingcap-public/dbaas/$component:"$version" -q && \ + $KIND load docker-image gcr.io/pingcap-public/dbaas/$component:"$version" --name ${V_KIND_CLUSTER} done done } diff --git a/image/Dockerfile b/image/Dockerfile index f68d364334..ba7cd69074 100644 --- a/image/Dockerfile +++ b/image/Dockerfile @@ -1,5 +1,5 @@ # syntax=docker.io/docker/dockerfile:1.8.1@sha256:e87caa74dcb7d46cd820352bfea12591f3dba3ddc4285e19c7dcd13359f7cefd -FROM --platform=$BUILDPLATFORM golang:1.22 AS builder +FROM --platform=$BUILDPLATFORM gcr.io/pingcap-public/third-party/baseimage/golang:1.23 AS builder ARG TARGETPLATFORM @@ -24,7 +24,7 @@ RUN --mount=type=cache,target=/go/pkg/mod/ \ --mount=type=cache,target=/go/cache \ V_PLATFORMS=$TARGETPLATFORM ./hack/build.sh -FROM --platform=$TARGETPLATFORM alpine:3.14 AS operator +FROM --platform=$TARGETPLATFORM ghcr.io/pingcap-qe/bases/pingcap-base:v1.9.2 AS operator ARG TARGETPLATFORM @@ -38,7 +38,7 @@ USER 65532:65532 ENTRYPOINT ["/operator"] -FROM --platform=$TARGETPLATFORM alpine:3.14 AS prestop-checker +FROM --platform=$TARGETPLATFORM ghcr.io/pingcap-qe/bases/pingcap-base:v1.9.2 AS prestop-checker ARG TARGETPLATFORM diff --git a/pkg/client/client.go b/pkg/client/client.go index ad81dde4fc..affa1541f2 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -143,7 +143,7 @@ func (p *applyPatch) Data(obj client.Object) ([]byte, error) { return buf.Bytes(), nil } -func (p *applier) Extract(current client.Object, fieldManager string, gvk schema.GroupVersionKind, patch interface{}, subresource string) error { +func (p *applier) Extract(current client.Object, fieldManager string, gvk schema.GroupVersionKind, patch any, subresource string) error { typed := p.parser.Type(gvk) if typed == nil { return fmt.Errorf("can't find specified type: %s", gvk) diff --git a/pkg/client/fake.go b/pkg/client/fake.go index 18e0096401..834d12c429 100644 --- a/pkg/client/fake.go +++ b/pkg/client/fake.go @@ -565,7 +565,7 @@ func (c *fakeUnderlayClient) PatchReactionFunc(action *testing.PatchActionImpl) return true, nil, err } case types.ApplyPatchType: - patchObj := &unstructured.Unstructured{Object: map[string]interface{}{}} + patchObj := &unstructured.Unstructured{Object: map[string]any{}} if err := yaml.Unmarshal(action.GetPatch(), &patchObj.Object); err != nil { return true, nil, fmt.Errorf("error decoding YAML: %w", err) } diff --git a/pkg/client/fake_test.go b/pkg/client/fake_test.go index 28e37d0473..3956592906 100644 --- a/pkg/client/fake_test.go +++ b/pkg/client/fake_test.go @@ -18,10 +18,11 @@ import ( "context" "testing" - "github.com/pingcap/tidb-operator/pkg/utils/fake" "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/pingcap/tidb-operator/pkg/utils/fake" ) func TestGet(t *testing.T) { diff --git a/pkg/controllers/pd/tasks/cm.go b/pkg/controllers/pd/tasks/cm.go index 36034bac26..51a3b99207 100644 --- a/pkg/controllers/pd/tasks/cm.go +++ b/pkg/controllers/pd/tasks/cm.go @@ -80,7 +80,7 @@ func newConfigMap(pd *v1alpha1.PD, data []byte, hash string) *corev1.ConfigMap { Name: ConfigMapName(pd.Name), Namespace: pd.Namespace, Labels: maputil.Merge(pd.Labels, map[string]string{ - v1alpha1.LabelKeyInstance: pd.Name, + v1alpha1.LabelKeyInstance: pd.Name, v1alpha1.LabelKeyConfigHash: hash, }), OwnerReferences: []metav1.OwnerReference{ diff --git a/pkg/controllers/pd/tasks/pod.go b/pkg/controllers/pd/tasks/pod.go index e9ac80d45e..64822d3a2c 100644 --- a/pkg/controllers/pd/tasks/pod.go +++ b/pkg/controllers/pd/tasks/pod.go @@ -232,7 +232,7 @@ func (t *TaskPod) newPod(cluster *v1alpha1.Cluster, pdg *v1alpha1.PDGroup, pd *v Namespace: pd.Namespace, Name: pd.Name, Labels: maputil.Merge(pd.Labels, map[string]string{ - v1alpha1.LabelKeyInstance: pd.Name, + v1alpha1.LabelKeyInstance: pd.Name, v1alpha1.LabelKeyConfigHash: configHash, }), Annotations: anno, diff --git a/pkg/controllers/tidb/tasks/pod.go b/pkg/controllers/tidb/tasks/pod.go index 72d5c737a7..0fcf178caa 100644 --- a/pkg/controllers/tidb/tasks/pod.go +++ b/pkg/controllers/tidb/tasks/pod.go @@ -239,7 +239,7 @@ func (t *TaskPod) newPod(cluster *v1alpha1.Cluster, dbg *v1alpha1.TiDBGroup, tid Namespace: tidb.Namespace, Name: tidb.Name, Labels: maputil.Merge(tidb.Labels, map[string]string{ - v1alpha1.LabelKeyInstance: tidb.Name, + v1alpha1.LabelKeyInstance: tidb.Name, v1alpha1.LabelKeyConfigHash: configHash, }), Annotations: maputil.Copy(tidb.GetAnnotations()), diff --git a/pkg/controllers/tidbgroup/tasks/ctx.go b/pkg/controllers/tidbgroup/tasks/ctx.go index cd344655f4..490b90a3d9 100644 --- a/pkg/controllers/tidbgroup/tasks/ctx.go +++ b/pkg/controllers/tidbgroup/tasks/ctx.go @@ -17,7 +17,6 @@ package tasks import ( "cmp" "context" - "github.com/pingcap/tidb-operator/pkg/action" "slices" "github.com/go-logr/logr" @@ -26,6 +25,7 @@ import ( "k8s.io/apimachinery/pkg/types" "github.com/pingcap/tidb-operator/apis/core/v1alpha1" + "github.com/pingcap/tidb-operator/pkg/action" "github.com/pingcap/tidb-operator/pkg/client" "github.com/pingcap/tidb-operator/pkg/tidbapi/v1" "github.com/pingcap/tidb-operator/pkg/utils/task" diff --git a/pkg/controllers/tidbgroup/tasks/updater_test.go b/pkg/controllers/tidbgroup/tasks/updater_test.go index 36b1bd5797..e5c44a8f40 100644 --- a/pkg/controllers/tidbgroup/tasks/updater_test.go +++ b/pkg/controllers/tidbgroup/tasks/updater_test.go @@ -72,8 +72,8 @@ func TestUpdater(t *testing.T) { expected: task.Complete().With(""), expectFunc: func(t *testing.T, ctx *ReconcileContext, cli client.Client) { var crList appsv1.ControllerRevisionList - assert.Equal(t, cli.List(context.TODO(), &crList), nil) - assert.Equal(t, len(crList.Items), 1) + assert.NoError(t, cli.List(context.TODO(), &crList)) + assert.Len(t, crList.Items, 1) }, }, } diff --git a/pkg/controllers/tiflash/tasks/pod.go b/pkg/controllers/tiflash/tasks/pod.go index aae958e65e..3b6709cdb0 100644 --- a/pkg/controllers/tiflash/tasks/pod.go +++ b/pkg/controllers/tiflash/tasks/pod.go @@ -79,7 +79,7 @@ func (t *TaskPod) Sync(ctx task.Context[ReconcileContext]) task.Result { curHash, expectHash := rtx.Pod.Labels[v1alpha1.LabelKeyConfigHash], expected.Labels[v1alpha1.LabelKeyConfigHash] configChanged := curHash != expectHash t.Logger.Info("compare pod", "result", res, "configChanged", configChanged, "currentConfigHash", curHash, "expectConfigHash", expectHash) - + if res == k8s.CompareResultRecreate || (configChanged && rtx.TiFlashGroup.Spec.ConfigUpdateStrategy == v1alpha1.ConfigUpdateStrategyRollingUpdate) { t.Logger.Info("will recreate the pod") if err := t.Client.Delete(rtx, rtx.Pod); err != nil { @@ -167,7 +167,7 @@ func (t *TaskPod) newPod(cluster *v1alpha1.Cluster, flashg *v1alpha1.TiFlashGrou Namespace: tiflash.Namespace, Name: tiflash.Name, Labels: maputil.Merge(tiflash.Labels, map[string]string{ - v1alpha1.LabelKeyInstance: tiflash.Name, + v1alpha1.LabelKeyInstance: tiflash.Name, v1alpha1.LabelKeyConfigHash: configHash, }), Annotations: maputil.Copy(tiflash.GetAnnotations()), diff --git a/pkg/controllers/tikvgroup/tasks/ctx.go b/pkg/controllers/tikvgroup/tasks/ctx.go index c34ba8ae58..8f3374384b 100644 --- a/pkg/controllers/tikvgroup/tasks/ctx.go +++ b/pkg/controllers/tikvgroup/tasks/ctx.go @@ -17,7 +17,6 @@ package tasks import ( "cmp" "context" - "github.com/pingcap/tidb-operator/pkg/action" "slices" "github.com/go-logr/logr" @@ -26,6 +25,7 @@ import ( "k8s.io/apimachinery/pkg/types" "github.com/pingcap/tidb-operator/apis/core/v1alpha1" + "github.com/pingcap/tidb-operator/pkg/action" "github.com/pingcap/tidb-operator/pkg/client" "github.com/pingcap/tidb-operator/pkg/utils/task" ) diff --git a/pkg/overlay/overlay_test.go b/pkg/overlay/overlay_test.go index 47fddc0341..a46ff134d6 100644 --- a/pkg/overlay/overlay_test.go +++ b/pkg/overlay/overlay_test.go @@ -17,10 +17,11 @@ package overlay import ( "testing" - "github.com/pingcap/tidb-operator/pkg/utils/random" "github.com/stretchr/testify/assert" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/pingcap/tidb-operator/pkg/utils/random" ) type Case[T any] struct { diff --git a/pkg/pdapi/v1/pd_config.go b/pkg/pdapi/v1/pd_config.go index 1e54648c5d..3ed7716706 100644 --- a/pkg/pdapi/v1/pd_config.go +++ b/pkg/pdapi/v1/pd_config.go @@ -194,7 +194,7 @@ type PDScheduleConfig struct { Schedulers *PDSchedulerConfigs `toml:"schedulers,omitempty" json:"schedulers-v2,omitempty"` // json v2 is for the sake of compatible upgrade // Only used to display - SchedulersPayload map[string]interface{} `toml:"schedulers-payload" json:"schedulers-payload,omitempty"` + SchedulersPayload map[string]any `toml:"schedulers-payload" json:"schedulers-payload,omitempty"` // EnableOneWayMerge is the option to enable one way merge. This means a Region can only be merged into the next region of it. // Imported from v3.1.0 diff --git a/pkg/pdapi/v1/types.go b/pkg/pdapi/v1/types.go index 4746acfa92..35363a79ee 100644 --- a/pkg/pdapi/v1/types.go +++ b/pkg/pdapi/v1/types.go @@ -104,7 +104,7 @@ func (e *TiKVNotBootstrappedError) Error() string { } // TiKVNotBootstrappedErrorf returns a TiKVNotBootstrappedError. -func TiKVNotBootstrappedErrorf(format string, a ...interface{}) error { +func TiKVNotBootstrappedErrorf(format string, a ...any) error { return &TiKVNotBootstrappedError{fmt.Sprintf(format, a...)} } diff --git a/pkg/timanager/informer.go b/pkg/timanager/informer.go index 9521292f8d..6518b0abc9 100644 --- a/pkg/timanager/informer.go +++ b/pkg/timanager/informer.go @@ -264,7 +264,7 @@ func (s *globalCacheLister[T, PT]) ByCluster(cluster string) CacheLister[T, PT] } func (s *cacheLister[T, PT]) List(selector labels.Selector) (ret []PT, _ error) { - if err := cache.ListAllByNamespace(s.indexer, s.ns, selector, func(m interface{}) { + if err := cache.ListAllByNamespace(s.indexer, s.ns, selector, func(m any) { ret = append(ret, m.(PT)) }); err != nil { return nil, err diff --git a/pkg/timanager/manager.go b/pkg/timanager/manager.go index ce8db06bc1..b04a36307a 100644 --- a/pkg/timanager/manager.go +++ b/pkg/timanager/manager.go @@ -279,7 +279,7 @@ func NewResourceEventHandler[O client.Object, R comparable](ctx context.Context, logger := logr.FromContextOrDiscard(ctx) return cache.ResourceEventHandlerDetailedFuncs{ - AddFunc: func(obj interface{}, isInInitialList bool) { + AddFunc: func(obj any, isInInitialList bool) { e := event.TypedCreateEvent[O]{} if o, ok := obj.(O); ok { @@ -291,7 +291,7 @@ func NewResourceEventHandler[O client.Object, R comparable](ctx context.Context, } h.Create(ctx, e, q) }, - UpdateFunc: func(oldObj, newObj interface{}) { + UpdateFunc: func(oldObj, newObj any) { e := event.TypedUpdateEvent[O]{} if o, ok := oldObj.(O); ok { @@ -312,7 +312,7 @@ func NewResourceEventHandler[O client.Object, R comparable](ctx context.Context, h.Update(ctx, e, q) }, - DeleteFunc: func(obj interface{}) { + DeleteFunc: func(obj any) { e := event.TypedDeleteEvent[O]{} var ok bool diff --git a/pkg/timanager/manager_test.go b/pkg/timanager/manager_test.go index 0fb5925a46..b823a360cb 100644 --- a/pkg/timanager/manager_test.go +++ b/pkg/timanager/manager_test.go @@ -20,8 +20,6 @@ import ( "time" "github.com/go-logr/logr" - "github.com/pingcap/tidb-operator/pkg/client" - "github.com/pingcap/tidb-operator/pkg/utils/fake" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" @@ -31,7 +29,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" + "github.com/pingcap/tidb-operator/pkg/client" pdv1 "github.com/pingcap/tidb-operator/pkg/timanager/apis/pd/v1" + "github.com/pingcap/tidb-operator/pkg/utils/fake" ) func TestClientManager(t *testing.T) { diff --git a/pkg/timanager/poller_test.go b/pkg/timanager/poller_test.go index fb8d908496..f6a5bacb50 100644 --- a/pkg/timanager/poller_test.go +++ b/pkg/timanager/poller_test.go @@ -22,12 +22,13 @@ import ( "time" "github.com/go-logr/logr" - "github.com/pingcap/tidb-operator/pkg/client" - "github.com/pingcap/tidb-operator/pkg/utils/fake" "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" + + "github.com/pingcap/tidb-operator/pkg/client" + "github.com/pingcap/tidb-operator/pkg/utils/fake" ) type FakeLister[T any, PT Object[T]] struct { diff --git a/pkg/utils/k8s/revision/controller_revision.go b/pkg/utils/k8s/revision/controller_revision.go index b0e9b16506..19665d0419 100644 --- a/pkg/utils/k8s/revision/controller_revision.go +++ b/pkg/utils/k8s/revision/controller_revision.go @@ -141,14 +141,14 @@ func getPatch(obj client.Object, gvk schema.GroupVersionKind) ([]byte, error) { return nil, fmt.Errorf("failed to encode patch: %w", err) } - var raw map[string]interface{} + var raw map[string]any if err := json.Unmarshal(buf.Bytes(), &raw); err != nil { return nil, fmt.Errorf("failed to unmarshal data: %w", err) } - objCopy := make(map[string]interface{}) + objCopy := make(map[string]any) objCopy["$patch"] = "replace" - objCopy["spec"] = raw["spec"].(map[string]interface{}) + objCopy["spec"] = raw["spec"].(map[string]any) return json.Marshal(objCopy) } @@ -189,7 +189,7 @@ func TruncateHistory[T v1alpha1.Instance]( history = append(history, revisions[i]) } } - + historyLimit := defaultRevisionHistoryLimit if limit != nil { historyLimit = int(*limit) diff --git a/pkg/utils/toml/toml.go b/pkg/utils/toml/toml.go index f798fac3fa..0b468615b5 100644 --- a/pkg/utils/toml/toml.go +++ b/pkg/utils/toml/toml.go @@ -155,7 +155,6 @@ func getField(src reflect.Value, dst any) (any, error) { } } - // GenerateHash takes a TOML string as input, unmarshals it into a map, // and generates a hash of the resulting configuration. The hash is then // encoded into a safe string format and returned. diff --git a/pkg/version/version.go b/pkg/version/version.go index 9550bf52a8..232426b45e 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -55,8 +55,8 @@ func (info Info) String() string { // KeysAndValues returns the keys and values of the version info. // This is useful for some logging formats. -func (info Info) KeysAndValues() []interface{} { - return []interface{}{ +func (info Info) KeysAndValues() []any { + return []any{ "gitVersion", info.GitVersion, "gitCommit", info.GitCommit, "gitTreeState", info.GitTreeState, diff --git a/tests/e2e/cluster/cluster.go b/tests/e2e/cluster/cluster.go index 42cee1533f..656e5ff5d5 100644 --- a/tests/e2e/cluster/cluster.go +++ b/tests/e2e/cluster/cluster.go @@ -63,7 +63,7 @@ const ( deleteClusterPolling = 5 * time.Second ) -// nolint:unparam +//nolint:unparam func initK8sClient() (kubernetes.Interface, client.Client, *rest.Config) { restConfig, err := k8s.LoadConfig() Expect(err).NotTo(HaveOccurred()) @@ -1102,7 +1102,7 @@ var _ = Describe("TiDB Cluster", func() { Expect(infos[4].name).To(Equal(infos[5].name)) } }) - }) + }) Context("Version Upgrade", func() { When("use the default policy", func() { @@ -1688,8 +1688,7 @@ location-labels = ["region", "zone", "host"]` g.Expect(utiltidb.AreAllInstancesReady(k8sClient, pdg, []*v1alpha1.TiKVGroup{kvg}, []*v1alpha1.TiDBGroup{dbg}, nil)).To(Succeed()) }).WithTimeout(createClusterTimeout).WithPolling(createClusterPolling).Should(Succeed()) - - + By("Recording the terminationGracePeriodSeconds before overlay") listOpts := metav1.ListOptions{LabelSelector: fmt.Sprintf("%s=%s,%s=%s", v1alpha1.LabelKeyCluster, tc.Name, v1alpha1.LabelKeyGroup, dbg.Name)} pods, err := clientSet.CoreV1().Pods(tc.Namespace).List(ctx, listOpts) @@ -1698,7 +1697,7 @@ location-labels = ["region", "zone", "host"]` beforeTermSeconds := pods.Items[0].Spec.TerminationGracePeriodSeconds Expect(beforeTermSeconds).NotTo(BeNil()) beforeUID := pods.Items[0].UID - + By("Overlaying the terminationGracePeriodSeconds") var dbgGet v1alpha1.TiDBGroup Expect(k8sClient.Get(ctx, client.ObjectKey{Namespace: tc.Namespace, Name: dbg.Name}, &dbgGet)).To(Succeed()) @@ -1715,7 +1714,7 @@ location-labels = ["region", "zone", "host"]` g.Expect(ready).To(BeTrue()) g.Expect(utiltidb.AreAllInstancesReady(k8sClient, pdg, []*v1alpha1.TiKVGroup{kvg}, []*v1alpha1.TiDBGroup{dbg}, nil)).To(Succeed()) - + pods, err := clientSet.CoreV1().Pods(tc.Namespace).List(ctx, listOpts) Expect(err).To(BeNil()) Expect(len(pods.Items)).To(Equal(1)) diff --git a/tests/e2e/cluster/tls.go b/tests/e2e/cluster/tls.go index 114c37448c..385e22a836 100644 --- a/tests/e2e/cluster/tls.go +++ b/tests/e2e/cluster/tls.go @@ -290,7 +290,7 @@ func installTiDBComponentsCertificates(ctx context.Context, yamlApplier *k8s.YAM PDGroupName: pdGroupName, TiKVGroupName: tikvGroupName, TiDBGroupName: tidbGroupName, TiFlashGroupName: TiFlashGroupName}) } -func installCert(ctx context.Context, yamlApplier *k8s.YAMLApplier, tmplStr string, tp interface{}) error { +func installCert(ctx context.Context, yamlApplier *k8s.YAMLApplier, tmplStr string, tp any) error { var buf bytes.Buffer tmpl, err := template.New("template").Parse(tmplStr) if err != nil { diff --git a/tests/e2e/config/restclientgetter.go b/tests/e2e/config/restclientgetter.go index 810216bb69..f3edf250a0 100644 --- a/tests/e2e/config/restclientgetter.go +++ b/tests/e2e/config/restclientgetter.go @@ -55,7 +55,7 @@ func (getter *simpleRestClientGetter) ToDiscoveryClient() (discovery.CachedDisco httpCacheDir := defaultCacheDir discoveryCacheDir := computeDiscoverCacheDir(filepath.Join(homedir.HomeDir(), ".kube", "cache", "discovery"), config.Host) - return diskcached.NewCachedDiscoveryClientForConfig(config, discoveryCacheDir, httpCacheDir, time.Duration(10*time.Minute)) + return diskcached.NewCachedDiscoveryClientForConfig(config, discoveryCacheDir, httpCacheDir, 10*time.Minute) } // ToRESTMapper returns a restmapper diff --git a/tests/e2e/utils/data/cluster.go b/tests/e2e/utils/data/cluster.go index 9bd5c2d5e4..6c2ef9eb25 100644 --- a/tests/e2e/utils/data/cluster.go +++ b/tests/e2e/utils/data/cluster.go @@ -17,11 +17,15 @@ package data import ( "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/utils/ptr" "github.com/pingcap/tidb-operator/apis/core/v1alpha1" ) const ( + imageRegistry = "gcr.io/pingcap-public/dbaas/" + helperImage = "gcr.io/pingcap-public/dbaas/busybox:1.36.0" + version = "v8.1.0" GiB = 1024 * 1024 * 1024 ) @@ -59,6 +63,7 @@ func NewPDGroup(namespace, name, clusterName string, replicas *int32, apply func Version: version, Template: v1alpha1.PDTemplate{ Spec: v1alpha1.PDTemplateSpec{ + Image: ptr.To(imageRegistry + "pd"), Volumes: []v1alpha1.Volume{ { Name: "data", @@ -94,6 +99,7 @@ func NewTiKVGroup(namespace, name, clusterName string, replicas *int32, apply fu Replicas: replicas, Template: v1alpha1.TiKVTemplate{ Spec: v1alpha1.TiKVTemplateSpec{ + Image: ptr.To(imageRegistry + "tikv"), Volumes: []v1alpha1.Volume{ { Name: "data", @@ -127,6 +133,14 @@ func NewTiDBGroup(namespace, name, clusterName string, replicas *int32, apply fu Cluster: v1alpha1.ClusterReference{Name: clusterName}, Version: version, Replicas: replicas, + Template: v1alpha1.TiDBTemplate{ + Spec: v1alpha1.TiDBTemplateSpec{ + Image: ptr.To(imageRegistry + "tidb"), + SlowLog: &v1alpha1.TiDBSlowLog{ + Image: ptr.To(helperImage), + }, + }, + }, }, } if apply != nil { @@ -152,6 +166,7 @@ func NewTiFlashGroup(namespace, name, clusterName string, replicas *int32, apply Replicas: replicas, Template: v1alpha1.TiFlashTemplate{ Spec: v1alpha1.TiFlashTemplateSpec{ + Image: ptr.To(imageRegistry + "tiflash"), Volumes: []v1alpha1.Volume{ { Name: "data", @@ -160,6 +175,9 @@ func NewTiFlashGroup(namespace, name, clusterName string, replicas *int32, apply Storage: StorageSizeGi2quantity(1), }, }, + LogTailer: &v1alpha1.TiFlashLogTailer{ + Image: ptr.To(helperImage), + }, }, }, }, diff --git a/tools/tools.go b/tools/tools.go index ca1ad8e24f..86beed83d3 100644 --- a/tools/tools.go +++ b/tools/tools.go @@ -15,6 +15,6 @@ package tools import ( - _ "k8s.io/code-generator/cmd/register-gen" - _ "sigs.k8s.io/controller-tools/cmd/controller-gen" + _ "k8s.io/code-generator" // Intend to import "k8s.io/code-generator/cmd/register-gen", but typecheck will fail + _ "sigs.k8s.io/controller-tools/pkg/version" // Intend to import "sigs.k8s.io/controller-tools/cmd/controller-gen", but typecheck will fail )