Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support push with SOCI #578

Merged
merged 1 commit into from
Sep 25, 2023
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
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()
ginglis13 marked this conversation as resolved.
Show resolved Hide resolved
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
Loading