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

fix: run SOCI as a systemd service #667

Merged
merged 2 commits into from
Oct 31, 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
28 changes: 18 additions & 10 deletions pkg/config/lima_config_applier.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,31 @@ const (
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"
sociServiceDownloadURLFormat = "https://raw.githubusercontent.com/awslabs/soci-snapshotter/v%s/soci-snapshotter.service"
sociInstallationScriptFormat = `%s
if [ ! -f /usr/local/bin/soci ]; then
# download soci
set -e
curl --retry 2 --retry-max-time 120 -OL "%s"
# move to usr/local/bin
tar -C /usr/local/bin -xvf %s soci soci-snapshotter-grpc
# changing containerd config
echo " [proxy_plugins.soci]
type = \"snapshot\"
address = \"/run/soci-snapshotter-grpc/soci-snapshotter-grpc.sock\" " >> /etc/containerd/config.toml

# install as a systemd service
curl --retry 2 --retry-max-time 120 -OL "%s"
mv soci-snapshotter.service /usr/local/lib/systemd/system/
ln -s /usr/local/lib/systemd/system/soci-snapshotter.service /etc/systemd/system/multi-user.target.wants/
restorecon -v /usr/local/lib/systemd/system/soci-snapshotter.service
systemctl daemon-reload
sudo systemctl add-requires soci-snapshotter.service containerd.service
systemctl enable --now soci-snapshotter
fi

# changing containerd config
export config=etc/containerd/config.toml
echo " [proxy_plugins.soci]
type = \"snapshot\"
address = \"/run/soci-snapshotter-grpc/soci-snapshotter-grpc.sock\" " >> $config

sudo systemctl restart containerd.service
sudo soci-snapshotter-grpc &> ~/soci-snapshotter-logs &

`
`

userModeEmulationProvisioningScriptHeader = "# cross-arch tools"
)
Expand Down Expand Up @@ -251,7 +257,9 @@ func toggleSoci(limaCfg *limayaml.LimaYAML, enabled bool, isDefault bool, sociVe
idx, hasScript := findSociInstallationScript(limaCfg)
sociFileName := fmt.Sprintf(sociFileNameFormat, sociVersion, system.NewStdLib().Arch())
sociDownloadURL := fmt.Sprintf(sociDownloadURLFormat, sociVersion, sociFileName)
sociInstallationScript := fmt.Sprintf(sociInstallationScriptFormat, sociInstallationProvisioningScriptHeader, sociDownloadURL, sociFileName)
sociServiceDownloadURL := fmt.Sprintf(sociServiceDownloadURLFormat, sociVersion)
sociInstallationScript := fmt.Sprintf(sociInstallationScriptFormat, sociInstallationProvisioningScriptHeader,
sociDownloadURL, sociFileName, sociServiceDownloadURL)
if !hasScript && enabled {
limaCfg.Provision = append(limaCfg.Provision, limayaml.Provision{
Mode: "system",
Expand Down
12 changes: 9 additions & 3 deletions pkg/config/lima_config_applier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,12 @@ fi

sociFileName := fmt.Sprintf(sociFileNameFormat, sociVersion, system.NewStdLib().Arch())
sociDownloadURL := fmt.Sprintf(sociDownloadURLFormat, sociVersion, sociFileName)
sociServiceDownloadURL := fmt.Sprintf(sociServiceDownloadURLFormat, sociVersion)
sociInstallationScript := fmt.Sprintf(sociInstallationScriptFormat,
sociInstallationProvisioningScriptHeader,
sociDownloadURL,
sociFileName)
sociFileName,
sociServiceDownloadURL)

var limaCfg limayaml.LimaYAML
err = yaml.Unmarshal(buf, &limaCfg)
Expand Down Expand Up @@ -286,10 +288,12 @@ fi

sociFileName := fmt.Sprintf(sociFileNameFormat, sociVersion, system.NewStdLib().Arch())
sociDownloadURL := fmt.Sprintf(sociDownloadURLFormat, sociVersion, sociFileName)
sociServiceDownloadURL := fmt.Sprintf(sociServiceDownloadURLFormat, sociVersion)
sociInstallationScript := fmt.Sprintf(sociInstallationScriptFormat,
sociInstallationProvisioningScriptHeader,
sociDownloadURL,
sociFileName)
sociFileName,
sociServiceDownloadURL)

var limaCfg limayaml.LimaYAML
err = yaml.Unmarshal(buf, &limaCfg)
Expand Down Expand Up @@ -348,10 +352,12 @@ fi

sociFileName := fmt.Sprintf(sociFileNameFormat, sociVersion, system.NewStdLib().Arch())
sociDownloadURL := fmt.Sprintf(sociDownloadURLFormat, sociVersion, sociFileName)
sociServiceDownloadURL := fmt.Sprintf(sociServiceDownloadURLFormat, sociVersion)
sociInstallationScript := fmt.Sprintf(sociInstallationScriptFormat,
sociInstallationProvisioningScriptHeader,
sociDownloadURL,
sociFileName)
sociFileName,
sociServiceDownloadURL)

var limaCfg limayaml.LimaYAML
err = yaml.Unmarshal(buf, &limaCfg)
Expand Down
Loading