Skip to content

Commit 69721b7

Browse files
authored
feat: support push with SOCI (#578)
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]>
1 parent f70314e commit 69721b7

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

docs/soci.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# Lazy-pulling using SOCI Snapshotter
22

3-
| :bird: Requirement | finch >= 0.8.0 |
4-
|--------------------|----------------|
3+
| :bird: Requirement for pull and run | finch >= 0.8.0 |
4+
|-----------------------------------|----------------|
5+
6+
| :bird: Requirement for push with SOCI | finch >= 0.9.0 |
7+
|---------------------------------------|----------------|
58

69
## Using SOCI
710

e2e/vm/soci_test.go

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package vm
55

66
import (
7+
"fmt"
78
"os"
89
"os/exec"
910
"path/filepath"
@@ -12,11 +13,15 @@ import (
1213
"github.com/onsi/ginkgo/v2"
1314
"github.com/onsi/gomega"
1415
"github.com/runfinch/common-tests/command"
16+
"github.com/runfinch/common-tests/ffs"
17+
"github.com/runfinch/common-tests/fnet"
1518
"github.com/runfinch/common-tests/option"
1619
)
1720

1821
const (
1922
ffmpegSociImage = "public.ecr.aws/soci-workshop-examples/ffmpeg:latest"
23+
registryImage = "public.ecr.aws/docker/library/registry:latest"
24+
ubuntuImage = "public.ecr.aws/docker/library/ubuntu:23.10"
2025
sociMountString = "fuse.rawBridge"
2126
)
2227

@@ -25,6 +30,7 @@ var testSoci = func(o *option.Option, installed bool) {
2530
var limactlO *option.Option
2631
var fpath, realFinchPath, limactlPath, limaHomePathEnv, wd string
2732
var err error
33+
var port int
2834

2935
ginkgo.BeforeEach(func() {
3036
// 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) {
5460
writeFile(finchConfigFilePath, []byte("cpus: 6\nmemory: 4GiB\nsnapshotters:\n "+
5561
"- soci\nvmType: qemu\nrosetta: false"))
5662
command.New(o, virtualMachineRootCmd, "init").WithTimeoutInSeconds(600).Run()
57-
command.New(o, "pull", ffmpegSociImage).WithTimeoutInSeconds(30).Run()
63+
command.New(o, "pull", "--snapshotter=soci", ffmpegSociImage).WithTimeoutInSeconds(30).Run()
5864
finchPullMounts := countMounts(limactlO)
5965
command.Run(o, "rmi", "-f", ffmpegSociImage)
6066
command.New(limactlO, "shell", "finch",
@@ -70,7 +76,7 @@ var testSoci = func(o *option.Option, installed bool) {
7076
writeFile(finchConfigFilePath, []byte("cpus: 6\nmemory: 4GiB\nsnapshotters:\n "+
7177
"- soci\nvmType: qemu\nrosetta: false"))
7278
command.New(o, virtualMachineRootCmd, "init").WithTimeoutInSeconds(600).Run()
73-
command.New(o, "run", ffmpegSociImage).WithTimeoutInSeconds(30).Run()
79+
command.New(o, "run", "--snapshotter=soci", ffmpegSociImage).WithTimeoutInSeconds(30).Run()
7480
finchPullMounts := countMounts(limactlO)
7581
command.Run(o, "rmi", "-f", ffmpegSociImage)
7682
command.New(limactlO, "shell", "finch",
@@ -79,6 +85,28 @@ var testSoci = func(o *option.Option, installed bool) {
7985
command.Run(o, "rmi", "-f", ffmpegSociImage)
8086
gomega.Expect(finchPullMounts).Should(gomega.Equal(nerdctlPullMounts))
8187
})
88+
ginkgo.It("finch push should work", func() {
89+
resetVM(o, installed)
90+
resetDisks(o, installed)
91+
writeFile(finchConfigFilePath, []byte("cpus: 6\nmemory: 4GiB\nsnapshotters:\n "+
92+
"- soci\nvmType: qemu\nrosetta: false"))
93+
command.New(o, virtualMachineRootCmd, "init").WithTimeoutInSeconds(600).Run()
94+
port = fnet.GetFreePort()
95+
command.New(o, "run", "-dp", fmt.Sprintf("%d:5000", port), "--name", "registry", registryImage).
96+
WithTimeoutInSeconds(30).Run()
97+
buildContext := ffs.CreateBuildContext(fmt.Sprintf(`FROM %s
98+
CMD ["echo", "bar"]
99+
`, ubuntuImage))
100+
ginkgo.DeferCleanup(os.RemoveAll, buildContext)
101+
targetTag := fmt.Sprintf(`localhost:%d/test-push-soci:tag`, port)
102+
command.New(o, "build", "-t", targetTag, buildContext).WithTimeoutInSeconds(30).Run()
103+
testSociSpanSize := 2097152 // 2MiB
104+
testSociMinLayerSize := 20971520 // 20MiB
105+
command.New(o, "push", "--insecure-registry", "--snapshotter=soci", fmt.Sprintf("--soci-span-size=%d", testSociSpanSize),
106+
fmt.Sprintf("--soci-min-layer-size=%d", testSociMinLayerSize), targetTag).WithTimeoutInSeconds(30).Run()
107+
indexOutput := command.StdoutStr(limactlO, "shell", "finch", "sudo", "soci", "index", "list")
108+
gomega.Expect(indexOutput).Should(gomega.ContainSubstring(targetTag))
109+
})
82110
})
83111
}
84112

pkg/config/lima_config_applier.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
)
1919

2020
const (
21-
sociVersion = "0.3.0"
21+
sociVersion = "0.4.0"
2222
sociInstallationProvisioningScriptHeader = "# soci installation and configuring"
2323
sociFileNameFormat = "soci-snapshotter-%s-linux-%s.tar.gz"
2424
sociDownloadURLFormat = "https://github.com/awslabs/soci-snapshotter/releases/download/v%s/%s"

0 commit comments

Comments
 (0)