Skip to content

Commit fc18d84

Browse files
authored
Upgrade used go version (FoundationDB#1417)
* Upgrade used go version
1 parent f019bd4 commit fc18d84

22 files changed

+66
-54
lines changed

.github/workflows/pull_request.yml

+3-6
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Set up Go
1919
uses: actions/setup-go@v1
2020
with:
21-
go-version: 1.18.6
21+
go-version: 1.19.2
2222
- uses: actions/cache@v2
2323
with:
2424
path: ~/go/pkg/mod
@@ -44,7 +44,7 @@ jobs:
4444
- name: Set up Go
4545
uses: actions/setup-go@v1
4646
with:
47-
go-version: 1.18.6
47+
go-version: 1.19.2
4848
- name: Check out code into the Go module directory
4949
uses: actions/checkout@v2
5050
with:
@@ -104,7 +104,7 @@ jobs:
104104
- name: Set up Go
105105
uses: actions/setup-go@v1
106106
with:
107-
go-version: 1.18.6
107+
go-version: 1.19.2
108108
- name: Check out code into the Go module directory
109109
uses: actions/checkout@v2
110110
with:
@@ -126,10 +126,7 @@ jobs:
126126
# Install dependencies either from cache or freshly downloaded
127127
sudo dpkg -i fdb.deb
128128
- name: Run tests
129-
# Currently the default runner has 2 vCPU:
130-
# https://docs.github.com/en/free-pro-team@latest/actions/reference/specifications-for-github-hosted-runners#supported-runners-and-hardware-resources
131129
env:
132-
GOMAXPROCS: "2"
133130
TEST_RACE_CONDITIONS: "1"
134131
run: |
135132
make test

.github/workflows/release.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
- name: Set up Go
4444
uses: actions/setup-go@v1
4545
with:
46-
go-version: 1.18.6
46+
go-version: 1.19.2
4747
# https://github.com/goreleaser/goreleaser/issues/1311
4848
- name: Get current semver tag
4949
run: echo "::set-output name=CURRENT_TAG::$(git describe --tags --match "v*" --abbrev=0)"

.golangci.yml

+43-17
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,63 @@ issues:
22
# don't skip warning about doc comments
33
# don't exclude the default set of lint
44
exclude-use-default: false
5+
exclude:
6+
- "ST1000: at least one file in a package should have a package comment"
57
exclude-rules:
68
# exclude deprecation warning otherwise we get an error for our own deprecations
7-
- linters: [staticcheck]
9+
- linters:
10+
- staticcheck
811
text: "SA1019:"
9-
- linters: [ govet ]
12+
- linters:
13+
- govet
1014
text: 'declaration of "(err|ctx)" shadows declaration at'
15+
- linters:
16+
- revive
17+
text: "package-comments: should have a package comment"
18+
# TODO (johscheuer): Ignore those linting issues for now and change it once we cut a new major release.
19+
- linters:
20+
- stylecheck
21+
text: "ST1003: const StorageEngineRocksDbExperimental"
22+
- linters:
23+
- stylecheck
24+
text: "ST1003: const StorageEngineRocksDbV1"
1125

1226
linters:
1327
disable-all: true
1428
# TODO(johscheuer): activate linters again and fix issues
1529
enable:
16-
- deadcode
17-
#- dupl
30+
- asciicheck
31+
- bodyclose
32+
- depguard
33+
- dogsled
1834
- errcheck
19-
#- goconst
20-
#- gocyclo
35+
# - errorlint
36+
- exportloopref
37+
# - goconst
38+
# - gocritic
39+
# - gocyclo
2140
- gofmt
22-
- goimports
23-
- revive
24-
#- gosec
41+
#- goimports
42+
- goprintffuncname
43+
# - gosec
2544
- gosimple
2645
- govet
46+
- importas
2747
- ineffassign
28-
#- interfacer
29-
#- lll
30-
#- maligned
3148
- misspell
3249
- nakedret
50+
- nilerr
51+
# - nolintlint
3352
- prealloc
34-
- exportloopref
53+
- revive
54+
- rowserrcheck
3555
- staticcheck
36-
- structcheck
56+
- stylecheck
3757
- typecheck
3858
- unconvert
3959
- unparam
4060
- unused
41-
- varcheck
61+
- whitespace
4262

4363
linters-settings:
4464
errcheck:
@@ -48,7 +68,13 @@ linters-settings:
4868
govet:
4969
enable:
5070
- shadow
71+
staticcheck:
72+
go: "1.19"
73+
stylecheck:
74+
go: "1.19"
75+
5176
run:
52-
deadline: 5m
77+
timeout: 10m
5378
skip-files:
54-
- ".*_generated.*.go$"
79+
- "zz_generated.*\\.go$"
80+
allow-parallel-runners: true

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ARG BASE_IMAGE=docker.io/debian:bullseye
22

33
# Build the manager binary
4-
FROM docker.io/library/golang:1.18.6 as builder
4+
FROM docker.io/library/golang:1.19.2 as builder
55

66
# Install FDB this version is only required to compile the fdb operator
77
ARG FDB_VERSION=6.2.29

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ CONTROLLER_GEN_PKG?=sigs.k8s.io/controller-tools/cmd/[email protected]
3333
CONTROLLER_GEN=$(GOBIN)/controller-gen
3434
KUSTOMIZE_PKG?=sigs.k8s.io/kustomize/kustomize/[email protected]
3535
KUSTOMIZE=$(GOBIN)/kustomize
36-
GOLANGCI_LINT_PKG=github.com/golangci/golangci-lint/cmd/golangci-lint@v1.46.2
36+
GOLANGCI_LINT_PKG=github.com/golangci/golangci-lint/cmd/golangci-lint@v1.50.1
3737
GOLANGCI_LINT=$(GOBIN)/golangci-lint
3838
GORELEASER_PKG=github.com/goreleaser/[email protected]
3939
GORELEASER=$(GOBIN)/goreleaser

api/v1beta1/foundationdb_database_configuration.go

-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@ func (configuration DatabaseConfiguration) GetNextConfigurationChange(finalConfi
335335
} else if dataCenter.Priority > 0 {
336336
hasAlternativePrimary = true
337337
}
338-
339338
}
340339
}
341340
}

