Skip to content

Commit 4873e73

Browse files
build(deps): update nerdctl to v2.1.6 from v2.1.3
Signed-off-by: Swapnanil-Gupta <[email protected]>
1 parent 4891207 commit 4873e73

File tree

11 files changed

+137
-199
lines changed

11 files changed

+137
-199
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
- '**.md'
1313
workflow_dispatch:
1414
env:
15-
GO_VERSION: '1.23.8'
15+
GO_VERSION: '1.24.6'
1616
GOLANGCI_LINT_VERSION: '1.64.8'
1717
jobs:
1818
git-secrets:
@@ -80,7 +80,7 @@ jobs:
8080
strategy:
8181
matrix:
8282
containerd: ["1.7.27", "2.1.3"]
83-
nerdctl: ["2.1.2", "2.1.3"]
83+
nerdctl: ["2.1.3", "2.1.4", "2.1.5", "2.1.6"]
8484
fail-fast: false
8585
timeout-minutes: 10
8686
steps:

.github/workflows/finch-vm-test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
- '**.md'
1313
workflow_dispatch:
1414
env:
15-
GO_VERSION: '1.24.x'
15+
GO_VERSION: '1.24.6'
1616
jobs:
1717
mac-test-e2e:
1818
runs-on: codebuild-finch-daemon-arm64-2-instance-${{ github.run_id }}-${{ github.run_attempt }}

.github/workflows/release-automation.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
workflow_dispatch:
44
workflow_call:
55
env:
6-
GO_VERSION: '1.23.8'
6+
GO_VERSION: '1.24.6'
77
permissions:
88
contents: write
99
deployments: write

.github/workflows/samcli-direct.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
workflow_dispatch:
1212

1313
env:
14-
GO_VERSION: '1.24.x'
14+
GO_VERSION: '1.24.6'
1515
CONTAINERD_VERSION: '2.0.x'
1616

1717
permissions:

.github/workflows/samcli-vm.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
workflow_dispatch:
77

88
env:
9-
GO_VERSION: '1.24.x'
9+
GO_VERSION: '1.24.6'
1010
PYTHON_VERSION: '3.11'
1111
PYTHON_BINARY: 'python3.11'
1212
AWS_DEFAULT_REGION: "${{ secrets.REGION }}"

e2e/tests/container_create.go

