Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/windows-hyperv-periodic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -309,15 +309,15 @@ jobs:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}

- name: UploadJobReport
uses: google-github-actions/upload-cloud-storage@7c73f5d6eae167341002e9c946f7479a609c588e # v2.2.3
uses: google-github-actions/upload-cloud-storage@6397bd7208e18d13ba2619ee21b9873edc94427a # v3.0.0
if: steps.AssignGcpCreds.outputs.GCP_SERVICE_ACCOUNT && steps.AssignGcpCreds.outputs.GCP_WORKLOAD_IDENTITY_PROVIDER
with:
path: ${{ github.workspace }}/latest-build.txt
destination: ${{ matrix.GOOGLE_BUCKET }}
parent: false

- name: UploadLogsDir
uses: google-github-actions/upload-cloud-storage@7c73f5d6eae167341002e9c946f7479a609c588e # v2.2.3
uses: google-github-actions/upload-cloud-storage@6397bd7208e18d13ba2619ee21b9873edc94427a # v3.0.0
if: steps.AssignGcpCreds.outputs.GCP_SERVICE_ACCOUNT && steps.AssignGcpCreds.outputs.GCP_WORKLOAD_IDENTITY_PROVIDER
with:
path: ${{ env.LOGS_DIR }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/windows-periodic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -259,15 +259,15 @@ jobs:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}

- name: UploadJobReport
uses: google-github-actions/upload-cloud-storage@7c73f5d6eae167341002e9c946f7479a609c588e # v2.2.3
uses: google-github-actions/upload-cloud-storage@6397bd7208e18d13ba2619ee21b9873edc94427a # v3.0.0
if: steps.AssignGcpCreds.outputs.GCP_SERVICE_ACCOUNT && steps.AssignGcpCreds.outputs.GCP_WORKLOAD_IDENTITY_PROVIDER
with:
path: ${{ github.workspace }}/latest-build.txt
destination: ${{ matrix.GOOGLE_BUCKET }}
parent: false

- name: UploadLogsDir
uses: google-github-actions/upload-cloud-storage@7c73f5d6eae167341002e9c946f7479a609c588e # v2.2.3
uses: google-github-actions/upload-cloud-storage@6397bd7208e18d13ba2619ee21b9873edc94427a # v3.0.0
if: steps.AssignGcpCreds.outputs.GCP_SERVICE_ACCOUNT && steps.AssignGcpCreds.outputs.GCP_WORKLOAD_IDENTITY_PROVIDER
with:
path: ${{ env.LOGS_DIR }}
Expand Down
3 changes: 2 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ linters:
- depguard # Checks for dependencies that should not be (re)introduced. See "settings" for further details.
- dupword # Checks for duplicate words in the source code
- gosec
- revive
- misspell
- nolintlint
- revive
- unconvert
- usetesting
disable:
- errcheck
settings:
Expand Down
80 changes: 24 additions & 56 deletions core/mount/losetup_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,27 @@ package mount

import (
"os"
"path/filepath"
"testing"
"time"

"github.com/containerd/continuity/testutil"
"github.com/stretchr/testify/require"
)

var randomData = []byte("randomdata")

