Skip to content

Commit

Permalink
feat: support push with SOCI (runfinch#578)
Browse files Browse the repository at this point in the history
SOCI push docs and tests. Marking as feat to officially support the
feature and bump minor version.



- [ X ] I've reviewed the guidance in CONTRIBUTING.md


#### License Acceptance

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.

Signed-off-by: Ziwen Ning <[email protected]>
  • Loading branch information
ningziwen authored and ginglis13 committed Sep 27, 2023
1 parent 73c1ada commit a63ff3a
Show file tree
Hide file tree
Showing 3 changed files with 36 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
32 changes: 30 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,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))
})
})
}

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 a63ff3a

Please sign in to comment.