Skip to content

Commit 9576907

Browse files
Bump Go min version to Go 1.23 (#805)
* Bump Go min version to Go 1.23 Signed-off-by: Austin Vazquez <[email protected]> * Resolve lint warnings for golangci-lint v1.64.2 Signed-off-by: Austin Vazquez <[email protected]> --------- Signed-off-by: Austin Vazquez <[email protected]>
1 parent e5a3c77 commit 9576907

Some content is hidden

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

62 files changed

+163
-159
lines changed

.github/workflows/build.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
matrix:
1616
os: ['ubuntu-20.04', 'ubuntu-22.04']
17-
go: ['1.21', '1.22']
17+
go: ['1.23', '1.24']
1818
# Build all variants regardless of failures
1919
fail-fast: false
2020

.golangci.yml

+17-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ linters:
55
disable-all: true
66
enable:
77
- govet
8+
- copyloopvar
89
- staticcheck
9-
# - unused
1010
- gosimple
1111
- ineffassign
1212
- typecheck
@@ -19,15 +19,29 @@ linters:
1919
- gocritic
2020
- gofmt
2121
- revive
22-
- exportloopref
2322

2423
issues:
2524
exclude-use-default: false
2625
exclude:
2726
- G104 # Errors unhandled
2827
- G103 # Use of unsafe calls should be audited
28+
- G114 # Use of net/http serve function without timeouts.
29+
- G115 # Integer overflow conversion should be audited
2930
- G204 # Subprocess launched with variable
31+
- G301 # Expect directory permissions to be 0750 or less
3032
- G304 # Potential file inclusion via variable
3133
- G306 # WriteFile permissions 0600 or less to be audited
3234
- G307 # Deferring unsafe method "Close" on type "*os.File" to be audited
33-
-
35+
- G404 # Use of weak random number generator
36+
exclude-rules:
37+
- linters:
38+
- govet
39+
text: "copylocks"
40+
- linters:
41+
- revive
42+
text: package-comments
43+
- linters:
44+
- staticcheck
45+
text: "Do not rely on the global seed"
46+
exclude-dirs:
47+
- snapshotter/internal/integtest/stargz # Code copied from upstream stargz

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ SUBMODULES=_submodules
2828
UID:=$(shell id -u)
2929
GID:=$(shell id -g)
3030

31-
FIRECRACKER_CONTAINERD_BUILDER_IMAGE?=golang:1.21-bullseye
31+
FIRECRACKER_CONTAINERD_BUILDER_IMAGE?=golang:1.23-bullseye
3232
export FIRECRACKER_CONTAINERD_TEST_IMAGE?=localhost/firecracker-containerd-test
3333
export GO_CACHE_VOLUME_NAME?=gocache
3434

@@ -136,7 +136,7 @@ tidy:
136136
./tools/tidy.sh
137137

138138
$(BINPATH)/golangci-lint:
139-
GOBIN=$(BINPATH) go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.57.2
139+
GOBIN=$(BINPATH) go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.2
140140
$(BINPATH)/golangci-lint --version
141141

142142
$(BINPATH)/git-validation:

agent/drive_handler.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ import (
2121
"strings"
2222
"time"
2323

24-
"github.com/containerd/containerd/log"
2524
"github.com/containerd/containerd/mount"
2625
"github.com/containerd/containerd/protobuf/types"
26+
"github.com/containerd/log"
2727
"github.com/firecracker-microvm/firecracker-containerd/internal"
2828
drivemount "github.com/firecracker-microvm/firecracker-containerd/proto/service/drivemount/ttrpc"
2929
)
@@ -214,7 +214,7 @@ func (dh driveHandler) MountDrive(ctx context.Context, req *drivemount.MountDriv
214214
return nil, fmt.Errorf("exhausted retries mounting drive from %q to %q", drive.Path(), req.DestinationPath)
215215
}
216216

217-
func (dh driveHandler) UnmountDrive(ctx context.Context, req *drivemount.UnmountDriveRequest) (*types.Empty, error) {
217+
func (dh driveHandler) UnmountDrive(_ context.Context, req *drivemount.UnmountDriveRequest) (*types.Empty, error) {
218218
drive, ok := dh.GetDrive(req.DriveID)
219219
if !ok {
220220
return nil, fmt.Errorf("drive %q could not be found", req.DriveID)

agent/error_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ func TestIsRetryableMountError(t *testing.T) {
5555
}
5656

5757
for _, c := range cases {
58-
c := c // see https://github.com/kyoh86/scopelint/issues/4
5958
t.Run(c.Name, func(t *testing.T) {
6059
assert.Equal(t, c.Expected, isRetryableMountError(c.Error))
6160
})

agent/ioproxy_handler.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import (
1717
"context"
1818

1919
task "github.com/containerd/containerd/api/runtime/task/v2"
20-
"github.com/containerd/containerd/log"
2120
"github.com/containerd/containerd/protobuf/types"
21+
"github.com/containerd/log"
2222
"github.com/firecracker-microvm/firecracker-containerd/internal/vm"
2323
ioproxy "github.com/firecracker-microvm/firecracker-containerd/proto/service/ioproxy/ttrpc"
2424
)

agent/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ import (
2323

2424
taskAPI "github.com/containerd/containerd/api/runtime/task/v2"
2525
"github.com/containerd/containerd/events/exchange"
26-
"github.com/containerd/containerd/log"
2726
"github.com/containerd/containerd/namespaces"
2827
"github.com/containerd/containerd/sys/reaper"
28+
"github.com/containerd/log"
2929
"github.com/containerd/ttrpc"
3030
"github.com/firecracker-microvm/firecracker-go-sdk/vsock"
3131
"github.com/opencontainers/runc/libcontainer/system"

agent/service.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ import (
2525
taskAPI "github.com/containerd/containerd/api/runtime/task/v2"
2626
"github.com/containerd/containerd/cio"
2727
"github.com/containerd/containerd/identifiers"
28-
"github.com/containerd/containerd/log"
2928
"github.com/containerd/containerd/mount"
3029
"github.com/containerd/containerd/protobuf/types"
3130
runc "github.com/containerd/containerd/runtime/v2/runc/v2"
3231
"github.com/containerd/containerd/runtime/v2/shim"
32+
"github.com/containerd/log"
3333
"github.com/hashicorp/go-multierror"
3434
"github.com/sirupsen/logrus"
3535
"golang.org/x/sys/unix"

docs/getting-started.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ You need to have the following things in order to use firecracker-containerd:
4040
* git
4141
* gcc, required by the Firecracker agent for building
4242
* A recent installation of [Docker CE](https://docker.com).
43-
* Go 1.21 or later, which you can download from [here](https://golang.org/dl/).
43+
* Go 1.23 or later, which you can download from [here](https://golang.org/dl/).
4444

4545
## Setup
4646

docs/quickstart.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ files into `/usr/local/bin`.
2828

2929
cd ~
3030

31-
# Install git, Go 1.21, make, curl
31+
# Install git, Go 1.23, make, curl
3232
sudo mkdir -p /etc/apt/sources.list.d
3333
echo "deb http://ftp.debian.org/debian bullseye-backports main" | \
3434
sudo tee /etc/apt/sources.list.d/bullseye-backports.list
3535
sudo DEBIAN_FRONTEND=noninteractive apt-get update
3636
sudo DEBIAN_FRONTEND=noninteractive apt-get \
3737
install --yes \
38-
golang-1.21 \
38+
golang-1.23 \
3939
make \
4040
git \
4141
curl \
@@ -44,8 +44,8 @@ sudo DEBIAN_FRONTEND=noninteractive apt-get \
4444
bc \
4545
gnupg
4646

47-
# Debian's Go 1.21 package installs "go" command under /usr/lib/go-1.21/bin
48-
export PATH=/usr/lib/go-1.21/bin:$PATH
47+
# Debian's Go 1.23 package installs "go" command under /usr/lib/go-1.23/bin
48+
export PATH=/usr/lib/go-1.23/bin:$PATH
4949

5050
cd ~
5151

@@ -93,7 +93,7 @@ sudo yum -y install \
9393
# need to source environment variables afterwards for the existing shell session.
9494
curl -LO https://get.golang.org/$(uname)/go_installer && \
9595
chmod +x go_installer && \
96-
./go_installer -version 1.21 && \
96+
./go_installer -version 1.23 && \
9797
rm go_installer && \
9898
source .bash_profile
9999

docs/remote-snapshotter-getting-started.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ You will need the following to use firecracker-containerd with support for remot
1616

1717
* git
1818

19-
* Go 1.21 or later
19+
* Go 1.23 or later
2020

2121
* This repository cloned onto your local machine
2222

eventbridge/eventbridge.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func (s *getterService) GetEvent(ctx context.Context) (*eventapi.Envelope, error
8989
// RegisterGetterService adds the Getter service as a method to the provided TTRPC server.
9090
func RegisterGetterService(srv *ttrpc.Server, svc Getter) {
9191
srv.Register(getterServiceName, map[string]ttrpc.Method{
92-
getEventMethodName: func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
92+
getEventMethodName: func(ctx context.Context, _ func(any) error) (any, error) {
9393
return svc.GetEvent(ctx)
9494
},
9595
})

eventbridge/eventbridge_test.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,13 @@ func verifyPublishAndReceive(ctx context.Context, t *testing.T, source eventtype
7979
topic := "/just/container/things"
8080
sinkEventCh, sinkErrorCh := sink.Subscribe(ctx, fmt.Sprintf(`topic=="%s"`, topic))
8181

82-
for i := 0; i < 100; i++ {
82+
const taskLimit uint32 = 100
83+
for i := range taskLimit {
8384
taskExitEvent := &events.TaskExit{
8485
ContainerID: fmt.Sprintf("container-%d", i),
8586
ID: fmt.Sprintf("id-%d", i),
86-
Pid: uint32(i),
87-
ExitStatus: uint32(i + 1),
87+
Pid: i,
88+
ExitStatus: i + 1,
8889
ExitedAt: protobuf.ToTimestamp(time.Now().UTC()),
8990
}
9091

examples/cmd/remote-snapshotter/go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/firecracker-microvm/firecracker-containerd/example/remote-snapshotter
22

3-
go 1.21
3+
go 1.23.0
44

55
require (
66
github.com/containerd/containerd v1.7.16
@@ -48,7 +48,7 @@ require (
4848
golang.org/x/mod v0.18.0 // indirect
4949
golang.org/x/net v0.33.0 // indirect
5050
golang.org/x/sync v0.10.0 // indirect
51-
golang.org/x/sys v0.28.0 // indirect
51+
golang.org/x/sys v0.31.0 // indirect
5252
golang.org/x/text v0.21.0 // indirect
5353
golang.org/x/tools v0.22.0 // indirect
5454
google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80 // indirect

examples/cmd/remote-snapshotter/go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -1167,8 +1167,8 @@ golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBc
11671167
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
11681168
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
11691169
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1170-
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
1171-
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
1170+
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
1171+
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
11721172
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
11731173
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
11741174
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=

firecracker-control/cmd/containerd/main.go

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"os"
1919

2020
"github.com/containerd/containerd/cmd/containerd/command"
21+
2122
"github.com/containerd/containerd/pkg/seed"
2223

2324
// Register containerd builtins

firecracker-control/local.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ import (
2525
"time"
2626

2727
"github.com/containerd/containerd/identifiers"
28-
"github.com/containerd/containerd/log"
2928
"github.com/containerd/containerd/namespaces"
3029
"github.com/containerd/containerd/plugin"
3130
"github.com/containerd/containerd/protobuf/types"
3231
"github.com/containerd/containerd/runtime/v2/shim"
3332
"github.com/containerd/containerd/sys"
33+
"github.com/containerd/log"
3434
"github.com/hashicorp/go-multierror"
3535
"github.com/sirupsen/logrus"
3636
"google.golang.org/grpc/codes"

firecracker-control/service.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ import (
1717
"context"
1818
"fmt"
1919

20-
"github.com/containerd/containerd/log"
2120
"github.com/containerd/containerd/plugin"
2221
"github.com/containerd/containerd/protobuf/types"
22+
"github.com/containerd/log"
2323
"github.com/containerd/ttrpc"
2424

2525
"github.com/firecracker-microvm/firecracker-containerd/proto"

go.mod

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
module github.com/firecracker-microvm/firecracker-containerd
22

3-
go 1.21
3+
go 1.23.0
44

55
require (
66
github.com/awslabs/tc-redirect-tap v0.0.0-20211025175357-e30dfca224c2
77
github.com/containerd/containerd v1.7.16
88
github.com/containerd/continuity v0.4.2
99
github.com/containerd/fifo v1.1.0
1010
github.com/containerd/go-runc v1.0.0
11+
github.com/containerd/log v0.1.0
1112
github.com/containerd/ttrpc v1.2.3
1213
github.com/containerd/typeurl/v2 v2.1.1
1314
github.com/containernetworking/cni v1.2.0
@@ -27,7 +28,7 @@ require (
2728
github.com/vishvananda/netlink v1.2.1-beta.2
2829
go.uber.org/goleak v1.1.12
2930
golang.org/x/sync v0.10.0
30-
golang.org/x/sys v0.28.0
31+
golang.org/x/sys v0.31.0
3132
google.golang.org/grpc v1.64.1
3233
google.golang.org/protobuf v1.34.1
3334
)
@@ -50,7 +51,6 @@ require (
5051
github.com/containerd/console v1.0.3 // indirect
5152
github.com/containerd/go-cni v1.1.9 // indirect
5253
github.com/containerd/imgcrypt v1.1.7 // indirect
53-
github.com/containerd/log v0.1.0 // indirect
5454
github.com/containerd/nri v0.6.1 // indirect
5555
github.com/containerd/typeurl v1.0.2 // indirect
5656
github.com/containers/ocicrypt v1.1.6 // indirect

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -1430,8 +1430,8 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
14301430
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
14311431
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
14321432
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1433-
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
1434-
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
1433+
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
1434+
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
14351435
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
14361436
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
14371437
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=

internal/cmd/test-bridged-tap/main.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,12 @@ import (
3838
)
3939

4040
func main() {
41-
skel.PluginMain(add, check, del,
42-
// support CNI versions that support plugin chaining
41+
skel.PluginMainFuncs(
42+
skel.CNIFuncs{
43+
Add: add,
44+
Check: check,
45+
Del: del,
46+
},
4347
version.PluginSupports("0.3.0", "0.3.1", version.Current()),
4448
buildversion.BuildString("test-bridged-tap"),
4549
)
@@ -188,10 +192,10 @@ func getCurrentResult(args *skel.CmdArgs) (*current.Result, error) {
188192
return currentResult, nil
189193
}
190194

191-
func del(args *skel.CmdArgs) error {
195+
func del(_ *skel.CmdArgs) error {
192196
return nil
193197
}
194198

195-
func check(args *skel.CmdArgs) error {
199+
func check(_ *skel.CmdArgs) error {
196200
return nil
197201
}

internal/common_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ func TestIsStubDrive(t *testing.T) {
5656
}
5757

5858
for _, c := range cases {
59-
c := c // see https://github.com/kyoh86/scopelint/issues/4
6059
t.Run(c.name, func(t *testing.T) {
6160
if e, a := c.expected, IsStubDrive(c.r); e != a {
6261
t.Errorf("expected %t, but received %t", e, a)

internal/network_test_utils.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func (l localNetworkServices) Serve(ctx context.Context) error {
127127
errGroup.Go(func() error {
128128
for path, contents := range l.webpages {
129129
webpage := contents
130-
http.HandleFunc("/"+path, func(w http.ResponseWriter, r *http.Request) {
130+
http.HandleFunc("/"+path, func(w http.ResponseWriter, _ *http.Request) {
131131
io.WriteString(w, webpage)
132132
})
133133
}

internal/vm/agent.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func NewNullIOProxy() IOProxy {
4545
return &nullIOProxy{}
4646
}
4747

48-
func (*nullIOProxy) start(proc *vmProc) (ioInitDone <-chan error, ioCopyDone <-chan error) {
48+
func (*nullIOProxy) start(_ *vmProc) (ioInitDone <-chan error, ioCopyDone <-chan error) {
4949
initCh := make(chan error)
5050
close(initCh)
5151

internal/vm/agent_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"testing"
1818

1919
"github.com/containerd/containerd/cio"
20-
"github.com/containerd/containerd/log"
20+
"github.com/containerd/log"
2121
"github.com/stretchr/testify/assert"
2222
)
2323

internal/vm/fifo.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323

2424
// fifoConnector adapts containerd's fifo package to the IOConnector interface
2525
func fifoConnector(path string, flag int) IOConnector {
26-
return func(procCtx context.Context, logger *logrus.Entry) <-chan IOConnectorResult {
26+
return func(procCtx context.Context, _ *logrus.Entry) <-chan IOConnectorResult {
2727
returnCh := make(chan IOConnectorResult, 1)
2828
defer close(returnCh)
2929

internal/vm/ioproxy_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
)
2626

2727
func fileConnector(path string, flag int) IOConnector {
28-
return func(procCtx context.Context, logger *logrus.Entry) <-chan IOConnectorResult {
28+
return func(_ context.Context, _ *logrus.Entry) <-chan IOConnectorResult {
2929
returnCh := make(chan IOConnectorResult, 1)
3030
defer close(returnCh)
3131

0 commit comments

Comments
 (0)