-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding config option for SOCI installation on VM (#506)
*Description of changes:* Adding snapshotter option in config file and integrating SOCI with Finch **Setting Snapshotters** - Users can set the snapshotters they'd like to use by listing them in the config file as the ```snapshotters``` value. - All listed snapshotters will be installed if they are currently supported with Finch. As of this PR the two that are supported are OverlayFS (the default snapshotter) and SOCI. - The first snapshotter listed will be made the default snapshotter used. Other snapshotters can be used by specifying when running commands (i.e. ```finch --snapshotter={exampleSnapshotter} pull ...```) *Example ```snapshotters``` setting in ```finch.yaml```:* ```yaml snapshotters: -overlayfs -soci ``` This would install SOCI on the user's VM and allow for it to be used when specified in commands, but would keep OverlayFS as the default for commands **To Install SOCI** - SOCI can be setup with minimal configuration by adding ```"- soci"``` to the ```snapshotters``` list in ```finch.yaml``` . - Once the option has been set SOCI will be installed on either ```finch vm init``` or ```finch vm start```. The binary will be downloaded onto the user's VM and the needed settings for SOCI containerd configuration will be appended to ```etc/containerd/config.toml``` in the VM. If SOCI is the first snapshotter listed it will also be set as the default nerdctl snapshotter in the user's VM which would allow the user to pull images with SOCI simply by doing ```finch pull ...``` . **To Stop Using SOCI by default** - ```"- soci"``` should be removed or not be the first snapshotter of the ```snapshotters``` list in ```finch.yaml``` . The user can also make the first snapshotter listed ```"- overlayfs"``` to revert back to the original default used by nerdctl/containerd. **Note:** removing a snapshotter from ```snapshotters``` list will not uninstall the snapshotter from the user's VM. In order to fully uninstall the snapshotter the user must shell into the VM and remove the binaries from ```/usr/local/bin```. Testing done: [ 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: Channing Gaddy <chxgaddy@amazon.com>
- Loading branch information
1 parent
fca1828
commit a2e077b
Showing
8 changed files
with
485 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package vm | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"strings" | ||
|
||
"github.com/onsi/ginkgo/v2" | ||
"github.com/onsi/gomega" | ||
"github.com/runfinch/common-tests/command" | ||
"github.com/runfinch/common-tests/option" | ||
) | ||
|
||
const ( | ||
ffmpegSociImage = "public.ecr.aws/soci-workshop-examples/ffmpeg:latest" | ||
sociMountString = "fuse.rawBridge" | ||
) | ||
|
||
var testSoci = func(o *option.Option, installed bool) { | ||
ginkgo.Describe("SOCI", func() { | ||
var limactlO *option.Option | ||
var limaHomePathEnv string | ||
var wd string | ||
var err error | ||
|
||
ginkgo.BeforeEach(func() { | ||
wd, err = os.Getwd() | ||
gomega.Expect(err).Should(gomega.BeNil()) | ||
limaHomePathEnv = "LIMA_HOME=" + filepath.Join(wd, "../../_output/lima/data") | ||
limactlO, err = option.New([]string{filepath.Join(wd, "../../_output/lima/bin/limactl")}, | ||
option.Env([]string{limaHomePathEnv})) | ||
gomega.Expect(err).Should(gomega.BeNil()) | ||
}) | ||
|
||
ginkgo.It("finch pull should have same mounts as nerdctl pull with SOCI", 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() | ||
command.New(o, "pull", ffmpegSociImage).WithTimeoutInSeconds(30).Run() | ||
finchPullMounts := countMounts(limactlO) | ||
command.Run(o, "rmi", "-f", ffmpegSociImage) | ||
command.New(limactlO, "shell", "finch", | ||
"sudo", "nerdctl", "--snapshotter=soci", "pull", ffmpegSociImage).WithTimeoutInSeconds(30).Run() | ||
nerdctlPullMounts := countMounts(limactlO) | ||
command.Run(o, "rmi", "-f", ffmpegSociImage) | ||
gomega.Expect(finchPullMounts).Should(gomega.Equal(nerdctlPullMounts)) | ||
}) | ||
|
||
ginkgo.It("finch run should have same mounts as nerdctl run with SOCI", 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() | ||
command.New(o, "run", ffmpegSociImage).WithTimeoutInSeconds(30).Run() | ||
finchPullMounts := countMounts(limactlO) | ||
command.Run(o, "rmi", "-f", ffmpegSociImage) | ||
command.New(limactlO, "shell", "finch", | ||
"sudo", "nerdctl", "--snapshotter=soci", "run", ffmpegSociImage).WithTimeoutInSeconds(30).Run() | ||
nerdctlPullMounts := countMounts(limactlO) | ||
command.Run(o, "rmi", "-f", ffmpegSociImage) | ||
gomega.Expect(finchPullMounts).Should(gomega.Equal(nerdctlPullMounts)) | ||
}) | ||
}) | ||
} | ||
|
||
// counts the mounts present in the VM after pulling an image. | ||
func countMounts(limactlO *option.Option) int { | ||
mountOutput := command.StdoutStr(limactlO, "shell", "finch", "mount") | ||
return strings.Count(mountOutput, sociMountString) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.