api/v1beta1/foundationdbcluster_types.go

-1
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,6 @@ func (clusterStatus FoundationDBClusterStatus) ProcessGroupsByProcessClass(proce
789789
if groupStatus.ProcessClass == processClass {
790790
result = append(result, groupStatus)
791791
}
792-
793792
}
794793

795794
return result

api/v1beta2/foundationdb_database_configuration.go

-1
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,6 @@ func (configuration DatabaseConfiguration) GetNextConfigurationChange(finalConfi
444444
} else if dataCenter.Priority > 0 {
445445
hasAlternativePrimary = true
446446
}
447-
448447
}
449448
}
450449
}

api/v1beta2/foundationdbcluster_types.go

-1
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,6 @@ func (clusterStatus FoundationDBClusterStatus) ProcessGroupsByProcessClass(proce
620620
if groupStatus.ProcessClass == processClass {
621621
result = append(result, groupStatus)
622622
}
623-
624623
}
625624

626625
return result

cmd/po-docgen/api.go

-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ func ParseDocumentationFrom(srcs []string) []KubeTypes {
124124
pkg := astFrom(src)
125125

126126
for _, kubType := range pkg.Types {
127-
128127
if structType, ok := kubType.Decl.Specs[0].(*ast.TypeSpec).Type.(*ast.StructType); ok {
129128
var ks KubeTypes
130129
ks = append(ks, Pair{kubType.Name, fmtRawDoc(kubType.Doc), "", false})

controllers/admin_client_mock.go

-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ func (client *mockAdminClient) GetStatus() (*fdbv1beta2.FoundationDBStatus, erro
256256
Version: client.Cluster.Status.RunningVersion,
257257
UptimeSeconds: uptimeSeconds,
258258
}
259-
260259
}
261260
}
262261

controllers/change_coordinators.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ func selectCoordinators(cluster *fdbv1beta2.FoundationDBCluster, status *fdbv1be
154154

155155
candidates, err := selectCandidates(cluster, status)
156156
if err != nil {
157-
return []localityInfo{}, nil
157+
return []localityInfo{}, err
158158
}
159159

160160
coordinators, err := chooseDistributedProcesses(cluster, candidates, coordinatorCount, processSelectionConstraint{

controllers/cluster_controller.go

-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ func (r *FoundationDBClusterReconciler) Reconcile(ctx context.Context, request c
8989
if err != nil {
9090
if k8serrors.IsNotFound(err) {
9191
return ctrl.Result{}, nil
92-
9392
}
9493
// Error reading the object - requeue the request.
9594
return ctrl.Result{}, err

controllers/update_status.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ func tryConnectionOptions(cluster *fdbv1beta2.FoundationDBCluster, r *Foundation
341341
if err == nil {
342342
logger.Info("Chose connection option",
343343
"version", version, "connectionString", activeConnectionString)
344-
return version, activeConnectionString, err
344+
return version, activeConnectionString, nil
345345
}
346346
logger.Error(err, "Error getting connection string from cluster",
347347
"version", version, "connectionString", connectionString)

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/FoundationDB/fdb-kubernetes-operator
22

3-
go 1.18
3+
go 1.19
44

55
require (
66
github.com/apple/foundationdb/bindings/go v0.0.0-20201222225940-f3aef311ccfb

internal/deprecations.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525

2626
fdbtypes "github.com/FoundationDB/fdb-kubernetes-operator/api/v1beta2"
2727
corev1 "k8s.io/api/core/v1"
28-
v1 "k8s.io/api/core/v1"
2928
"k8s.io/apimachinery/pkg/api/resource"
3029
)
3130

@@ -61,12 +60,12 @@ func NormalizeClusterSpec(cluster *fdbtypes.FoundationDBCluster, options Depreca
6160

6261
if !options.OnlyShowChanges {
6362
// Set up resource requirements for the main container.
64-
updatePodTemplates(&cluster.Spec, func(template *v1.PodTemplateSpec) {
63+
updatePodTemplates(&cluster.Spec, func(template *corev1.PodTemplateSpec) {
6564
template.Spec.Containers, _ = ensureContainerPresent(template.Spec.Containers, "foundationdb", 0)
6665

67-
template.Spec.Containers = customizeContainerFromList(template.Spec.Containers, "foundationdb", func(container *v1.Container) {
66+
template.Spec.Containers = customizeContainerFromList(template.Spec.Containers, "foundationdb", func(container *corev1.Container) {
6867
if container.Resources.Requests == nil {
69-
container.Resources.Requests = v1.ResourceList{
68+
container.Resources.Requests = corev1.ResourceList{
7069
"cpu": resource.MustParse("1"),
7170
"memory": resource.MustParse("1Gi"),
7271
}
@@ -77,9 +76,9 @@ func NormalizeClusterSpec(cluster *fdbtypes.FoundationDBCluster, options Depreca
7776
}
7877
})
7978

80-
sidecarUpdater := func(container *v1.Container) {
79+
sidecarUpdater := func(container *corev1.Container) {
8180
if container.Resources.Requests == nil {
82-
container.Resources.Requests = v1.ResourceList{
81+
container.Resources.Requests = corev1.ResourceList{
8382
"cpu": resource.MustParse("100m"),
8483
"memory": resource.MustParse("256Mi"),
8584
}

internal/pod_client.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ func (client *realFdbPodSidecarClient) getListenIP() string {
173173

174174
// makeRequest submits a request to the sidecar.
175175
func (client *realFdbPodSidecarClient) makeRequest(method, path string) (string, int, error) {
176-
var resp *http.Response
177176
var err error
178177

179178
protocol := "http"
@@ -190,13 +189,16 @@ func (client *realFdbPodSidecarClient) makeRequest(method, path string) (string,
190189
}
191190

192191
url := fmt.Sprintf("%s://%s:8080/%s", protocol, client.getListenIP(), path)
192+
var resp *http.Response
193193
switch method {
194194
case http.MethodGet:
195195
retryClient.HTTPClient.Timeout = client.getTimeout
196196
resp, err = retryClient.Get(url)
197+
defer resp.Body.Close()
197198
case http.MethodPost:
198199
retryClient.HTTPClient.Timeout = client.postTimeout
199200
resp, err = retryClient.Post(url, "application/json", strings.NewReader(""))
201+
defer resp.Body.Close()
200202
default:
201203
return "", 0, fmt.Errorf("unknown HTTP method %s", method)
202204
}
@@ -205,8 +207,6 @@ func (client *realFdbPodSidecarClient) makeRequest(method, path string) (string,
205207
return "", 0, err
206208
}
207209

208-
defer resp.Body.Close()
209-
210210
body, err := io.ReadAll(resp.Body)
211211
bodyText := string(body)
212212

@@ -221,7 +221,7 @@ func (client *realFdbPodSidecarClient) makeRequest(method, path string) (string,
221221
func (client *realFdbPodSidecarClient) IsPresent(filename string) (bool, error) {
222222
version, err := fdbv1beta2.ParseFdbVersion(client.Cluster.Spec.Version)
223223
if err != nil {
224-
return false, nil
224+
return false, err
225225
}
226226

227227
path := "check_hash"

internal/pod_models.go

-1
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,6 @@ func GetBackupDeployment(backup *fdbv1beta2.FoundationDBBackup) (*appsv1.Deploym
852852
for _, customParameter := range backup.Spec.CustomParameters {
853853
args = append(args, fmt.Sprintf("--%s", customParameter))
854854
}
855-
856855
}
857856

858857
mainContainer.Args = args

kubectl-fdb/cmd/analyze_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ func getPodList(clusterName string, namespace string, status corev1.PodStatus, d
7979
},
8080
},
8181
}
82-
8382
}
8483

8584
var _ = Describe("[plugin] analyze cluster", func() {

kubectl-fdb/cmd/exec.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,14 @@ func buildCommand(kubeClient client.Client, cluster *fdbv1beta2.FoundationDBClus
111111
for key, value := range cluster.GetMatchLabels() {
112112
requirement, err := labels.NewRequirement(key, selection.Equals, []string{value})
113113
if err != nil {
114-
return exec.Cmd{}, nil
114+
return exec.Cmd{}, err
115115
}
116116
selector = selector.Add(*requirement)
117117
}
118118

119119
processClassRequirement, err := labels.NewRequirement(cluster.GetProcessClassLabel(), selection.Exists, nil)
120120
if err != nil {
121-
return exec.Cmd{}, nil
121+
return exec.Cmd{}, err
122122
}
123123
selector = selector.Add(*processClassRequirement)
124124

kubectl-fdb/cmd/k8s_client.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ import (
3737
corev1 "k8s.io/api/core/v1"
3838
"k8s.io/apimachinery/pkg/types"
3939
"k8s.io/client-go/kubernetes"
40-
"k8s.io/client-go/kubernetes/scheme"
4140
"k8s.io/client-go/rest"
4241
"k8s.io/client-go/tools/clientcmd"
4342
"k8s.io/client-go/tools/remotecommand"
@@ -143,7 +142,7 @@ func executeCmd(restConfig *rest.Config, kubeClient *kubernetes.Clientset, podNa
143142
}
144143
req.VersionedParams(
145144
option,
146-
scheme.ParameterCodec,
145+
clientgoscheme.ParameterCodec,
147146
)
148147
exec, err := remotecommand.NewSPDYExecutor(restConfig, "POST", req.URL())
149148
if err != nil {

kubectl-fdb/cmd/version.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ func newVersionCmd(streams genericclioptions.IOStreams) *cobra.Command {
4747
}
4848
clientOnly, err := cmd.Flags().GetBool("client-only")
4949
if err != nil {
50-
return nil
50+
return err
5151
}
5252
containerName, err := cmd.Flags().GetString("container-name")
5353
if err != nil {
54-
return nil
54+
return err
5555
}
5656

5757
if !clientOnly {

0 commit comments

Comments
 (0)