diff --git a/docs/soci.md b/docs/soci.md index bfcb53ff0..88b3d66dd 100644 --- a/docs/soci.md +++ b/docs/soci.md @@ -1,7 +1,10 @@ # Lazy-pulling using SOCI Snapshotter -| :bird: Requirement | finch >= 0.8.0 | -|--------------------|----------------| +| :bird: Requirement for pull and run | finch >= 0.8.0 | +|-----------------------------------|----------------| + +| :bird: Requirement for push with SOCI | finch >= 0.9.0 | +|---------------------------------------|----------------| ## Using SOCI diff --git a/e2e/vm/soci_test.go b/e2e/vm/soci_test.go index 7c8300ccd..8e8fb18a9 100644 --- a/e2e/vm/soci_test.go +++ b/e2e/vm/soci_test.go @@ -4,6 +4,7 @@ package vm import ( + "fmt" "os" "os/exec" "path/filepath" @@ -12,11 +13,15 @@ import ( "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" "github.com/runfinch/common-tests/command" + "github.com/runfinch/common-tests/ffs" + "github.com/runfinch/common-tests/fnet" "github.com/runfinch/common-tests/option" ) const ( ffmpegSociImage = "public.ecr.aws/soci-workshop-examples/ffmpeg:latest" + registryImage = "public.ecr.aws/docker/library/registry:latest" + ubuntuImage = "public.ecr.aws/docker/library/ubuntu:23.10" sociMountString = "fuse.rawBridge" ) @@ -25,6 +30,7 @@ var testSoci = func(o *option.Option, installed bool) { var limactlO *option.Option var fpath, realFinchPath, limactlPath, limaHomePathEnv, wd string var err error + var port int ginkgo.BeforeEach(func() { // Find lima paths. limactl is used to shell into the Finch VM and verify @@ -54,7 +60,7 @@ var testSoci = func(o *option.Option, installed bool) { writeFile(finchConfigFilePath, []byte("cpus: 6\nmemory: 4GiB\nsnapshotters:\n "+ "- soci\nvmType: qemu\nrosetta: false")) command.New(o, virtualMachineRootCmd, "init").WithTimeoutInSeconds(600).Run() - command.New(o, "pull", ffmpegSociImage).WithTimeoutInSeconds(30).Run() + command.New(o, "pull", "--snapshotter=soci", ffmpegSociImage).WithTimeoutInSeconds(30).Run() finchPullMounts := countMounts(limactlO) command.Run(o, "rmi", "-f", ffmpegSociImage) command.New(limactlO, "shell", "finch", @@ -70,7 +76,7 @@ var testSoci = func(o *option.Option, installed bool) { writeFile(finchConfigFilePath, []byte("cpus: 6\nmemory: 4GiB\nsnapshotters:\n "+ "- soci\nvmType: qemu\nrosetta: false")) command.New(o, virtualMachineRootCmd, "init").WithTimeoutInSeconds(600).Run() - command.New(o, "run", ffmpegSociImage).WithTimeoutInSeconds(30).Run() + command.New(o, "run", "--snapshotter=soci", ffmpegSociImage).WithTimeoutInSeconds(30).Run() finchPullMounts := countMounts(limactlO) command.Run(o, "rmi", "-f", ffmpegSociImage) command.New(limactlO, "shell", "finch", @@ -79,6 +85,28 @@ var testSoci = func(o *option.Option, installed bool) { command.Run(o, "rmi", "-f", ffmpegSociImage) gomega.Expect(finchPullMounts).Should(gomega.Equal(nerdctlPullMounts)) }) + ginkgo.It("finch push should work", func() { + resetVM(o, installed) + resetDisks(o, installed) + writeFile(finchConfigFilePath, []byte("cpus: 6\nmemory: 4GiB\nsnapshotters:\n "+ + "- soci\nvmType: qemu\nrosetta: false")) + command.New(o, virtualMachineRootCmd, "init").WithTimeoutInSeconds(600).Run() + port = fnet.GetFreePort() + command.New(o, "run", "-dp", fmt.Sprintf("%d:5000", port), "--name", "registry", registryImage). + WithTimeoutInSeconds(30).Run() + buildContext := ffs.CreateBuildContext(fmt.Sprintf(`FROM %s + CMD ["echo", "bar"] + `, ubuntuImage)) + ginkgo.DeferCleanup(os.RemoveAll, buildContext) + targetTag := fmt.Sprintf(`localhost:%d/test-push-soci:tag`, port) + command.New(o, "build", "-t", targetTag, buildContext).WithTimeoutInSeconds(30).Run() + testSociSpanSize := 2097152 // 2MiB + testSociMinLayerSize := 20971520 // 20MiB + command.New(o, "push", "--insecure-registry", "--snapshotter=soci", fmt.Sprintf("--soci-span-size=%d", testSociSpanSize), + fmt.Sprintf("--soci-min-layer-size=%d", testSociMinLayerSize), targetTag).WithTimeoutInSeconds(30).Run() + indexOutput := command.StdoutStr(limactlO, "shell", "finch", "sudo", "soci", "index", "list") + gomega.Expect(indexOutput).Should(gomega.ContainSubstring(targetTag)) + }) }) } diff --git a/pkg/config/lima_config_applier.go b/pkg/config/lima_config_applier.go index 02d3a3262..2ed4000c1 100644 --- a/pkg/config/lima_config_applier.go +++ b/pkg/config/lima_config_applier.go @@ -18,7 +18,7 @@ import ( ) const ( - sociVersion = "0.3.0" + sociVersion = "0.4.0" sociInstallationProvisioningScriptHeader = "# soci installation and configuring" sociFileNameFormat = "soci-snapshotter-%s-linux-%s.tar.gz" sociDownloadURLFormat = "https://github.com/awslabs/soci-snapshotter/releases/download/v%s/%s"