From 2ba70268de565672f164fccf4fb3a6a22b9ecb80 Mon Sep 17 00:00:00 2001 From: Austin Vazquez Date: Thu, 13 Mar 2025 21:08:08 +0000 Subject: [PATCH 1/2] Bump Go min version to Go 1.23 Signed-off-by: Austin Vazquez --- .github/workflows/build.yaml | 2 +- Makefile | 4 ++-- docs/getting-started.md | 2 +- docs/quickstart.md | 10 +++++----- docs/remote-snapshotter-getting-started.md | 2 +- examples/cmd/remote-snapshotter/go.mod | 2 +- go.mod | 2 +- tools/docker/Dockerfile.integ-test | 2 +- tools/docker/Dockerfile.proto-builder | 2 +- tools/docker/Dockerfile.runc-builder | 2 +- tools/docker/Dockerfile.stargz-builder | 2 +- 11 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index f63be6e42..088fed382 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -14,7 +14,7 @@ jobs: strategy: matrix: os: ['ubuntu-20.04', 'ubuntu-22.04'] - go: ['1.21', '1.22'] + go: ['1.23', '1.24'] # Build all variants regardless of failures fail-fast: false diff --git a/Makefile b/Makefile index 7f8470b57..0a8c4b78e 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ SUBMODULES=_submodules UID:=$(shell id -u) GID:=$(shell id -g) -FIRECRACKER_CONTAINERD_BUILDER_IMAGE?=golang:1.21-bullseye +FIRECRACKER_CONTAINERD_BUILDER_IMAGE?=golang:1.23-bullseye export FIRECRACKER_CONTAINERD_TEST_IMAGE?=localhost/firecracker-containerd-test export GO_CACHE_VOLUME_NAME?=gocache @@ -136,7 +136,7 @@ tidy: ./tools/tidy.sh $(BINPATH)/golangci-lint: - GOBIN=$(BINPATH) go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.57.2 + GOBIN=$(BINPATH) go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.2 $(BINPATH)/golangci-lint --version $(BINPATH)/git-validation: diff --git a/docs/getting-started.md b/docs/getting-started.md index 17e765fab..9c3a26082 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -40,7 +40,7 @@ You need to have the following things in order to use firecracker-containerd: * git * gcc, required by the Firecracker agent for building * A recent installation of [Docker CE](https://docker.com). -* Go 1.21 or later, which you can download from [here](https://golang.org/dl/). +* Go 1.23 or later, which you can download from [here](https://golang.org/dl/). ## Setup diff --git a/docs/quickstart.md b/docs/quickstart.md index 5fd839a74..1ec6227d2 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -28,14 +28,14 @@ files into `/usr/local/bin`. cd ~ -# Install git, Go 1.21, make, curl +# Install git, Go 1.23, make, curl sudo mkdir -p /etc/apt/sources.list.d echo "deb http://ftp.debian.org/debian bullseye-backports main" | \ sudo tee /etc/apt/sources.list.d/bullseye-backports.list sudo DEBIAN_FRONTEND=noninteractive apt-get update sudo DEBIAN_FRONTEND=noninteractive apt-get \ install --yes \ - golang-1.21 \ + golang-1.23 \ make \ git \ curl \ @@ -44,8 +44,8 @@ sudo DEBIAN_FRONTEND=noninteractive apt-get \ bc \ gnupg -# Debian's Go 1.21 package installs "go" command under /usr/lib/go-1.21/bin -export PATH=/usr/lib/go-1.21/bin:$PATH +# Debian's Go 1.23 package installs "go" command under /usr/lib/go-1.23/bin +export PATH=/usr/lib/go-1.23/bin:$PATH cd ~ @@ -93,7 +93,7 @@ sudo yum -y install \ # need to source environment variables afterwards for the existing shell session. curl -LO https://get.golang.org/$(uname)/go_installer && \ chmod +x go_installer && \ - ./go_installer -version 1.21 && \ + ./go_installer -version 1.23 && \ rm go_installer && \ source .bash_profile diff --git a/docs/remote-snapshotter-getting-started.md b/docs/remote-snapshotter-getting-started.md index 99b46d62c..82b05cd25 100644 --- a/docs/remote-snapshotter-getting-started.md +++ b/docs/remote-snapshotter-getting-started.md @@ -16,7 +16,7 @@ You will need the following to use firecracker-containerd with support for remot * git -* Go 1.21 or later +* Go 1.23 or later * This repository cloned onto your local machine diff --git a/examples/cmd/remote-snapshotter/go.mod b/examples/cmd/remote-snapshotter/go.mod index e98446620..caf0cacee 100644 --- a/examples/cmd/remote-snapshotter/go.mod +++ b/examples/cmd/remote-snapshotter/go.mod @@ -1,6 +1,6 @@ module github.com/firecracker-microvm/firecracker-containerd/example/remote-snapshotter -go 1.21 +go 1.23.0 require ( github.com/containerd/containerd v1.7.16 diff --git a/go.mod b/go.mod index 33b3671a4..6d8d86e95 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/firecracker-microvm/firecracker-containerd -go 1.21 +go 1.23.0 require ( github.com/awslabs/tc-redirect-tap v0.0.0-20211025175357-e30dfca224c2 diff --git a/tools/docker/Dockerfile.integ-test b/tools/docker/Dockerfile.integ-test index 6f1866acb..bb1f7eca3 100644 --- a/tools/docker/Dockerfile.integ-test +++ b/tools/docker/Dockerfile.integ-test @@ -1,7 +1,7 @@ # syntax=docker/dockerfile:experimental # Test image that starts up containerd and the devmapper snapshotter. The default CMD will drop to a bash shell. Overrides # to CMD will be provided appended to /bin/bash -c -FROM public.ecr.aws/docker/library/golang:1.21-bullseye +FROM public.ecr.aws/docker/library/golang:1.23-bullseye ENV PATH="/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/go/bin" ENV INSTALLROOT="/usr/local" ENV DEBIAN_FRONTEND="noninteractive" diff --git a/tools/docker/Dockerfile.proto-builder b/tools/docker/Dockerfile.proto-builder index cf52f8927..2903930f8 100644 --- a/tools/docker/Dockerfile.proto-builder +++ b/tools/docker/Dockerfile.proto-builder @@ -11,7 +11,7 @@ # express or implied. See the License for the specific language governing # permissions and limitations under the License. -FROM public.ecr.aws/docker/library/golang:1.21-bullseye +FROM public.ecr.aws/docker/library/golang:1.23-bullseye RUN apt-get update && apt-get install --yes --no-install-recommends \ libprotobuf-dev=3.12.4-1+deb11u1 \ diff --git a/tools/docker/Dockerfile.runc-builder b/tools/docker/Dockerfile.runc-builder index 7cdd6bf7d..a559c4992 100644 --- a/tools/docker/Dockerfile.runc-builder +++ b/tools/docker/Dockerfile.runc-builder @@ -11,7 +11,7 @@ # express or implied. See the License for the specific language governing # permissions and limitations under the License. -FROM public.ecr.aws/docker/library/golang:1.21-bullseye +FROM public.ecr.aws/docker/library/golang:1.23-bullseye RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get -y install libseccomp-dev pkg-config diff --git a/tools/docker/Dockerfile.stargz-builder b/tools/docker/Dockerfile.stargz-builder index 5b3e2e9a0..2578afed4 100644 --- a/tools/docker/Dockerfile.stargz-builder +++ b/tools/docker/Dockerfile.stargz-builder @@ -11,4 +11,4 @@ # express or implied. See the License for the specific language governing # permissions and limitations under the License. -FROM public.ecr.aws/docker/library/golang:1.21-bullseye +FROM public.ecr.aws/docker/library/golang:1.23-bullseye From 932f5aeeaf7f54599969fdde1e66ff045538e475 Mon Sep 17 00:00:00 2001 From: Austin Vazquez Date: Fri, 14 Mar 2025 02:14:23 +0000 Subject: [PATCH 2/2] Resolve lint warnings for golangci-lint v1.64.2 Signed-off-by: Austin Vazquez --- .golangci.yml | 20 +++++++++++++--- agent/drive_handler.go | 4 ++-- agent/error_test.go | 1 - agent/ioproxy_handler.go | 2 +- agent/main.go | 2 +- agent/service.go | 2 +- eventbridge/eventbridge.go | 2 +- eventbridge/eventbridge_test.go | 7 +++--- examples/cmd/remote-snapshotter/go.mod | 2 +- examples/cmd/remote-snapshotter/go.sum | 4 ++-- firecracker-control/cmd/containerd/main.go | 1 + firecracker-control/local.go | 2 +- firecracker-control/service.go | 2 +- go.mod | 4 ++-- go.sum | 4 ++-- internal/cmd/test-bridged-tap/main.go | 12 ++++++---- internal/common_test.go | 1 - internal/network_test_utils.go | 2 +- internal/vm/agent.go | 2 +- internal/vm/agent_test.go | 2 +- internal/vm/fifo.go | 2 +- internal/vm/ioproxy_test.go | 2 +- internal/vm/task_test.go | 8 +++---- runtime/benchmark_test.go | 4 ++-- runtime/cpuset/cpuset_builder.go | 12 +++++----- runtime/drive_handler_test.go | 4 ++-- runtime/firecrackeroci/vm.go | 2 +- runtime/helpers.go | 6 ++--- runtime/helpers_test.go | 1 - runtime/main.go | 2 +- runtime/noop_jailer.go | 4 ++-- runtime/runc_jailer.go | 7 +++--- runtime/runc_jailer_test.go | 1 - runtime/service.go | 23 +++++++++---------- runtime/service_integ_test.go | 15 ++++-------- runtime/service_test.go | 2 -- snapshotter/app/service.go | 4 ++-- snapshotter/demux/cache/cache_test.go | 10 ++++---- snapshotter/demux/cache/evict_test.go | 12 +++++----- .../demux/internal/failing_snapshotter.go | 20 ++++++++-------- .../demux/internal/successful_snapshotter.go | 20 ++++++++-------- .../metrics/discovery/service_discovery.go | 2 +- snapshotter/demux/metrics/proxy.go | 2 +- snapshotter/demux/metrics/proxy_test.go | 2 +- .../demux/proxy/address/http_resolver_test.go | 2 +- snapshotter/demux/proxy/snapshotter.go | 3 +-- snapshotter/demux/snapshotter.go | 2 +- snapshotter/demux/snapshotter_test.go | 16 ++++++------- volume/cmd/volume-init/main.go | 4 ++-- volume/cmd/volume-init/main_test.go | 2 +- volume/guest_image.go | 8 +++---- volume/set.go | 4 ++-- volume/set_test.go | 4 ++-- 53 files changed, 147 insertions(+), 143 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 7e95fa8e8..a8b88ab06 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -5,8 +5,8 @@ linters: disable-all: true enable: - govet + - copyloopvar - staticcheck -# - unused - gosimple - ineffassign - typecheck @@ -19,15 +19,29 @@ linters: - gocritic - gofmt - revive - - exportloopref issues: exclude-use-default: false exclude: - G104 # Errors unhandled - G103 # Use of unsafe calls should be audited + - G114 # Use of net/http serve function without timeouts. + - G115 # Integer overflow conversion should be audited - G204 # Subprocess launched with variable + - G301 # Expect directory permissions to be 0750 or less - G304 # Potential file inclusion via variable - G306 # WriteFile permissions 0600 or less to be audited - G307 # Deferring unsafe method "Close" on type "*os.File" to be audited - - + - G404 # Use of weak random number generator + exclude-rules: + - linters: + - govet + text: "copylocks" + - linters: + - revive + text: package-comments + - linters: + - staticcheck + text: "Do not rely on the global seed" + exclude-dirs: + - snapshotter/internal/integtest/stargz # Code copied from upstream stargz diff --git a/agent/drive_handler.go b/agent/drive_handler.go index 5369717a1..65f19b2af 100644 --- a/agent/drive_handler.go +++ b/agent/drive_handler.go @@ -21,9 +21,9 @@ import ( "strings" "time" - "github.com/containerd/containerd/log" "github.com/containerd/containerd/mount" "github.com/containerd/containerd/protobuf/types" + "github.com/containerd/log" "github.com/firecracker-microvm/firecracker-containerd/internal" drivemount "github.com/firecracker-microvm/firecracker-containerd/proto/service/drivemount/ttrpc" ) @@ -214,7 +214,7 @@ func (dh driveHandler) MountDrive(ctx context.Context, req *drivemount.MountDriv return nil, fmt.Errorf("exhausted retries mounting drive from %q to %q", drive.Path(), req.DestinationPath) } -func (dh driveHandler) UnmountDrive(ctx context.Context, req *drivemount.UnmountDriveRequest) (*types.Empty, error) { +func (dh driveHandler) UnmountDrive(_ context.Context, req *drivemount.UnmountDriveRequest) (*types.Empty, error) { drive, ok := dh.GetDrive(req.DriveID) if !ok { return nil, fmt.Errorf("drive %q could not be found", req.DriveID) diff --git a/agent/error_test.go b/agent/error_test.go index 74ab02a30..cafd633fd 100644 --- a/agent/error_test.go +++ b/agent/error_test.go @@ -55,7 +55,6 @@ func TestIsRetryableMountError(t *testing.T) { } for _, c := range cases { - c := c // see https://github.com/kyoh86/scopelint/issues/4 t.Run(c.Name, func(t *testing.T) { assert.Equal(t, c.Expected, isRetryableMountError(c.Error)) }) diff --git a/agent/ioproxy_handler.go b/agent/ioproxy_handler.go index 46891f134..ad1b1f385 100644 --- a/agent/ioproxy_handler.go +++ b/agent/ioproxy_handler.go @@ -17,8 +17,8 @@ import ( "context" task "github.com/containerd/containerd/api/runtime/task/v2" - "github.com/containerd/containerd/log" "github.com/containerd/containerd/protobuf/types" + "github.com/containerd/log" "github.com/firecracker-microvm/firecracker-containerd/internal/vm" ioproxy "github.com/firecracker-microvm/firecracker-containerd/proto/service/ioproxy/ttrpc" ) diff --git a/agent/main.go b/agent/main.go index 6f0e25722..4d5cc3460 100644 --- a/agent/main.go +++ b/agent/main.go @@ -23,9 +23,9 @@ import ( taskAPI "github.com/containerd/containerd/api/runtime/task/v2" "github.com/containerd/containerd/events/exchange" - "github.com/containerd/containerd/log" "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/sys/reaper" + "github.com/containerd/log" "github.com/containerd/ttrpc" "github.com/firecracker-microvm/firecracker-go-sdk/vsock" "github.com/opencontainers/runc/libcontainer/system" diff --git a/agent/service.go b/agent/service.go index aa8b3ad55..aa5e5c72f 100644 --- a/agent/service.go +++ b/agent/service.go @@ -25,11 +25,11 @@ import ( taskAPI "github.com/containerd/containerd/api/runtime/task/v2" "github.com/containerd/containerd/cio" "github.com/containerd/containerd/identifiers" - "github.com/containerd/containerd/log" "github.com/containerd/containerd/mount" "github.com/containerd/containerd/protobuf/types" runc "github.com/containerd/containerd/runtime/v2/runc/v2" "github.com/containerd/containerd/runtime/v2/shim" + "github.com/containerd/log" "github.com/hashicorp/go-multierror" "github.com/sirupsen/logrus" "golang.org/x/sys/unix" diff --git a/eventbridge/eventbridge.go b/eventbridge/eventbridge.go index 136d015ba..1b794f104 100644 --- a/eventbridge/eventbridge.go +++ b/eventbridge/eventbridge.go @@ -89,7 +89,7 @@ func (s *getterService) GetEvent(ctx context.Context) (*eventapi.Envelope, error // RegisterGetterService adds the Getter service as a method to the provided TTRPC server. func RegisterGetterService(srv *ttrpc.Server, svc Getter) { srv.Register(getterServiceName, map[string]ttrpc.Method{ - getEventMethodName: func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) { + getEventMethodName: func(ctx context.Context, _ func(any) error) (any, error) { return svc.GetEvent(ctx) }, }) diff --git a/eventbridge/eventbridge_test.go b/eventbridge/eventbridge_test.go index 9efa01ed3..b7f6dadc5 100644 --- a/eventbridge/eventbridge_test.go +++ b/eventbridge/eventbridge_test.go @@ -79,12 +79,13 @@ func verifyPublishAndReceive(ctx context.Context, t *testing.T, source eventtype topic := "/just/container/things" sinkEventCh, sinkErrorCh := sink.Subscribe(ctx, fmt.Sprintf(`topic=="%s"`, topic)) - for i := 0; i < 100; i++ { + const taskLimit uint32 = 100 + for i := range taskLimit { taskExitEvent := &events.TaskExit{ ContainerID: fmt.Sprintf("container-%d", i), ID: fmt.Sprintf("id-%d", i), - Pid: uint32(i), - ExitStatus: uint32(i + 1), + Pid: i, + ExitStatus: i + 1, ExitedAt: protobuf.ToTimestamp(time.Now().UTC()), } diff --git a/examples/cmd/remote-snapshotter/go.mod b/examples/cmd/remote-snapshotter/go.mod index caf0cacee..78bcf86a5 100644 --- a/examples/cmd/remote-snapshotter/go.mod +++ b/examples/cmd/remote-snapshotter/go.mod @@ -48,7 +48,7 @@ require ( golang.org/x/mod v0.18.0 // indirect golang.org/x/net v0.33.0 // indirect golang.org/x/sync v0.10.0 // indirect - golang.org/x/sys v0.28.0 // indirect + golang.org/x/sys v0.31.0 // indirect golang.org/x/text v0.21.0 // indirect golang.org/x/tools v0.22.0 // indirect google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80 // indirect diff --git a/examples/cmd/remote-snapshotter/go.sum b/examples/cmd/remote-snapshotter/go.sum index 1c1950c42..3db86f5ba 100644 --- a/examples/cmd/remote-snapshotter/go.sum +++ b/examples/cmd/remote-snapshotter/go.sum @@ -1167,8 +1167,8 @@ golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= -golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= +golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= diff --git a/firecracker-control/cmd/containerd/main.go b/firecracker-control/cmd/containerd/main.go index 34b1a7159..16ce55da0 100644 --- a/firecracker-control/cmd/containerd/main.go +++ b/firecracker-control/cmd/containerd/main.go @@ -18,6 +18,7 @@ import ( "os" "github.com/containerd/containerd/cmd/containerd/command" + "github.com/containerd/containerd/pkg/seed" // Register containerd builtins diff --git a/firecracker-control/local.go b/firecracker-control/local.go index f7b53e47c..a02cbd4a9 100644 --- a/firecracker-control/local.go +++ b/firecracker-control/local.go @@ -25,12 +25,12 @@ import ( "time" "github.com/containerd/containerd/identifiers" - "github.com/containerd/containerd/log" "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/plugin" "github.com/containerd/containerd/protobuf/types" "github.com/containerd/containerd/runtime/v2/shim" "github.com/containerd/containerd/sys" + "github.com/containerd/log" "github.com/hashicorp/go-multierror" "github.com/sirupsen/logrus" "google.golang.org/grpc/codes" diff --git a/firecracker-control/service.go b/firecracker-control/service.go index b4f97874e..fa57e250b 100644 --- a/firecracker-control/service.go +++ b/firecracker-control/service.go @@ -17,9 +17,9 @@ import ( "context" "fmt" - "github.com/containerd/containerd/log" "github.com/containerd/containerd/plugin" "github.com/containerd/containerd/protobuf/types" + "github.com/containerd/log" "github.com/containerd/ttrpc" "github.com/firecracker-microvm/firecracker-containerd/proto" diff --git a/go.mod b/go.mod index 6d8d86e95..c00fc1258 100644 --- a/go.mod +++ b/go.mod @@ -8,6 +8,7 @@ require ( github.com/containerd/continuity v0.4.2 github.com/containerd/fifo v1.1.0 github.com/containerd/go-runc v1.0.0 + github.com/containerd/log v0.1.0 github.com/containerd/ttrpc v1.2.3 github.com/containerd/typeurl/v2 v2.1.1 github.com/containernetworking/cni v1.2.0 @@ -27,7 +28,7 @@ require ( github.com/vishvananda/netlink v1.2.1-beta.2 go.uber.org/goleak v1.1.12 golang.org/x/sync v0.10.0 - golang.org/x/sys v0.28.0 + golang.org/x/sys v0.31.0 google.golang.org/grpc v1.64.1 google.golang.org/protobuf v1.34.1 ) @@ -50,7 +51,6 @@ require ( github.com/containerd/console v1.0.3 // indirect github.com/containerd/go-cni v1.1.9 // indirect github.com/containerd/imgcrypt v1.1.7 // indirect - github.com/containerd/log v0.1.0 // indirect github.com/containerd/nri v0.6.1 // indirect github.com/containerd/typeurl v1.0.2 // indirect github.com/containers/ocicrypt v1.1.6 // indirect diff --git a/go.sum b/go.sum index 8490ddb1f..ca271146c 100644 --- a/go.sum +++ b/go.sum @@ -1430,8 +1430,8 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= -golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= +golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= diff --git a/internal/cmd/test-bridged-tap/main.go b/internal/cmd/test-bridged-tap/main.go index 8da95d0e2..0080c84b4 100644 --- a/internal/cmd/test-bridged-tap/main.go +++ b/internal/cmd/test-bridged-tap/main.go @@ -38,8 +38,12 @@ import ( ) func main() { - skel.PluginMain(add, check, del, - // support CNI versions that support plugin chaining + skel.PluginMainFuncs( + skel.CNIFuncs{ + Add: add, + Check: check, + Del: del, + }, version.PluginSupports("0.3.0", "0.3.1", version.Current()), buildversion.BuildString("test-bridged-tap"), ) @@ -188,10 +192,10 @@ func getCurrentResult(args *skel.CmdArgs) (*current.Result, error) { return currentResult, nil } -func del(args *skel.CmdArgs) error { +func del(_ *skel.CmdArgs) error { return nil } -func check(args *skel.CmdArgs) error { +func check(_ *skel.CmdArgs) error { return nil } diff --git a/internal/common_test.go b/internal/common_test.go index d91bc424a..14be1d744 100644 --- a/internal/common_test.go +++ b/internal/common_test.go @@ -56,7 +56,6 @@ func TestIsStubDrive(t *testing.T) { } for _, c := range cases { - c := c // see https://github.com/kyoh86/scopelint/issues/4 t.Run(c.name, func(t *testing.T) { if e, a := c.expected, IsStubDrive(c.r); e != a { t.Errorf("expected %t, but received %t", e, a) diff --git a/internal/network_test_utils.go b/internal/network_test_utils.go index ebdeb9538..200e24384 100644 --- a/internal/network_test_utils.go +++ b/internal/network_test_utils.go @@ -127,7 +127,7 @@ func (l localNetworkServices) Serve(ctx context.Context) error { errGroup.Go(func() error { for path, contents := range l.webpages { webpage := contents - http.HandleFunc("/"+path, func(w http.ResponseWriter, r *http.Request) { + http.HandleFunc("/"+path, func(w http.ResponseWriter, _ *http.Request) { io.WriteString(w, webpage) }) } diff --git a/internal/vm/agent.go b/internal/vm/agent.go index a4db4dcf3..8c9ab8b03 100644 --- a/internal/vm/agent.go +++ b/internal/vm/agent.go @@ -45,7 +45,7 @@ func NewNullIOProxy() IOProxy { return &nullIOProxy{} } -func (*nullIOProxy) start(proc *vmProc) (ioInitDone <-chan error, ioCopyDone <-chan error) { +func (*nullIOProxy) start(_ *vmProc) (ioInitDone <-chan error, ioCopyDone <-chan error) { initCh := make(chan error) close(initCh) diff --git a/internal/vm/agent_test.go b/internal/vm/agent_test.go index e67240394..77ef8c571 100644 --- a/internal/vm/agent_test.go +++ b/internal/vm/agent_test.go @@ -17,7 +17,7 @@ import ( "testing" "github.com/containerd/containerd/cio" - "github.com/containerd/containerd/log" + "github.com/containerd/log" "github.com/stretchr/testify/assert" ) diff --git a/internal/vm/fifo.go b/internal/vm/fifo.go index 6cf25d97d..5078a02f1 100644 --- a/internal/vm/fifo.go +++ b/internal/vm/fifo.go @@ -23,7 +23,7 @@ import ( // fifoConnector adapts containerd's fifo package to the IOConnector interface func fifoConnector(path string, flag int) IOConnector { - return func(procCtx context.Context, logger *logrus.Entry) <-chan IOConnectorResult { + return func(procCtx context.Context, _ *logrus.Entry) <-chan IOConnectorResult { returnCh := make(chan IOConnectorResult, 1) defer close(returnCh) diff --git a/internal/vm/ioproxy_test.go b/internal/vm/ioproxy_test.go index f5dbfa321..b7c7187a5 100644 --- a/internal/vm/ioproxy_test.go +++ b/internal/vm/ioproxy_test.go @@ -25,7 +25,7 @@ import ( ) func fileConnector(path string, flag int) IOConnector { - return func(procCtx context.Context, logger *logrus.Entry) <-chan IOConnectorResult { + return func(_ context.Context, _ *logrus.Entry) <-chan IOConnectorResult { returnCh := make(chan IOConnectorResult, 1) defer close(returnCh) diff --git a/internal/vm/task_test.go b/internal/vm/task_test.go index 07f23b92b..689c6266d 100644 --- a/internal/vm/task_test.go +++ b/internal/vm/task_test.go @@ -50,7 +50,7 @@ type mockTaskService struct { waitCh sync.Map } -func (s *mockTaskService) Create(reqCtx context.Context, req *taskAPI.CreateTaskRequest) (*taskAPI.CreateTaskResponse, error) { +func (s *mockTaskService) Create(_ context.Context, req *taskAPI.CreateTaskRequest) (*taskAPI.CreateTaskResponse, error) { reqCh, _ := s.createRequests.LoadOrStore(req.ID, make(chan *taskAPI.CreateTaskRequest, 128)) reqCh.(chan *taskAPI.CreateTaskRequest) <- req return &taskAPI.CreateTaskResponse{ @@ -74,7 +74,7 @@ func (s *mockTaskService) PopCreateRequests(id string) (reqs []*taskAPI.CreateTa } } -func (s *mockTaskService) Exec(reqCtx context.Context, req *taskAPI.ExecProcessRequest) (*types.Empty, error) { +func (s *mockTaskService) Exec(_ context.Context, req *taskAPI.ExecProcessRequest) (*types.Empty, error) { reqCh, _ := s.execRequests.LoadOrStore(req.ID, make(chan *taskAPI.ExecProcessRequest, 128)) reqCh.(chan *taskAPI.ExecProcessRequest) <- req return nil, nil @@ -96,7 +96,7 @@ func (s *mockTaskService) PopExecRequests(id string) (reqs []*taskAPI.ExecProces } } -func (s *mockTaskService) Delete(reqCtx context.Context, req *taskAPI.DeleteRequest) (*taskAPI.DeleteResponse, error) { +func (s *mockTaskService) Delete(_ context.Context, req *taskAPI.DeleteRequest) (*taskAPI.DeleteResponse, error) { reqCh, _ := s.deleteRequests.LoadOrStore(req.ID, make(chan *taskAPI.DeleteRequest, 128)) reqCh.(chan *taskAPI.DeleteRequest) <- req return nil, nil @@ -122,7 +122,7 @@ func (s *mockTaskService) processID(taskID, execID string) string { return taskID + "/" + execID } -func (s *mockTaskService) Wait(reqCtx context.Context, req *taskAPI.WaitRequest) (*taskAPI.WaitResponse, error) { +func (s *mockTaskService) Wait(_ context.Context, req *taskAPI.WaitRequest) (*taskAPI.WaitResponse, error) { reqCh, _ := s.waitRequests.LoadOrStore(req.ID, make(chan *taskAPI.WaitRequest, 128)) reqCh.(chan *taskAPI.WaitRequest) <- req diff --git a/runtime/benchmark_test.go b/runtime/benchmark_test.go index e37954804..c346eac9e 100644 --- a/runtime/benchmark_test.go +++ b/runtime/benchmark_test.go @@ -73,8 +73,8 @@ func benchmarkCreateAndStopVM(t *testing.T, vcpuCount uint32, kernelArgs string) }, } - var samples []time.Duration - for i := 0; i < benchmarkCount; i++ { + samples := make([]time.Duration, benchmarkCount) + for range benchmarkCount { ctx, cancel := context.WithTimeout(ctx, 5*time.Second) defer cancel() diff --git a/runtime/cpuset/cpuset_builder.go b/runtime/cpuset/cpuset_builder.go index 2a0d1dae6..23f1421f9 100644 --- a/runtime/cpuset/cpuset_builder.go +++ b/runtime/cpuset/cpuset_builder.go @@ -94,10 +94,10 @@ func (b Builder) AddCPU(cpu int) Builder { // AddCPURange adds a range of physical CPU numbers that the process is allowed // to run on -func (b Builder) AddCPURange(min, max int) Builder { +func (b Builder) AddCPURange(minimum, maximum int) Builder { b.cpuRanges = append(b.cpuRanges, _range{ - min: min, - max: max, + min: minimum, + max: maximum, }) return b @@ -110,10 +110,10 @@ func (b Builder) AddMem(mem int) Builder { } // AddMemRange adds a range of memory nodes to be used. -func (b Builder) AddMemRange(min, max int) Builder { +func (b Builder) AddMemRange(minimum, maximum int) Builder { b.memRanges = append(b.memRanges, _range{ - min: min, - max: max, + min: minimum, + max: maximum, }) return b diff --git a/runtime/drive_handler_test.go b/runtime/drive_handler_test.go index e45478420..01dbdbfe7 100644 --- a/runtime/drive_handler_test.go +++ b/runtime/drive_handler_test.go @@ -20,8 +20,8 @@ import ( "strconv" "testing" - "github.com/containerd/containerd/log" "github.com/containerd/containerd/protobuf/types" + "github.com/containerd/log" "github.com/firecracker-microvm/firecracker-containerd/internal/vm" "github.com/firecracker-microvm/firecracker-containerd/proto" drivemount "github.com/firecracker-microvm/firecracker-containerd/proto/service/drivemount/ttrpc" @@ -41,7 +41,7 @@ type MockDriveMounter struct { expectedOptions []string } -func (m *MockDriveMounter) MountDrive(ctx context.Context, req *drivemount.MountDriveRequest) (*types.Empty, error) { +func (m *MockDriveMounter) MountDrive(_ context.Context, req *drivemount.MountDriveRequest) (*types.Empty, error) { assert.Equal(m.t, m.expectedDestinationPath, req.DestinationPath) assert.Equal(m.t, m.expectedFilesystemType, req.FilesytemType) assert.Equal(m.t, m.expectedOptions, req.Options) diff --git a/runtime/firecrackeroci/vm.go b/runtime/firecrackeroci/vm.go index 79d10f296..bed4a5c87 100644 --- a/runtime/firecrackeroci/vm.go +++ b/runtime/firecrackeroci/vm.go @@ -105,7 +105,7 @@ func WithVMLocalImageConfig(image containerd.Image) oci.SpecOpts { // username -> uid or group name -> gid. It passes the user to the // agent running inside the VM to do that mapping. func WithVMLocalUser(user string) oci.SpecOpts { - return func(ctx context.Context, client oci.Client, container *containers.Container, spec *oci.Spec) error { + return func(_ context.Context, _ oci.Client, _ *containers.Container, spec *oci.Spec) error { // This is technically an LCOW specific field, but we piggy back // to get the string user into the VM where will will do the uid/gid mapping spec.Process.User.Username = user diff --git a/runtime/helpers.go b/runtime/helpers.go index e4f1977f7..df679bd13 100644 --- a/runtime/helpers.go +++ b/runtime/helpers.go @@ -61,7 +61,7 @@ func machineConfigurationFromProto(cfg *config.Config, req *proto.FirecrackerMac // networkConfigFromProto creates a firecracker NetworkInterface object from // the protobuf FirecrackerNetworkInterface message. -func networkConfigFromProto(nwIface *proto.FirecrackerNetworkInterface, vmID string) (*firecracker.NetworkInterface, error) { +func networkConfigFromProto(nwIface *proto.FirecrackerNetworkInterface, _ string) (*firecracker.NetworkInterface, error) { result := &firecracker.NetworkInterface{ AllowMMDS: nwIface.AllowMMDS, } @@ -138,7 +138,7 @@ func rateLimiterFromProto(rl *proto.FirecrackerRateLimiter) *models.RateLimiter func withRateLimiterFromProto(rl *proto.FirecrackerRateLimiter) firecracker.DriveOpt { if rl == nil { - return func(d *models.Drive) { + return func(_ *models.Drive) { // no-op } } @@ -178,7 +178,7 @@ func withCacheTypeFromProto(cacheType string) firecracker.DriveOpt { // protobuf 'string' type default to empty string if the encoded message // does not contain a value for that field. if cacheType == "" { - return func(d *models.Drive) { + return func(_ *models.Drive) { // no-op } } diff --git a/runtime/helpers_test.go b/runtime/helpers_test.go index cdcaeacda..affd72ec2 100644 --- a/runtime/helpers_test.go +++ b/runtime/helpers_test.go @@ -102,7 +102,6 @@ func TestMachineConfigurationFromProto(t *testing.T) { } for _, tc := range testcases { - tc := tc // see https://github.com/kyoh86/scopelint/issues/4 t.Run(tc.name, func(t *testing.T) { machineConfig := machineConfigurationFromProto(tc.config, tc.proto) assert.Equal(t, tc.expectedMachineConfig, machineConfig) diff --git a/runtime/main.go b/runtime/main.go index 9c80bb2a1..442fef1e0 100644 --- a/runtime/main.go +++ b/runtime/main.go @@ -16,8 +16,8 @@ package main import ( "os" - "github.com/containerd/containerd/log" "github.com/containerd/containerd/runtime/v2/shim" + "github.com/containerd/log" "github.com/sirupsen/logrus" ) diff --git a/runtime/noop_jailer.go b/runtime/noop_jailer.go index 3076768c8..8e8a74d89 100644 --- a/runtime/noop_jailer.go +++ b/runtime/noop_jailer.go @@ -67,7 +67,7 @@ func (j *noopJailer) BuildJailedMachine(cfg *config.Config, _ *firecracker.Confi pidHandler := firecracker.Handler{ Name: "firecracker-containerd-jail-pid-handler", - Fn: func(ctx context.Context, m *firecracker.Machine) error { + Fn: func(_ context.Context, m *firecracker.Machine) error { pid, err := m.PID() if err != nil { return err @@ -91,7 +91,7 @@ func (j *noopJailer) JailPath() vm.Dir { return j.shimDir } -func (j *noopJailer) ExposeFileToJail(path string) error { +func (j *noopJailer) ExposeFileToJail(_ string) error { j.logger.Debug("noop operation for ExposeFileToJail") return nil } diff --git a/runtime/runc_jailer.go b/runtime/runc_jailer.go index 410572ea4..0d3a3b369 100644 --- a/runtime/runc_jailer.go +++ b/runtime/runc_jailer.go @@ -213,15 +213,14 @@ func (j *runcJailer) BuildJailedMachine(cfg *config.Config, machineConfig *firec // BuildJailedRootHandler will populate the jail with the necessary files, which may be // device nodes, hard links, and/or bind-mount targets -func (j *runcJailer) BuildJailedRootHandler(cfg *config.Config, machineConfig *firecracker.Config, vmID string) firecracker.Handler { +func (j *runcJailer) BuildJailedRootHandler(cfg *config.Config, machineConfig *firecracker.Config, _ string) firecracker.Handler { ociBundlePath := j.OCIBundlePath() rootPath := j.RootPath() machineConfig.SocketPath = filepath.Join(rootfsFolder, "api.socket") return firecracker.Handler{ Name: jailerHandlerName, - Fn: func(ctx context.Context, m *firecracker.Machine) error { - + Fn: func(_ context.Context, m *firecracker.Machine) error { rootPathToConfig := filepath.Join(ociBundlePath, "config.json") j.logger.WithField("rootPathToConfig", rootPathToConfig).Debug("Copying config") if err := copyFile(j.Config.RuncConfigPath, rootPathToConfig, 0400); err != nil { @@ -332,7 +331,7 @@ func (j *runcJailer) makeLinkInJail(src, base string) (string, error) { func (j *runcJailer) BuildLinkFifoHandler() firecracker.Handler { return firecracker.Handler{ Name: jailerFifoHandlerName, - Fn: func(ctx context.Context, m *firecracker.Machine) error { + Fn: func(_ context.Context, m *firecracker.Machine) error { logFifo, err := j.makeLinkInJail(m.Cfg.LogPath, internal.FirecrackerLogFifoName) if err != nil { return err diff --git a/runtime/runc_jailer_test.go b/runtime/runc_jailer_test.go index 5b2b24d0f..b910e05d6 100644 --- a/runtime/runc_jailer_test.go +++ b/runtime/runc_jailer_test.go @@ -190,7 +190,6 @@ func TestFifoHandler(t *testing.T) { } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { dir := t.TempDir() diff --git a/runtime/service.go b/runtime/service.go index 4f394e3fb..979e04bac 100644 --- a/runtime/service.go +++ b/runtime/service.go @@ -37,13 +37,13 @@ import ( "github.com/containerd/containerd/api/types/task" "github.com/containerd/containerd/cio" "github.com/containerd/containerd/events/exchange" - "github.com/containerd/containerd/log" "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/pkg/ttrpcutil" "github.com/containerd/containerd/protobuf" "github.com/containerd/containerd/protobuf/types" "github.com/containerd/containerd/runtime/v2/shim" "github.com/containerd/fifo" + "github.com/containerd/log" "github.com/containerd/ttrpc" "github.com/firecracker-microvm/firecracker-go-sdk" "github.com/firecracker-microvm/firecracker-go-sdk/client/models" @@ -67,7 +67,7 @@ import ( ) func init() { - rand.Seed(time.Now().UnixNano()) + rand.New(rand.NewSource(time.Now().UnixNano())) } const ( @@ -169,7 +169,7 @@ func shimOpts(shimCtx context.Context) (*shim.Opts, error) { } // NewService creates new runtime shim. -func NewService(shimCtx context.Context, id string, remotePublisher shim.Publisher, shimCancel func()) (shim.Shim, error) { +func NewService(shimCtx context.Context, _ string, remotePublisher shim.Publisher, shimCancel func()) (shim.Shim, error) { cfg, err := config.LoadConfig("") if err != nil { return nil, err @@ -658,7 +658,7 @@ func (s *service) StopVM(requestCtx context.Context, request *proto.StopVMReques } // ResumeVM resumes a VM -func (s *service) ResumeVM(ctx context.Context, req *proto.ResumeVMRequest) (*types.Empty, error) { +func (s *service) ResumeVM(ctx context.Context, _ *proto.ResumeVMRequest) (*types.Empty, error) { defer logPanicAndDie(s.logger) err := s.waitVMReady() @@ -676,7 +676,7 @@ func (s *service) ResumeVM(ctx context.Context, req *proto.ResumeVMRequest) (*ty } // PauseVM pauses a VM -func (s *service) PauseVM(ctx context.Context, req *proto.PauseVMRequest) (*types.Empty, error) { +func (s *service) PauseVM(ctx context.Context, _ *proto.PauseVMRequest) (*types.Empty, error) { defer logPanicAndDie(s.logger) err := s.waitVMReady() @@ -695,7 +695,7 @@ func (s *service) PauseVM(ctx context.Context, req *proto.PauseVMRequest) (*type // GetVMInfo returns metadata for the VM being managed by this shim. If the VM has not been created yet, this // method will wait for up to a hardcoded timeout for it to exist, returning an error if the timeout is reached. -func (s *service) GetVMInfo(requestCtx context.Context, request *proto.GetVMInfoRequest) (*proto.GetVMInfoResponse, error) { +func (s *service) GetVMInfo(_ context.Context, _ *proto.GetVMInfoRequest) (*proto.GetVMInfoResponse, error) { defer logPanicAndDie(s.logger) err := s.waitVMReady() @@ -768,8 +768,7 @@ func (s *service) UpdateVMMetadata(requestCtx context.Context, request *proto.Up // GetVMMetadata returns the metadata for the vm managed by this shim.. // If the vm has not been created yet, this method will wait for up to the hardcoded timeout for it // to exist, returning an error if the timeout is reached. -func (s *service) GetVMMetadata(requestCtx context.Context, request *proto.GetVMMetadataRequest) (*proto.GetVMMetadataResponse, error) { - +func (s *service) GetVMMetadata(requestCtx context.Context, _ *proto.GetVMMetadataRequest) (*proto.GetVMMetadataResponse, error) { defer logPanicAndDie(s.logger) err := s.waitVMReady() @@ -789,7 +788,7 @@ func (s *service) GetVMMetadata(requestCtx context.Context, request *proto.GetVM return &proto.GetVMMetadataResponse{Metadata: string(metadata)}, nil } -func (s *service) createBalloon(requestCtx context.Context, request *proto.CreateVMRequest) (models.Balloon, error) { +func (s *service) createBalloon(_ context.Context, request *proto.CreateVMRequest) (models.Balloon, error) { amountMiB := request.BalloonDevice.AmountMib deflateOnOom := request.BalloonDevice.DeflateOnOom statsPollingIntervals := request.BalloonDevice.StatsPollingIntervals @@ -814,7 +813,7 @@ func (s *service) buildBalloonDeviceOpt(balloon models.Balloon) ([]firecracker.O } // GetBalloonConfig will get configuration for an existing balloon device, before or after machine startup -func (s *service) GetBalloonConfig(requestCtx context.Context, req *proto.GetBalloonConfigRequest) (*proto.GetBalloonConfigResponse, error) { +func (s *service) GetBalloonConfig(requestCtx context.Context, _ *proto.GetBalloonConfigRequest) (*proto.GetBalloonConfigResponse, error) { defer logPanicAndDie(s.logger) err := s.waitVMReady() @@ -857,7 +856,7 @@ func (s *service) UpdateBalloon(requestCtx context.Context, req *proto.UpdateBal } // GetBalloonStats will return the latest balloon device statistics, only if enabled pre-boot. -func (s *service) GetBalloonStats(requestCtx context.Context, req *proto.GetBalloonStatsRequest) (*proto.GetBalloonStatsResponse, error) { +func (s *service) GetBalloonStats(requestCtx context.Context, _ *proto.GetBalloonStatsRequest) (*proto.GetBalloonStatsResponse, error) { defer logPanicAndDie(s.logger) err := s.waitVMReady() @@ -1624,7 +1623,7 @@ func (s *service) isPaused(ctx context.Context) (bool, error) { return *info.State == models.InstanceInfoStatePaused, nil } -func (s *service) forceTerminate(ctx context.Context) error { +func (s *service) forceTerminate(_ context.Context) error { s.logger.Errorf("forcefully terminate VM %s", s.vmID) err := s.jailer.Stop(true) diff --git a/runtime/service_integ_test.go b/runtime/service_integ_test.go index 122d9c9a9..5898012b8 100644 --- a/runtime/service_integ_test.go +++ b/runtime/service_integ_test.go @@ -362,7 +362,6 @@ func testMultipleVMs(ctx context.Context, t *testing.T, count int) { for i, device := range devices { caseTypeNumber := i % len(cases) vmID := i - device := device c := cases[caseTypeNumber] f := func(ctx context.Context) error { @@ -421,7 +420,6 @@ func testMultipleVMs(ctx context.Context, t *testing.T, count int) { containerEg, containerCtx := errgroup.WithContext(vmEgCtx) for containerID := 0; containerID < int(containerCount); containerID++ { - containerID := containerID containerEg.Go(func() error { return testMultipleExecs( containerCtx, @@ -580,7 +578,6 @@ func testMultipleExecs( execStdouts := make(chan string, len(execIDs)) var eg, _ = errgroup.WithContext(ctx) for _, execID := range execIDs { - execID := execID eg.Go(func() error { ns, err := getMountNamespace(ctx, client, containerName, newTask, execID) if err != nil { @@ -671,7 +668,7 @@ func testMultipleExecs( return nil } -func getMountNamespace(ctx context.Context, client *containerd.Client, containerName string, newTask containerd.Task, execID string) (string, error) { +func getMountNamespace(ctx context.Context, _ *containerd.Client, _ string, newTask containerd.Task, execID string) (string, error) { var execStdout bytes.Buffer var execStderr bytes.Buffer @@ -1821,8 +1818,6 @@ func TestStopVM_Isolated(t *testing.T) { require.NoError(t, err) for _, test := range tests { - test := test - testFunc := func(tb testing.TB, createVMRequest proto.CreateVMRequest) { ctx, cancel := context.WithTimeout(ctx, 60*time.Second) defer cancel() @@ -2352,8 +2347,7 @@ func TestCreateVM_Isolated(t *testing.T) { } } - for _, _s := range subtests { - s := _s + for _, s := range subtests { request := s.request t.Run(s.name, func(t *testing.T) { runTest(t, request, s) @@ -2525,7 +2519,7 @@ func TestAttach_Isolated(t *testing.T) { name: "null io", // firecracker-containerd doesn't create IO Proxy objects in this case. - newIO: func(ctx context.Context, id string) (cio.IO, error) { + newIO: func(_ context.Context, id string) (cio.IO, error) { return cio.NullIO(id) }, @@ -2536,7 +2530,6 @@ func TestAttach_Isolated(t *testing.T) { } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { name := testNameToVMID(t.Name()) @@ -2551,7 +2544,7 @@ func TestAttach_Isolated(t *testing.T) { io, err := tc.newIO(ctx, name) require.NoError(t, err) - t1, err := c.NewTask(ctx, func(id string) (cio.IO, error) { + t1, err := c.NewTask(ctx, func(_ string) (cio.IO, error) { return io, nil }) require.NoError(t, err) diff --git a/runtime/service_test.go b/runtime/service_test.go index 756c10a2a..950e6aa8d 100644 --- a/runtime/service_test.go +++ b/runtime/service_test.go @@ -233,7 +233,6 @@ func TestBuildVMConfiguration(t *testing.T) { if cpuTemp, err := internal.SupportCPUTemplate(); !cpuTemp && err == nil { tc.expectedCfg.MachineCfg.CPUTemplate = "" } - tc := tc // see https://github.com/kyoh86/scopelint/issues/4 t.Run(tc.name, func(t *testing.T) { svc := &service{ namespace: namespace, @@ -312,7 +311,6 @@ func TestDebugConfig(t *testing.T) { path := t.TempDir() for i, c := range cases { - c := c stubDrivePath := filepath.Join(path, fmt.Sprintf("%d", i)) err := os.MkdirAll(stubDrivePath, os.ModePerm) assert.NoError(t, err, "failed to create stub drive path") diff --git a/snapshotter/app/service.go b/snapshotter/app/service.go index 101b2d2fe..c76f58275 100644 --- a/snapshotter/app/service.go +++ b/snapshotter/app/service.go @@ -26,7 +26,7 @@ import ( snapshotsapi "github.com/containerd/containerd/api/services/snapshots/v1" "github.com/containerd/containerd/contrib/snapshotservice" - "github.com/containerd/containerd/log" + "github.com/containerd/log" "github.com/firecracker-microvm/firecracker-go-sdk/vsock" "golang.org/x/sync/errgroup" "google.golang.org/grpc" @@ -201,7 +201,7 @@ func initCache(config config.Config, monitor *metrics.Monitor) (*cache.RemoteSna return nil, err } - dial := func(ctx context.Context, namespace string) (net.Conn, error) { + dial := func(ctx context.Context, _ string) (net.Conn, error) { return vsockDial(ctx, host, port) } diff --git a/snapshotter/demux/cache/cache_test.go b/snapshotter/demux/cache/cache_test.go index abf10b010..a0a9a2745 100644 --- a/snapshotter/demux/cache/cache_test.go +++ b/snapshotter/demux/cache/cache_test.go @@ -26,15 +26,15 @@ import ( "github.com/firecracker-microvm/firecracker-containerd/snapshotter/demux/proxy" ) -func getSnapshotterOkFunction(ctx context.Context, key string) (*proxy.RemoteSnapshotter, error) { +func getSnapshotterOkFunction(_ context.Context, _ string) (*proxy.RemoteSnapshotter, error) { return &proxy.RemoteSnapshotter{Snapshotter: &internal.SuccessfulSnapshotter{}}, nil } -func getSnapshotterErrorFunction(ctx context.Context, key string) (*proxy.RemoteSnapshotter, error) { +func getSnapshotterErrorFunction(_ context.Context, _ string) (*proxy.RemoteSnapshotter, error) { return nil, errors.New("Mock retrieve snapshotter error") } -func getFailingSnapshotterOkFunction(ctx context.Context, key string) (*proxy.RemoteSnapshotter, error) { +func getFailingSnapshotterOkFunction(_ context.Context, _ string) (*proxy.RemoteSnapshotter, error) { return &proxy.RemoteSnapshotter{Snapshotter: &internal.FailingSnapshotter{}}, nil } @@ -67,7 +67,7 @@ func getSnapshotterPropagatesErrors() error { return nil } -func successfulWalk(ctx context.Context, info snapshots.Info) error { +func successfulWalk(_ context.Context, _ snapshots.Info) error { return nil } @@ -101,7 +101,7 @@ func applyWalkFunctionPropagatesErrors() error { // The failing snapshotter mock will fail all Walk calls before applying // the snapshots.WalkFunc, but for the purposes of this test that is fine. // In which case, any function will do. - walkFunc := func(ctx context.Context, info snapshots.Info) error { + walkFunc := func(_ context.Context, _ snapshots.Info) error { return nil } if err := uut.WalkAll(context.Background(), walkFunc); err == nil { diff --git a/snapshotter/demux/cache/evict_test.go b/snapshotter/demux/cache/evict_test.go index 8145991ab..29fab7b89 100644 --- a/snapshotter/demux/cache/evict_test.go +++ b/snapshotter/demux/cache/evict_test.go @@ -26,11 +26,11 @@ import ( "go.uber.org/goleak" ) -func getSnapshotter(ctx context.Context, key string) (*proxy.RemoteSnapshotter, error) { +func getSnapshotter(_ context.Context, _ string) (*proxy.RemoteSnapshotter, error) { return &proxy.RemoteSnapshotter{Snapshotter: &internal.SuccessfulSnapshotter{}}, nil } -func getErrorSnapshotter(ctx context.Context, key string) (*proxy.RemoteSnapshotter, error) { +func getErrorSnapshotter(_ context.Context, _ string) (*proxy.RemoteSnapshotter, error) { return &proxy.RemoteSnapshotter{Snapshotter: &internal.FailingSnapshotter{}}, nil } @@ -43,7 +43,7 @@ func (c *RemoteSnapshotterCache) length() int { func TestCacheEvictionOnConnectionFailure(t *testing.T) { defer goleak.VerifyNone(t) - dial := func(ctx context.Context, namespace string) (net.Conn, error) { + dial := func(_ context.Context, _ string) (net.Conn, error) { // Error on dial to simulate unhealthy connection return nil, errors.New("mock dial error") } @@ -79,7 +79,7 @@ func TestCacheEvictionOnConnectionFailure(t *testing.T) { func TestCacheNotEvictedIfConnectionIsHealthy(t *testing.T) { defer goleak.VerifyNone(t) - dial := func(ctx context.Context, namespace string) (net.Conn, error) { + dial := func(_ context.Context, _ string) (net.Conn, error) { // Return no error to simulate healthy connection return &net.UnixConn{}, nil } @@ -113,7 +113,7 @@ func TestCacheNotEvictedIfConnectionIsHealthy(t *testing.T) { func TestBackgroundEnforcersCanBeStopped(t *testing.T) { defer goleak.VerifyNone(t) - dial := func(ctx context.Context, namespace string) (net.Conn, error) { + dial := func(_ context.Context, _ string) (net.Conn, error) { // Return no error so the entry is not evicted via policy return &net.UnixConn{}, nil } @@ -132,7 +132,7 @@ func TestBackgroundEnforcersCanBeStopped(t *testing.T) { func TestLogErrorOnEvictionFailure(t *testing.T) { defer goleak.VerifyNone(t) - dial := func(ctx context.Context, namespace string) (net.Conn, error) { + dial := func(_ context.Context, _ string) (net.Conn, error) { return nil, errors.New("mock dial error") } frequency := 1 * time.Millisecond diff --git a/snapshotter/demux/internal/failing_snapshotter.go b/snapshotter/demux/internal/failing_snapshotter.go index 1896b3778..d74af7d17 100644 --- a/snapshotter/demux/internal/failing_snapshotter.go +++ b/snapshotter/demux/internal/failing_snapshotter.go @@ -26,47 +26,47 @@ import ( type FailingSnapshotter struct{} // Stat mocks a failing remote call with a non-nil error. -func (s *FailingSnapshotter) Stat(ctx context.Context, key string) (snapshots.Info, error) { +func (s *FailingSnapshotter) Stat(_ context.Context, _ string) (snapshots.Info, error) { return snapshots.Info{}, errors.New("mock Stat error from remote snapshotter") } // Update mocks a failing remote call with a non-nil error. -func (s *FailingSnapshotter) Update(ctx context.Context, info snapshots.Info, fieldpaths ...string) (snapshots.Info, error) { +func (s *FailingSnapshotter) Update(_ context.Context, _ snapshots.Info, _ ...string) (snapshots.Info, error) { return snapshots.Info{}, errors.New("mock Update error from remote snapshotter") } // Usage mocks a failing remote call with a non-nil error. -func (s *FailingSnapshotter) Usage(ctx context.Context, key string) (snapshots.Usage, error) { +func (s *FailingSnapshotter) Usage(_ context.Context, _ string) (snapshots.Usage, error) { return snapshots.Usage{}, errors.New("mock Usage error from remote snapshotter") } // Mounts mocks a failing remote call with a non-nil error. -func (s *FailingSnapshotter) Mounts(ctx context.Context, key string) ([]mount.Mount, error) { +func (s *FailingSnapshotter) Mounts(_ context.Context, _ string) ([]mount.Mount, error) { return []mount.Mount{}, errors.New("mock Mounts error from remote snapshotter") } // Prepare mocks a failing remote call with a non-nil error. -func (s *FailingSnapshotter) Prepare(ctx context.Context, key string, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) { +func (s *FailingSnapshotter) Prepare(_ context.Context, _ string, _ string, _ ...snapshots.Opt) ([]mount.Mount, error) { return []mount.Mount{}, errors.New("mock Prepare error from remote snapshotter") } // View mocks a failing remote call with a non-nil error. -func (s *FailingSnapshotter) View(ctx context.Context, key string, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) { +func (s *FailingSnapshotter) View(_ context.Context, _ string, _ string, _ ...snapshots.Opt) ([]mount.Mount, error) { return []mount.Mount{}, errors.New("mock View error from remote snapshotter") } // Commit mocks a failing remote call with a non-nil error. -func (s *FailingSnapshotter) Commit(ctx context.Context, name string, key string, opts ...snapshots.Opt) error { +func (s *FailingSnapshotter) Commit(_ context.Context, _ string, _ string, _ ...snapshots.Opt) error { return errors.New("mock Commit error from remote snapshotter") } // Remove mocks a failing remote call with a non-nil error. -func (s *FailingSnapshotter) Remove(ctx context.Context, key string) error { +func (s *FailingSnapshotter) Remove(_ context.Context, _ string) error { return errors.New("mock Remove error from remote snapshotter") } // Walk mocks a failing remote call with a non-nil error. -func (s *FailingSnapshotter) Walk(ctx context.Context, fn snapshots.WalkFunc, filters ...string) error { +func (s *FailingSnapshotter) Walk(_ context.Context, _ snapshots.WalkFunc, _ ...string) error { return errors.New("mock Walk error from remote snapshotter") } @@ -76,6 +76,6 @@ func (s *FailingSnapshotter) Close() error { } // Cleanup mocks a failing remote call with a non-nil error. -func (s *FailingSnapshotter) Cleanup(ctx context.Context) error { +func (s *FailingSnapshotter) Cleanup(_ context.Context) error { return errors.New("mock Cleanup error from remote snapshotter") } diff --git a/snapshotter/demux/internal/successful_snapshotter.go b/snapshotter/demux/internal/successful_snapshotter.go index 4ed3e93bc..565141113 100644 --- a/snapshotter/demux/internal/successful_snapshotter.go +++ b/snapshotter/demux/internal/successful_snapshotter.go @@ -25,47 +25,47 @@ import ( type SuccessfulSnapshotter struct{} // Stat mocks a successful remote call with a nil error. -func (s *SuccessfulSnapshotter) Stat(ctx context.Context, key string) (snapshots.Info, error) { +func (s *SuccessfulSnapshotter) Stat(_ context.Context, _ string) (snapshots.Info, error) { return snapshots.Info{}, nil } // Update mocks a successful remote call with a nil error. -func (s *SuccessfulSnapshotter) Update(ctx context.Context, info snapshots.Info, fieldpaths ...string) (snapshots.Info, error) { +func (s *SuccessfulSnapshotter) Update(_ context.Context, _ snapshots.Info, _ ...string) (snapshots.Info, error) { return snapshots.Info{}, nil } // Usage mocks a successful remote call with a nil error. -func (s *SuccessfulSnapshotter) Usage(ctx context.Context, key string) (snapshots.Usage, error) { +func (s *SuccessfulSnapshotter) Usage(_ context.Context, _ string) (snapshots.Usage, error) { return snapshots.Usage{}, nil } // Mounts mocks a successful remote call with a nil error. -func (s *SuccessfulSnapshotter) Mounts(ctx context.Context, key string) ([]mount.Mount, error) { +func (s *SuccessfulSnapshotter) Mounts(_ context.Context, _ string) ([]mount.Mount, error) { return []mount.Mount{}, nil } // Prepare mocks a successful remote call with a nil error. -func (s *SuccessfulSnapshotter) Prepare(ctx context.Context, key string, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) { +func (s *SuccessfulSnapshotter) Prepare(_ context.Context, _ string, _ string, _ ...snapshots.Opt) ([]mount.Mount, error) { return []mount.Mount{}, nil } // View mocks a successful remote call with a nil error. -func (s *SuccessfulSnapshotter) View(ctx context.Context, key string, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) { +func (s *SuccessfulSnapshotter) View(_ context.Context, _ string, _ string, _ ...snapshots.Opt) ([]mount.Mount, error) { return []mount.Mount{}, nil } // Commit mocks a successful remote call with a nil error. -func (s *SuccessfulSnapshotter) Commit(ctx context.Context, name string, key string, opts ...snapshots.Opt) error { +func (s *SuccessfulSnapshotter) Commit(_ context.Context, _ string, _ string, _ ...snapshots.Opt) error { return nil } // Remove mocks a successful remote call with a nil error. -func (s *SuccessfulSnapshotter) Remove(ctx context.Context, key string) error { +func (s *SuccessfulSnapshotter) Remove(_ context.Context, _ string) error { return nil } // Walk mocks a successful remote call with a nil error. -func (s *SuccessfulSnapshotter) Walk(ctx context.Context, fn snapshots.WalkFunc, filters ...string) error { +func (s *SuccessfulSnapshotter) Walk(_ context.Context, _ snapshots.WalkFunc, _ ...string) error { return nil } @@ -75,6 +75,6 @@ func (s *SuccessfulSnapshotter) Close() error { } // Cleanup mocks a successful remote call with a nil error. -func (s *SuccessfulSnapshotter) Cleanup(ctx context.Context) error { +func (s *SuccessfulSnapshotter) Cleanup(_ context.Context) error { return nil } diff --git a/snapshotter/demux/metrics/discovery/service_discovery.go b/snapshotter/demux/metrics/discovery/service_discovery.go index 20ff9e38a..a2871a80d 100644 --- a/snapshotter/demux/metrics/discovery/service_discovery.go +++ b/snapshotter/demux/metrics/discovery/service_discovery.go @@ -21,7 +21,7 @@ import ( "strconv" "time" - "github.com/containerd/containerd/log" + "github.com/containerd/log" "github.com/firecracker-microvm/firecracker-containerd/snapshotter/demux/cache" ) diff --git a/snapshotter/demux/metrics/proxy.go b/snapshotter/demux/metrics/proxy.go index 3733c02b4..8e9979b64 100644 --- a/snapshotter/demux/metrics/proxy.go +++ b/snapshotter/demux/metrics/proxy.go @@ -23,7 +23,7 @@ import ( "sync" "time" - "github.com/containerd/containerd/log" + "github.com/containerd/log" ) const ( diff --git a/snapshotter/demux/metrics/proxy_test.go b/snapshotter/demux/metrics/proxy_test.go index 76d51010b..388294dd8 100644 --- a/snapshotter/demux/metrics/proxy_test.go +++ b/snapshotter/demux/metrics/proxy_test.go @@ -218,7 +218,7 @@ type mockClient struct { getError error } -func (c *mockClient) Get(url string) (*http.Response, error) { +func (c *mockClient) Get(_ string) (*http.Response, error) { if c.getError != nil { return nil, c.getError } diff --git a/snapshotter/demux/proxy/address/http_resolver_test.go b/snapshotter/demux/proxy/address/http_resolver_test.go index a8b1676c8..708225759 100644 --- a/snapshotter/demux/proxy/address/http_resolver_test.go +++ b/snapshotter/demux/proxy/address/http_resolver_test.go @@ -143,7 +143,7 @@ type mockClient struct { getError error } -func (c *mockClient) Get(url string) (*http.Response, error) { +func (c *mockClient) Get(_ string) (*http.Response, error) { if c.getError != nil { return nil, c.getError } diff --git a/snapshotter/demux/proxy/snapshotter.go b/snapshotter/demux/proxy/snapshotter.go index 39315128f..ce4ba8c23 100644 --- a/snapshotter/demux/proxy/snapshotter.go +++ b/snapshotter/demux/proxy/snapshotter.go @@ -64,9 +64,8 @@ func NewRemoteSnapshotter(ctx context.Context, address string, opts := []grpc.DialOption{ grpc.WithContextDialer(dialer), grpc.WithTransportCredentials(insecure.NewCredentials()), - grpc.WithBlock(), } - gRPCConn, err := grpc.DialContext(ctx, address, opts...) + gRPCConn, err := grpc.NewClient(address, opts...) if err != nil { return nil, err } diff --git a/snapshotter/demux/snapshotter.go b/snapshotter/demux/snapshotter.go index 96c33902a..76f7a69c9 100644 --- a/snapshotter/demux/snapshotter.go +++ b/snapshotter/demux/snapshotter.go @@ -16,10 +16,10 @@ package demux import ( "context" - "github.com/containerd/containerd/log" "github.com/containerd/containerd/mount" "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/snapshots" + "github.com/containerd/log" "github.com/sirupsen/logrus" "github.com/firecracker-microvm/firecracker-containerd/internal/vm" diff --git a/snapshotter/demux/snapshotter_test.go b/snapshotter/demux/snapshotter_test.go index 06a1660f7..23d17dc18 100644 --- a/snapshotter/demux/snapshotter_test.go +++ b/snapshotter/demux/snapshotter_test.go @@ -18,21 +18,21 @@ import ( "errors" "testing" - "github.com/containerd/containerd/log/logtest" "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/snapshots" + "github.com/containerd/log/logtest" "github.com/firecracker-microvm/firecracker-containerd/snapshotter/demux/cache" "github.com/firecracker-microvm/firecracker-containerd/snapshotter/demux/internal" "github.com/firecracker-microvm/firecracker-containerd/snapshotter/demux/proxy" ) -func fetchOkSnapshotter(ctx context.Context, key string) (*proxy.RemoteSnapshotter, error) { +func fetchOkSnapshotter(_ context.Context, _ string) (*proxy.RemoteSnapshotter, error) { var snapshotter internal.SuccessfulSnapshotter = internal.SuccessfulSnapshotter{} return &proxy.RemoteSnapshotter{Snapshotter: &snapshotter}, nil } -func fetchSnapshotterNotFound(ctx context.Context, key string) (*proxy.RemoteSnapshotter, error) { +func fetchSnapshotterNotFound(_ context.Context, _ string) (*proxy.RemoteSnapshotter, error) { return nil, errors.New("mock snapshotter not found") } @@ -42,7 +42,7 @@ func createSnapshotterCacheWithSuccessfulSnapshotter(namespace string) *cache.Re return cache } -func fetchFailingSnapshotter(ctx context.Context, key string) (*proxy.RemoteSnapshotter, error) { +func fetchFailingSnapshotter(_ context.Context, _ string) (*proxy.RemoteSnapshotter, error) { var snapshotter internal.FailingSnapshotter = internal.FailingSnapshotter{} return &proxy.RemoteSnapshotter{Snapshotter: &snapshotter}, nil } @@ -96,7 +96,7 @@ func TestNoErrorWhenCalledWithoutNamespacedContext(t *testing.T) { run func() error }{ {"Walk", func() error { - var callback = func(c context.Context, i snapshots.Info) error { return nil } + var callback = func(_ context.Context, _ snapshots.Info) error { return nil } return uut.Walk(ctx, callback) }}, } @@ -131,7 +131,7 @@ func TestReturnErrorWhenSnapshotterNotFound(t *testing.T) { {"Commit", func() error { return uut.Commit(ctx, "layer1", "layerKey") }}, {"Remove", func() error { return uut.Remove(ctx, "layerKey") }}, {"Walk", func() error { - var callback = func(c context.Context, i snapshots.Info) error { return nil } + var callback = func(_ context.Context, _ snapshots.Info) error { return nil } return uut.Walk(ctx, callback) }}, {"Cleanup", func() error { return uut.(snapshots.Cleaner).Cleanup(ctx) }}, @@ -167,7 +167,7 @@ func TestReturnErrorAfterProxyFunctionFailure(t *testing.T) { {"Commit", func() error { return uut.Commit(ctx, "layer1", "layerKey") }}, {"Remove", func() error { return uut.Remove(ctx, "layerKey") }}, {"Walk", func() error { - var callback = func(c context.Context, i snapshots.Info) error { return nil } + var callback = func(_ context.Context, _ snapshots.Info) error { return nil } return uut.Walk(ctx, callback) }}, {"Cleanup", func() error { return uut.(snapshots.Cleaner).Cleanup(ctx) }}, @@ -206,7 +206,7 @@ func TestNoErrorIsReturnedOnSuccessfulProxyExecution(t *testing.T) { {"Commit", func() error { return uut.Commit(ctx, "layer1", "layerKey") }}, {"Remove", func() error { return uut.Remove(ctx, "layerKey") }}, {"Walk", func() error { - var callback = func(c context.Context, i snapshots.Info) error { return nil } + var callback = func(_ context.Context, _ snapshots.Info) error { return nil } return uut.Walk(ctx, callback) }}, {"Cleanup", func() error { return uut.(snapshots.Cleaner).Cleanup(ctx) }}, diff --git a/volume/cmd/volume-init/main.go b/volume/cmd/volume-init/main.go index bb12de9d9..8da5431f2 100644 --- a/volume/cmd/volume-init/main.go +++ b/volume/cmd/volume-init/main.go @@ -23,7 +23,7 @@ import ( "github.com/firecracker-microvm/firecracker-containerd/volume" ) -func copy(in volume.GuestVolumeImageInput) error { +func copyVolume(in volume.GuestVolumeImageInput) error { for _, v := range in.Volumes { to, err := fs.RootPath(in.To, v) if err != nil { @@ -60,7 +60,7 @@ func realMain() error { return err } - return copy(in) + return copyVolume(in) } func main() { diff --git a/volume/cmd/volume-init/main_test.go b/volume/cmd/volume-init/main_test.go index 7991b39d4..5882b8fac 100644 --- a/volume/cmd/volume-init/main_test.go +++ b/volume/cmd/volume-init/main_test.go @@ -38,7 +38,7 @@ func TestCopy(t *testing.T) { err := mkdirAndTouch(filepath.Join(from, "/etc/foobar/hello"), "helloworld") require.NoError(t, err) - err = copy(volume.GuestVolumeImageInput{ + err = copyVolume(volume.GuestVolumeImageInput{ From: from, To: to, Volumes: []string{"/etc/foobar"}, diff --git a/volume/guest_image.go b/volume/guest_image.go index 43a6b42d1..e1cda2e3e 100644 --- a/volume/guest_image.go +++ b/volume/guest_image.go @@ -102,8 +102,8 @@ func (p *GuestVolumeImageProvider) pull(ctx context.Context) error { return nil } -func mountHostDirs(image string) oci.SpecOpts { - return func(ctx context.Context, client oci.Client, container *containers.Container, s *oci.Spec) error { +func mountHostDirs(_ string) oci.SpecOpts { + return func(_ context.Context, _ oci.Client, _ *containers.Container, s *oci.Spec) error { s.Mounts = append(s.Mounts, specs.Mount{ Source: vmBinDir, @@ -202,7 +202,7 @@ func (p *GuestVolumeImageProvider) copy(ctx context.Context, containerName strin } // CreateVolumesUnder creates volumes under the given directory. -func (p *GuestVolumeImageProvider) CreateVolumesUnder(ctx context.Context, tempDir string) ([]*Volume, error) { +func (p *GuestVolumeImageProvider) CreateVolumesUnder(_ context.Context, _ string) ([]*Volume, error) { if p.vmDir == "" { return nil, errors.New("call Copy() beforehand") } @@ -218,6 +218,6 @@ func (p *GuestVolumeImageProvider) CreateVolumesUnder(ctx context.Context, tempD } // Delete all resources made by the provider. -func (*GuestVolumeImageProvider) Delete(ctx context.Context) error { +func (*GuestVolumeImageProvider) Delete(_ context.Context) error { return nil } diff --git a/volume/set.go b/volume/set.go index 655e218c2..26a4ae0d2 100644 --- a/volume/set.go +++ b/volume/set.go @@ -79,7 +79,7 @@ func (vs *Set) Add(v *Volume) { } // AddFrom adds volumes from the given provider. -func (vs *Set) AddFrom(ctx context.Context, vp Provider) error { +func (vs *Set) AddFrom(_ context.Context, vp Provider) error { if _, exists := vs.providers[vp.Name()]; exists { return fmt.Errorf("failed to add %q: %w", vp.Name(), errdefs.ErrAlreadyExists) } @@ -338,7 +338,7 @@ func (vs *Set) WithMounts(mountpoints []Mount) (oci.SpecOpts, error) { }) } - return func(ctx context.Context, client oci.Client, container *containers.Container, s *oci.Spec) error { + return func(_ context.Context, _ oci.Client, _ *containers.Container, s *oci.Spec) error { s.Mounts = append(s.Mounts, mounts...) return nil }, nil diff --git a/volume/set_test.go b/volume/set_test.go index 14a5d6aee..9b55f07db 100644 --- a/volume/set_test.go +++ b/volume/set_test.go @@ -24,10 +24,10 @@ type testProvider struct { name string } -func (p *testProvider) CreateVolumesUnder(ctx context.Context, path string) ([]*Volume, error) { +func (p *testProvider) CreateVolumesUnder(_ context.Context, _ string) ([]*Volume, error) { return nil, nil } -func (p *testProvider) Delete(ctx context.Context) error { +func (p *testProvider) Delete(_ context.Context) error { return nil } func (p *testProvider) Name() string {