Skip to content

Commit 68e781a

Browse files
authored
Build Cortex with Go 1.19 (#4829)
Signed-off-by: Alvin Lin <[email protected]>
1 parent f578de9 commit 68e781a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+175
-164
lines changed

Diff for: .github/workflows/test-build-deploy.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
lint:
1111
runs-on: ubuntu-20.04
1212
container:
13-
image: quay.io/cortexproject/build-image:update-hugo-0.94.x-96d1d7cdd
13+
image: quay.io/cortexproject/build-image:update-go-1-19-a2f4d2c79
1414
steps:
1515
- name: Checkout Repo
1616
uses: actions/checkout@v2
@@ -34,7 +34,7 @@ jobs:
3434
test:
3535
runs-on: ubuntu-20.04
3636
container:
37-
image: quay.io/cortexproject/build-image:update-hugo-0.94.x-96d1d7cdd
37+
image: quay.io/cortexproject/build-image:update-go-1-19-a2f4d2c79
3838
steps:
3939
- name: Checkout Repo
4040
uses: actions/checkout@v2
@@ -48,7 +48,7 @@ jobs:
4848
build:
4949
runs-on: ubuntu-20.04
5050
container:
51-
image: quay.io/cortexproject/build-image:update-hugo-0.94.x-96d1d7cdd
51+
image: quay.io/cortexproject/build-image:update-go-1-19-a2f4d2c79
5252
steps:
5353
- name: Checkout Repo
5454
uses: actions/checkout@v2
@@ -163,14 +163,14 @@ jobs:
163163
run: |
164164
touch build-image/.uptodate
165165
MIGRATIONS_DIR=$(pwd)/cmd/cortex/migrations
166-
make BUILD_IMAGE=quay.io/cortexproject/build-image:update-hugo-0.94.x-96d1d7cdd TTY='' configs-integration-test
166+
make BUILD_IMAGE=quay.io/cortexproject/build-image:update-go-1-19-a2f4d2c79 TTY='' configs-integration-test
167167
168168
deploy_website:
169169
needs: [build, test]
170170
if: (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')) && github.repository == 'cortexproject/cortex'
171171
runs-on: ubuntu-20.04
172172
container:
173-
image: quay.io/cortexproject/build-image:update-hugo-0.94.x-96d1d7cdd
173+
image: quay.io/cortexproject/build-image:update-go-1-19-a2f4d2c79
174174
steps:
175175
- name: Checkout Repo
176176
uses: actions/checkout@v2
@@ -207,7 +207,7 @@ jobs:
207207
if: (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')) && github.repository == 'cortexproject/cortex'
208208
runs-on: ubuntu-20.04
209209
container:
210-
image: quay.io/cortexproject/build-image:update-hugo-0.94.x-96d1d7cdd
210+
image: quay.io/cortexproject/build-image:update-go-1-19-a2f4d2c79
211211
steps:
212212
- name: Checkout Repo
213213
uses: actions/checkout@v2

Diff for: .golangci.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@ output:
44
linters:
55
enable:
66
- goimports
7-
- golint
7+
- revive
88
- gofmt
99
- misspell
1010
- depguard
1111

1212
linters-settings:
13+
staticcheck:
14+
checks:
15+
- all
16+
- "-SA1019" # Disable because too many file uses io/ioutil now, will fix later
1317
errcheck:
1418
# path to a file containing a list of functions to exclude from checking
1519
# see https://github.com/kisielk/errcheck#excluding-functions for details

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
* [CHANGE] Disables TSDB isolation. #4825
4141
* [ENHANCEMENT] Querier/Ruler: Retry store-gateway in case of unexpected failure, instead of failing the query. #4532
4242
* [ENHANCEMENT] Ring: DoBatch prioritize 4xx errors when failing. #4783
43+
* [ENHANCEMENT] Cortex now built with Go 1.18. #4829
4344
* [FEATURE] Compactor: Added `-compactor.block-files-concurrency` allowing to configure number of go routines for download/upload block files during compaction. #4784
4445
* [FEATURE] Compactor: Added -compactor.blocks-fetch-concurrency` allowing to configure number of go routines for blocks during compaction. #4787
4546
* [FEATURE] Compactor: Added configurations for Azure MSI in blocks-storage, ruler-storage and alertmanager-storage. #4818

Diff for: Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ build-image/$(UPTODATE): build-image/*
116116
SUDO := $(shell docker info >/dev/null 2>&1 || echo "sudo -E")
117117
BUILD_IN_CONTAINER := true
118118
BUILD_IMAGE ?= $(IMAGE_PREFIX)build-image
119-
LATEST_BUILD_IMAGE_TAG ?= update-hugo-0.94.x-96d1d7cdd
119+
LATEST_BUILD_IMAGE_TAG ?= update-go-1-19-a2f4d2c79
120120

121121
# TTY is parameterized to allow Google Cloud Builder to run builds,
122122
# as it currently disallows TTY devices. This value needs to be overridden

Diff for: cmd/cortex/main_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"bytes"
55
"flag"
66
"io"
7-
"io/ioutil"
87
"os"
98
"strings"
109
"sync"
@@ -111,7 +110,7 @@ func testSingle(t *testing.T, arguments []string, yaml string, stdoutMessage, st
111110
defer restoreIfNeeded()
112111

113112
if yaml != "" {
114-
tempFile, err := ioutil.TempFile("", "test")
113+
tempFile, err := os.CreateTemp("", "test")
115114
require.NoError(t, err)
116115

117116
defer func() {

Diff for: cmd/thanosconvert/main.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"flag"
66
"fmt"
7-
"io/ioutil"
87
"os"
98
"strings"
109

@@ -42,7 +41,7 @@ func main() {
4241
}
4342

4443
if configFilename != "" {
45-
buf, err := ioutil.ReadFile(configFilename)
44+
buf, err := os.ReadFile(configFilename)
4645
if err != nil {
4746
fatal("failed to load config file from %s: %v", configFilename, err)
4847
}

Diff for: docs/contributing/how-to-run-website-locally.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@ The Cortex documentation is compiled into a website published at [cortexmetrics.
1212

1313
The following initial setup is required only once:
1414

15-
1. Install [Hugo](https://gohugo.io/) `v0.94.2` (**extended** version)
16-
2. Install [Node.js](https://nodejs.org/en/) `v14` or above (alternatively via [`nvm`](https://github.com/nvm-sh/nvm))
17-
3. Install required Node modules with:
15+
1. Install [Hugo](https://gohugo.io/) (**extended** version)
16+
* Look for value of `HUGO_VERSION` in `build-image/Dockerfile`.
17+
1. Install [Node.js](https://nodejs.org/en/) `v14` or above (alternatively via [`nvm`](https://github.com/nvm-sh/nvm))
18+
1. Install required Node modules with:
1819
```
1920
cd website && npm install && cd -
2021
```
21-
4. Install [embedmd](https://github.com/campoy/embedmd) `v1.0.0`:
22+
1. Install [embedmd](https://github.com/campoy/embedmd) `v1.0.0`:
2223
```
2324
go install github.com/campoy/[email protected]
2425
```
25-
5. Run `make BUILD_IN_CONTAINER=false web-build`
26+
1. Run `make BUILD_IN_CONTAINER=false web-build`
2627

2728

2829
## Run it

Diff for: integration/asserts.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build requires_docker
12
// +build requires_docker
23

34
package integration

Diff for: integration/blocks_storage_backends_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build requires_docker
12
// +build requires_docker
23

34
package integration

Diff for: integration/e2e/scenario_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build requires_docker
12
// +build requires_docker
23

34
package e2e_test

Diff for: integration/e2e/service_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build requires_docker
12
// +build requires_docker
23

34
package e2e

Diff for: integration/e2ecortex/client.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"errors"
88
"fmt"
99
"io"
10-
"io/ioutil"
1110
"net/http"
1211
"net/url"
1312
"strconv"
@@ -171,7 +170,7 @@ func (c *Client) query(addr string) (*http.Response, []byte, error) {
171170
}
172171
defer res.Body.Close()
173172

174-
body, err := ioutil.ReadAll(res.Body)
173+
body, err := io.ReadAll(res.Body)
175174
if err != nil {
176175
return nil, nil, err
177176
}
@@ -234,7 +233,7 @@ func (c *Client) GetPrometheusRules() ([]*ruler.RuleGroup, error) {
234233
}
235234
defer res.Body.Close()
236235

237-
body, err := ioutil.ReadAll(res.Body)
236+
body, err := io.ReadAll(res.Body)
238237
if err != nil {
239238
return nil, err
240239
}
@@ -278,7 +277,7 @@ func (c *Client) GetRuleGroups() (map[string][]rulefmt.RuleGroup, error) {
278277
defer res.Body.Close()
279278
rgs := map[string][]rulefmt.RuleGroup{}
280279

281-
data, err := ioutil.ReadAll(res.Body)
280+
data, err := io.ReadAll(res.Body)
282281
if err != nil {
283282
return nil, err
284283
}
@@ -412,7 +411,7 @@ func (c *Client) getRawPage(ctx context.Context, url string) ([]byte, error) {
412411
}
413412
defer resp.Body.Close()
414413

415-
content, err := ioutil.ReadAll(resp.Body)
414+
content, err := io.ReadAll(resp.Body)
416415
if err != nil {
417416
return nil, err
418417
}

Diff for: integration/getting_started_single_process_config_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build requires_docker
12
// +build requires_docker
23

34
package integration

Diff for: integration/getting_started_with_gossiped_ring_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build requires_docker
12
// +build requires_docker
23

34
package integration

Diff for: integration/ingester_limits_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build requires_docker
12
// +build requires_docker
23

34
package integration

Diff for: integration/ingester_sharding_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build requires_docker
12
// +build requires_docker
23

34
package integration

Diff for: integration/integration_memberlist_single_binary_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build requires_docker
12
// +build requires_docker
23

34
package integration

Diff for: integration/querier_remote_read_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build requires_docker
12
// +build requires_docker
23

34
package integration

Diff for: integration/querier_sharding_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build requires_docker
12
// +build requires_docker
23

34
package integration

Diff for: integration/querier_tenant_federation_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build requires_docker
12
// +build requires_docker
23

34
package integration

Diff for: integration/querier_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build requires_docker
12
// +build requires_docker
23

34
package integration

Diff for: integration/query_frontend_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build requires_docker
12
// +build requires_docker
23

34
package integration

Diff for: integration/util.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build requires_docker
12
// +build requires_docker
23

34
package integration

Diff for: pkg/configs/db/db.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"context"
55
"flag"
66
"fmt"
7-
"io/ioutil"
87
"net/url"
8+
"os"
99

1010
"github.com/cortexproject/cortex/pkg/configs/db/memory"
1111
"github.com/cortexproject/cortex/pkg/configs/db/postgres"
@@ -73,7 +73,7 @@ func New(cfg Config) (DB, error) {
7373
if u.User == nil {
7474
return nil, fmt.Errorf("--database.password-file requires username in --database.uri")
7575
}
76-
passwordBytes, err := ioutil.ReadFile(cfg.PasswordFile)
76+
passwordBytes, err := os.ReadFile(cfg.PasswordFile)
7777
if err != nil {
7878
return nil, fmt.Errorf("Could not read database password file: %v", err)
7979
}

Diff for: pkg/configs/legacy_promql/ast.go

+7-8
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
13-
//nolint //Since this was copied from Prometheus leave it as is
13+
// nolint //Since this was copied from Prometheus leave it as is
1414
package promql
1515

1616
import (
@@ -27,13 +27,12 @@ import (
2727
// or a chain of function definitions (e.g. String(), expr(), etc.) convention is
2828
// to list them as follows:
2929
//
30-
// - Statements
31-
// - statement types (alphabetical)
32-
// - ...
33-
// - Expressions
34-
// - expression types (alphabetical)
35-
// - ...
36-
//
30+
// - Statements
31+
// - statement types (alphabetical)
32+
// - ...
33+
// - Expressions
34+
// - expression types (alphabetical)
35+
// - ...
3736
type Node interface {
3837
// String representation of the node that returns the given node when parsed
3938
// as part of a valid query.

Diff for: pkg/configs/legacy_promql/engine.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
13-
//nolint //Since this was copied from Prometheus leave it as is
13+
// nolint //Since this was copied from Prometheus leave it as is
1414
package promql
1515

1616
import (

0 commit comments

Comments
 (0)