Skip to content

Commit

Permalink
feat: support push with SOCI
Browse files Browse the repository at this point in the history
Signed-off-by: Ziwen Ning <[email protected]>
  • Loading branch information
ningziwen committed Sep 25, 2023
1 parent f70314e commit c8f5f40
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
7 changes: 5 additions & 2 deletions docs/soci.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
28 changes: 26 additions & 2 deletions e2e/vm/soci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package vm

import (
"fmt"
"os"
"os/exec"
"path/filepath"
Expand All @@ -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"
)

Expand All @@ -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
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -79,6 +85,24 @@ 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()
command.New(o, "push", "--insecure-registry", "--snapshotter=soci", "--soci-span-size=2097152",
"--soci-min-layer-size=20971520", targetTag).WithTimeoutInSeconds(30).Run()
})
})
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/config/lima_config_applier.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit c8f5f40

Please sign in to comment.