Skip to content

Commit 24fd649

Browse files
authored
fix: run SOCI as a systemd service (runfinch#667)
Issue #, if available: runfinch#660 and probably runfinch#661 *Description of changes:* - Run SOCI as a systemd service - Ported from runfinch#649, which still needs more time before we can merge it *Testing done:* - e2e/unit tests - [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: Justin Alvarez <[email protected]>
1 parent 4b1b0a2 commit 24fd649

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

Diff for: pkg/config/lima_config_applier.go

+18-10
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,31 @@ const (
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"
25+
sociServiceDownloadURLFormat = "https://raw.githubusercontent.com/awslabs/soci-snapshotter/v%s/soci-snapshotter.service"
2526
sociInstallationScriptFormat = `%s
2627
if [ ! -f /usr/local/bin/soci ]; then
2728
# download soci
2829
set -e
2930
curl --retry 2 --retry-max-time 120 -OL "%s"
3031
# move to usr/local/bin
3132
tar -C /usr/local/bin -xvf %s soci soci-snapshotter-grpc
33+
# changing containerd config
34+
echo " [proxy_plugins.soci]
35+
type = \"snapshot\"
36+
address = \"/run/soci-snapshotter-grpc/soci-snapshotter-grpc.sock\" " >> /etc/containerd/config.toml
37+
38+
# install as a systemd service
39+
curl --retry 2 --retry-max-time 120 -OL "%s"
40+
mv soci-snapshotter.service /usr/local/lib/systemd/system/
41+
ln -s /usr/local/lib/systemd/system/soci-snapshotter.service /etc/systemd/system/multi-user.target.wants/
42+
restorecon -v /usr/local/lib/systemd/system/soci-snapshotter.service
43+
systemctl daemon-reload
44+
sudo systemctl add-requires soci-snapshotter.service containerd.service
45+
systemctl enable --now soci-snapshotter
3246
fi
3347
34-
# changing containerd config
35-
export config=etc/containerd/config.toml
36-
echo " [proxy_plugins.soci]
37-
type = \"snapshot\"
38-
address = \"/run/soci-snapshotter-grpc/soci-snapshotter-grpc.sock\" " >> $config
39-
4048
sudo systemctl restart containerd.service
41-
sudo soci-snapshotter-grpc &> ~/soci-snapshotter-logs &
42-
43-
`
49+
`
4450

4551
userModeEmulationProvisioningScriptHeader = "# cross-arch tools"
4652
)
@@ -251,7 +257,9 @@ func toggleSoci(limaCfg *limayaml.LimaYAML, enabled bool, isDefault bool, sociVe
251257
idx, hasScript := findSociInstallationScript(limaCfg)
252258
sociFileName := fmt.Sprintf(sociFileNameFormat, sociVersion, system.NewStdLib().Arch())
253259
sociDownloadURL := fmt.Sprintf(sociDownloadURLFormat, sociVersion, sociFileName)
254-
sociInstallationScript := fmt.Sprintf(sociInstallationScriptFormat, sociInstallationProvisioningScriptHeader, sociDownloadURL, sociFileName)
260+
sociServiceDownloadURL := fmt.Sprintf(sociServiceDownloadURLFormat, sociVersion)
261+
sociInstallationScript := fmt.Sprintf(sociInstallationScriptFormat, sociInstallationProvisioningScriptHeader,
262+
sociDownloadURL, sociFileName, sociServiceDownloadURL)
255263
if !hasScript && enabled {
256264
limaCfg.Provision = append(limaCfg.Provision, limayaml.Provision{
257265
Mode: "system",

Diff for: pkg/config/lima_config_applier_test.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,12 @@ fi
116116

117117
sociFileName := fmt.Sprintf(sociFileNameFormat, sociVersion, system.NewStdLib().Arch())
118118
sociDownloadURL := fmt.Sprintf(sociDownloadURLFormat, sociVersion, sociFileName)
119+
sociServiceDownloadURL := fmt.Sprintf(sociServiceDownloadURLFormat, sociVersion)
119120
sociInstallationScript := fmt.Sprintf(sociInstallationScriptFormat,
120121
sociInstallationProvisioningScriptHeader,
121122
sociDownloadURL,
122-
sociFileName)
123+
sociFileName,
124+
sociServiceDownloadURL)
123125

124126
var limaCfg limayaml.LimaYAML
125127
err = yaml.Unmarshal(buf, &limaCfg)
@@ -286,10 +288,12 @@ fi
286288

287289
sociFileName := fmt.Sprintf(sociFileNameFormat, sociVersion, system.NewStdLib().Arch())
288290
sociDownloadURL := fmt.Sprintf(sociDownloadURLFormat, sociVersion, sociFileName)
291+
sociServiceDownloadURL := fmt.Sprintf(sociServiceDownloadURLFormat, sociVersion)
289292
sociInstallationScript := fmt.Sprintf(sociInstallationScriptFormat,
290293
sociInstallationProvisioningScriptHeader,
291294
sociDownloadURL,
292-
sociFileName)
295+
sociFileName,
296+
sociServiceDownloadURL)
293297

294298
var limaCfg limayaml.LimaYAML
295299
err = yaml.Unmarshal(buf, &limaCfg)
@@ -348,10 +352,12 @@ fi
348352

349353
sociFileName := fmt.Sprintf(sociFileNameFormat, sociVersion, system.NewStdLib().Arch())
350354
sociDownloadURL := fmt.Sprintf(sociDownloadURLFormat, sociVersion, sociFileName)
355+
sociServiceDownloadURL := fmt.Sprintf(sociServiceDownloadURLFormat, sociVersion)
351356
sociInstallationScript := fmt.Sprintf(sociInstallationScriptFormat,
352357
sociInstallationProvisioningScriptHeader,
353358
sociDownloadURL,
354-
sociFileName)
359+
sociFileName,
360+
sociServiceDownloadURL)
355361

356362
var limaCfg limayaml.LimaYAML
357363
err = yaml.Unmarshal(buf, &limaCfg)

0 commit comments

Comments
 (0)