func createTempFile(t *testing.T) string {
t.Helper()

f, err := os.CreateTemp("", "losetup")
if err != nil {
t.Fatal(err)
}
defer f.Close()
f, err := os.Create(filepath.Join(t.TempDir(), "losetup"))
require.NoError(t, err)
t.Cleanup(func() {
f.Close()
})

if err = f.Truncate(512); err != nil {
t.Fatal(err)
}
err = f.Truncate(512)
require.NoError(t, err)

return f.Name()
}
Expand All @@ -56,17 +57,12 @@ func TestRoLoop(t *testing.T) {
testutil.RequiresRoot(t)

backingFile := createTempFile(t)
defer func() {
if err := os.Remove(backingFile); err != nil {
t.Fatal(err)
}
}()

file, err := setupLoop(backingFile, LoopParams{Readonly: true, Autoclear: true})
if err != nil {
t.Fatal(err)
}
defer file.Close()
require.NoError(t, err)
t.Cleanup(func() {
file.Close()
})

if _, err := file.Write(randomData); err == nil {
t.Fatalf("writing to readonly loop device should fail")
Expand All @@ -77,17 +73,12 @@ func TestRwLoop(t *testing.T) {
testutil.RequiresRoot(t)

backingFile := createTempFile(t)
defer func() {
if err := os.Remove(backingFile); err != nil {
t.Fatal(err)
}
}()

file, err := setupLoop(backingFile, LoopParams{Autoclear: true})
if err != nil {
t.Fatal(err)
}
defer file.Close()
require.NoError(t, err)
t.Cleanup(func() {
file.Close()
})

if _, err := file.Write(randomData); err != nil {
t.Fatal(err)
Expand All @@ -98,37 +89,22 @@ func TestAttachDetachLoopDevice(t *testing.T) {
testutil.RequiresRoot(t)

path := createTempFile(t)
defer func() {
if err := os.Remove(path); err != nil {
t.Fatal(err)
}
}()

dev, err := AttachLoopDevice(path)
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)

if err = DetachLoopDevice(dev); err != nil {
t.Fatal(err)
}
err = DetachLoopDevice(dev)
require.NoError(t, err)
}

func TestAutoclearTrueLoop(t *testing.T) {
testutil.RequiresRoot(t)

dev := func() string {
backingFile := createTempFile(t)
defer func() {
if err := os.Remove(backingFile); err != nil {
t.Fatal(err)
}
}()

file, err := setupLoop(backingFile, LoopParams{Autoclear: true})
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)
dev := file.Name()
file.Close()
return dev
Expand All @@ -144,22 +120,14 @@ func TestAutoclearFalseLoop(t *testing.T) {

dev := func() string {
backingFile := createTempFile(t)
defer func() {
if err := os.Remove(backingFile); err != nil {
t.Fatal(err)
}
}()

file, err := setupLoop(backingFile, LoopParams{Autoclear: false})
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)
dev := file.Name()
file.Close()
return dev
}()
time.Sleep(100 * time.Millisecond)
if err := removeLoop(dev); err != nil {
t.Fatal(err)
}
err := removeLoop(dev)
require.NoError(t, err)
}
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ require (
go.opentelemetry.io/otel/sdk v1.37.0
go.opentelemetry.io/otel/trace v1.37.0
go.uber.org/goleak v1.3.0
golang.org/x/mod v0.27.0
golang.org/x/sync v0.16.0
golang.org/x/sys v0.35.0
golang.org/x/mod v0.28.0
golang.org/x/sync v0.17.0
golang.org/x/sys v0.36.0
google.golang.org/genproto/googleapis/rpc v0.0.0-20250707201910-8d1bb00bc6a7
google.golang.org/grpc v1.75.0
google.golang.org/protobuf v1.36.8
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,8 @@ golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.27.0 h1:kb+q2PyFnEADO2IEF935ehFUXlWiNjJWtRNgBLSfbxQ=
golang.org/x/mod v0.27.0/go.mod h1:rWI627Fq0DEoudcK+MBkNkCe0EetEaDSwJJkCcjpazc=
golang.org/x/mod v0.28.0 h1:gQBtGhjxykdjY9YhZpSlZIsbnaE2+PgjfLWUQTnoZ1U=
golang.org/x/mod v0.28.0/go.mod h1:yfB/L0NOf/kmEbXjzCPOx1iK1fRutOydrCMsqRhEBxI=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -445,8 +445,8 @@ golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand All @@ -470,8 +470,8 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
Expand Down
3 changes: 2 additions & 1 deletion integration/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ func init() {
}

func testContext(t testing.TB) (context.Context, context.CancelFunc) {
ctx, cancel := context.WithCancel(context.Background())
// This needs work to convert from context.Background() to t.Context().
ctx, cancel := context.WithCancel(context.Background()) //nolint:all
ctx = namespaces.WithNamespace(ctx, testNamespace)
if t != nil {
ctx = logtest.WithT(ctx, t)
Expand Down
17 changes: 7 additions & 10 deletions integration/client/container_fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
fuzz "github.com/AdaLogics/go-fuzz-headers"
containerd "github.com/containerd/containerd/v2/client"
"github.com/containerd/containerd/v2/pkg/oci"
"github.com/stretchr/testify/require"
)

const (
Expand Down Expand Up @@ -112,9 +113,7 @@ func initInSteps(t *testing.T) bool {
if !haveChangedDownloadPATH {
oldPathEnv := os.Getenv("PATH")
newPathEnv := fmt.Sprintf("%s:%s", filepath.Join(downloadBinDir, "bin"), oldPathEnv)
if err := os.Setenv("PATH", newPathEnv); err != nil {
return true
}
t.Setenv("PATH", newPathEnv)
haveChangedDownloadPATH = true
return true
}
Expand Down Expand Up @@ -153,13 +152,11 @@ func checkIfShouldRestart(err error) {
func startDaemon(ctx context.Context, t *testing.T, shouldTearDown bool) {
buf := bytes.NewBuffer(nil)
tmpDir := t.TempDir()
stdioFile, err := os.CreateTemp(tmpDir, "")
if err != nil {
// We panic here as it is a fuzz-blocker that
// may need fixing
t.Fatalf("failed to create temp file: %v", err)
}
defer stdioFile.Close()
stdioFile, err := os.Create(filepath.Join(tmpDir, "stdio"))
require.NoError(t, err)
t.Cleanup(func() {
stdioFile.Close()
})

ctrdStdioFilePath = stdioFile.Name()
stdioWriter := io.MultiWriter(stdioFile, buf)
Expand Down
21 changes: 10 additions & 11 deletions integration/client/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"context"
"io"
"os"
"path/filepath"
"runtime"
"strings"
"testing"
Expand All @@ -34,6 +35,7 @@ import (
"github.com/containerd/platforms"
"github.com/google/uuid"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/stretchr/testify/require"
)

func TestExportAllCases(t *testing.T) {
Expand Down Expand Up @@ -241,23 +243,20 @@ func TestExportAllCases(t *testing.T) {

namespace := uuid.New().String()
client, err := newClient(t, address, WithDefaultNamespace(namespace))
if err != nil {
t.Fatal(err)
}
defer client.Close()
require.NoError(t, err)
t.Cleanup(func() {
client.Close()
})

ctx = namespaces.WithNamespace(ctx, namespace)

img := tc.prepare(ctx, t, client)

dstFile, err := os.CreateTemp("", "export-test")
if err != nil {
t.Fatal(err)
}
defer func() {
dstFile, err := os.Create(filepath.Join(t.TempDir(), "export-test"))
require.NoError(t, err)
t.Cleanup(func() {
dstFile.Close()
os.Remove(dstFile.Name())
}()
})

tc.check(ctx, t, client, dstFile, img)
})
Expand Down
Loading
Loading