Lines changed: 22 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ import (
1515
"strings"
1616
"time"
1717

18+
"github.com/containerd/continuity/testutil/loopback"
1819
"github.com/containerd/nerdctl/v2/pkg/inspecttypes/dockercompat"
1920
"github.com/docker/go-connections/nat"
2021
"github.com/moby/moby/api/types/blkiodev"
2122
. "github.com/onsi/ginkgo/v2"
2223
. "github.com/onsi/gomega"
23-
"github.com/opencontainers/runtime-spec/specs-go"
2424
"github.com/runfinch/common-tests/command"
2525
"github.com/runfinch/common-tests/ffs"
2626
"github.com/runfinch/common-tests/option"
@@ -841,21 +841,16 @@ func ContainerCreate(opt *option.Option, pOpt util.NewOpt) {
841841
Skip("Blkio settings are only supported on Linux")
842842
}
843843

844-
// Create dummy device paths
845-
dummyDev1 := "/dev/dummy-zero1"
846-
dummyDev2 := "/dev/dummy-zero2"
844+
// check if our nerdctl version is >= 2.1.5 or not
845+
// because nerdctl 2.1.5 saw changes in container inspect's hostconfig object
846+
// where Blkio fields were changed from LinuxBlkio* to Blkio* and instead of device
847+
// major:minor numbers, device paths are returned. See - https://github.com/containerd/nerdctl/pull/4512
848+
RequireNerdctlVersion(opt, ">=2.1.5")
847849

848-
// Create dummy devices (major number 1 for char devices)
849-
mknodOpt1, _ := pOpt([]string{"mknod", dummyDev1, "c", "1", "5"})
850-
command.Run(mknodOpt1)
851-
mknodOpt2, _ := pOpt([]string{"mknod", dummyDev2, "c", "1", "6"})
852-
command.Run(mknodOpt2)
853-
854-
// Cleanup dummy devices after test
855-
defer func() {
856-
rmOpt, _ := pOpt([]string{"rm", "-f", dummyDev1, dummyDev2})
857-
command.Run(rmOpt)
858-
}()
850+
// setup loop device
851+
lo, err := loopback.New(4096)
852+
Expect(err).Should(BeNil())
853+
defer lo.Close()
859854

860855
// define options
861856
options.Cmd = []string{"sleep", "Infinity"}
@@ -864,40 +859,36 @@ func ContainerCreate(opt *option.Option, pOpt util.NewOpt) {
864859
// Create WeightDevice objects for input
865860
weightDevices := []*blkiodev.WeightDevice{
866861
{
867-
Path: dummyDev1,
862+
Path: lo.Device,
868863
Weight: 400,
869864
},
870-
{
871-
Path: dummyDev2,
872-
Weight: 300,
873-
},
874865
}
875866

876867
// Create ThrottleDevice objects for input
877868
readBpsDevices := []*blkiodev.ThrottleDevice{
878869
{
879-
Path: dummyDev1,
870+
Path: lo.Device,
880871
Rate: 1048576, // 1MB/s
881872
},
882873
}
883874

884875
writeBpsDevices := []*blkiodev.ThrottleDevice{
885876
{
886-
Path: dummyDev1,
877+
Path: lo.Device,
887878
Rate: 2097152, // 2MB/s
888879
},
889880
}
890881

891882
readIopsDevices := []*blkiodev.ThrottleDevice{
892883
{
893-
Path: dummyDev1,
884+
Path: lo.Device,
894885
Rate: 1000,
895886
},
896887
}
897888

898889
writeIopsDevices := []*blkiodev.ThrottleDevice{
899890
{
900-
Path: dummyDev1,
891+
Path: lo.Device,
901892
Rate: 2000,
902893
},
903894
}
@@ -920,93 +911,23 @@ func ContainerCreate(opt *option.Option, pOpt util.NewOpt) {
920911
// inspect container
921912
resp := command.Stdout(opt, "inspect", testContainerName)
922913
var inspect []*dockercompat.Container
923-
err := json.Unmarshal(resp, &inspect)
914+
err = json.Unmarshal(resp, &inspect)
924915
Expect(err).Should(BeNil())
925916
Expect(inspect).Should(HaveLen(1))
926917

927918
// Verify blkio settings in LinuxBlkioSettings
928-
blkioSettings := inspect[0].HostConfig.LinuxBlkioSettings
919+
blkioSettings := inspect[0].HostConfig.BlkioSettings
929920
// Verify BlkioWeight
930921
Expect(blkioSettings.BlkioWeight).Should(Equal(options.HostConfig.BlkioWeight))
931922

932-
// Helper function to map major/minor to device path
933-
devicePathFromMajorMinor := func(major, minor int64) string {
934-
if major == 1 && minor == 5 {
935-
return dummyDev1
936-
}
937-
if major == 1 && minor == 6 {
938-
return dummyDev2
939-
}
940-
return fmt.Sprintf("/dev/unknown-%d-%d", major, minor)
941-
}
942-
943-
// Helper function to convert specs.LinuxWeightDevice to blkiodev.WeightDevice
944-
convertWeightDevice := func(wd *specs.LinuxWeightDevice) *blkiodev.WeightDevice {
945-
if wd == nil || wd.Weight == nil {
946-
return nil
947-
}
948-
return &blkiodev.WeightDevice{
949-
Path: devicePathFromMajorMinor(wd.Major, wd.Minor),
950-
Weight: *wd.Weight,
951-
}
952-
}
953-
954-
// Helper function to convert specs.LinuxThrottleDevice to blkiodev.ThrottleDevice
955-
convertThrottleDevice := func(td *specs.LinuxThrottleDevice) *blkiodev.ThrottleDevice {
956-
if td == nil {
957-
return nil
958-
}
959-
return &blkiodev.ThrottleDevice{
960-
Path: devicePathFromMajorMinor(td.Major, td.Minor),
961-
Rate: td.Rate,
962-
}
963-
}
964-
965-
// Convert response devices to blkiodev types
966-
responseWeightDevices := make([]*blkiodev.WeightDevice, 0, len(blkioSettings.BlkioWeightDevice))
967-
for _, d := range blkioSettings.BlkioWeightDevice {
968-
if converted := convertWeightDevice(d); converted != nil {
969-
responseWeightDevices = append(responseWeightDevices, converted)
970-
}
971-
}
972-
973-
responseReadBpsDevices := make([]*blkiodev.ThrottleDevice, 0, len(blkioSettings.BlkioDeviceReadBps))
974-
for _, d := range blkioSettings.BlkioDeviceReadBps {
975-
if converted := convertThrottleDevice(d); converted != nil {
976-
responseReadBpsDevices = append(responseReadBpsDevices, converted)
977-
}
978-
}
979-
980-
responseWriteBpsDevices := make([]*blkiodev.ThrottleDevice, 0, len(blkioSettings.BlkioDeviceWriteBps))
981-
for _, d := range blkioSettings.BlkioDeviceWriteBps {
982-
if converted := convertThrottleDevice(d); converted != nil {
983-
responseWriteBpsDevices = append(responseWriteBpsDevices, converted)
984-
}
985-
}
986-
987-
responseReadIopsDevices := make([]*blkiodev.ThrottleDevice, 0, len(blkioSettings.BlkioDeviceReadIOps))
988-
for _, d := range blkioSettings.BlkioDeviceReadIOps {
989-
if converted := convertThrottleDevice(d); converted != nil {
990-
responseReadIopsDevices = append(responseReadIopsDevices, converted)
991-
}
992-
}
993-
994-
responseWriteIopsDevices := make([]*blkiodev.ThrottleDevice, 0, len(blkioSettings.BlkioDeviceWriteIOps))
995-
for _, d := range blkioSettings.BlkioDeviceWriteIOps {
996-
if converted := convertThrottleDevice(d); converted != nil {
997-
responseWriteIopsDevices = append(responseWriteIopsDevices, converted)
998-
}
999-
}
1000-
1001923
// Compare string representations
1002924
for i, wd := range weightDevices {
1003-
Expect(responseWeightDevices[i].String()).Should(Equal(wd.String()))
925+
Expect(blkioSettings.BlkioWeightDevice[i].String()).Should(Equal(wd.String()))
1004926
}
1005-
1006-
Expect(responseReadBpsDevices[0].String()).Should(Equal(readBpsDevices[0].String()))
1007-
Expect(responseWriteBpsDevices[0].String()).Should(Equal(writeBpsDevices[0].String()))
1008-
Expect(responseReadIopsDevices[0].String()).Should(Equal(readIopsDevices[0].String()))
1009-
Expect(responseWriteIopsDevices[0].String()).Should(Equal(writeIopsDevices[0].String()))
927+
Expect(blkioSettings.BlkioDeviceReadBps[0].String()).Should(Equal(readBpsDevices[0].String()))
928+
Expect(blkioSettings.BlkioDeviceWriteBps[0].String()).Should(Equal(writeBpsDevices[0].String()))
929+
Expect(blkioSettings.BlkioDeviceReadIOps[0].String()).Should(Equal(readIopsDevices[0].String()))
930+
Expect(blkioSettings.BlkioDeviceWriteIOps[0].String()).Should(Equal(writeIopsDevices[0].String()))
1010931
})
1011932

1012933
It("should create container with volumes from another container", func() {

e2e/tests/container_inspect.go

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"io"
1010
"net/http"
1111

12+
"github.com/containerd/continuity/testutil/loopback"
1213
"github.com/docker/go-connections/nat"
1314
. "github.com/onsi/ginkgo/v2"
1415
. "github.com/onsi/gomega"
@@ -104,25 +105,13 @@ func ContainerInspect(opt *option.Option, pOpt util.NewOpt) {
104105
}
105106

106107
// setup devices
107-
tmpFileOpt, _ := pOpt([]string{"touch", "/tmp/loopdev"})
108-
command.Run(tmpFileOpt)
109-
defer func() {
110-
rmOpt, _ := pOpt([]string{"rm", "-f", "/tmp/loopdev"})
111-
command.Run(rmOpt)
112-
}()
113-
ddOpt, _ := pOpt([]string{"dd", "if=/dev/zero", "of=/tmp/loopdev", "bs=4096", "count=1"})
114-
command.Run(ddOpt)
115-
loopDevOpt, _ := pOpt([]string{"losetup", "-f", "--show", "/tmp/loopdev"})
116-
loopDev := command.StdoutStr(loopDevOpt)
117-
Expect(loopDev).ShouldNot(BeEmpty())
118-
defer func() {
119-
detachOpt, _ := pOpt([]string{"losetup", "-d", loopDev})
120-
command.Run(detachOpt)
121-
}()
108+
lo, err := loopback.New(4096)
109+
Expect(err).Should(BeNil())
110+
defer lo.Close()
122111
createOptions.HostConfig.Devices = []types.DeviceMapping{
123112
{
124-
PathOnHost: loopDev,
125-
PathInContainer: loopDev,
113+
PathOnHost: lo.Device,
114+
PathInContainer: lo.Device,
126115
CgroupPermissions: "rwm",
127116
},
128117
}

e2e/tests/tests.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ import (
1515
"os"
1616
"os/exec"
1717
"path/filepath"
18+
"regexp"
1819
"strings"
1920

21+
"github.com/Masterminds/semver/v3"
2022
"github.com/onsi/ginkgo/v2"
2123
"github.com/onsi/gomega"
2224
"github.com/runfinch/common-tests/command"
@@ -234,3 +236,29 @@ func GetFinchDaemonExe() string {
234236
}
235237
return daemonPath
236238
}
239+
240+
func GetNerdctlVersion(opt *option.Option) (string, error) {
241+
output := command.StdoutStr(opt, "--version")
242+
if output == "" {
243+
return "", fmt.Errorf("failed to get nerdctl version")
244+
}
245+
246+
re := regexp.MustCompile(`^nerdctl\s+version\s+(.*)$`)
247+
matches := re.FindStringSubmatch(output)
248+
if matches == nil || len(matches) != 2 {
249+
return "", fmt.Errorf("regexp did not match properly, output: %s", output)
250+
}
251+
return matches[1], nil
252+
}
253+
254+
func RequireNerdctlVersion(opt *option.Option, constraint string) {
255+
nerdctlVersion, err := GetNerdctlVersion(opt)
256+
gomega.Expect(err).Should(gomega.BeNil())
257+
nerdctlSemver, err := semver.NewVersion(nerdctlVersion)
258+
gomega.Expect(err).Should(gomega.BeNil())
259+
nerdctlVersionConstraint, err := semver.NewConstraint(constraint)
260+
gomega.Expect(err).Should(gomega.BeNil())
261+
if nerdctlVersionConstraint.Check(nerdctlSemver) {
262+
ginkgo.Skip(fmt.Sprintf("Test requires nerdctl version: %s, but got: %s", constraint, nerdctlVersion))
263+
}
264+
}

0 commit comments

Comments
 (0)