Skip to content

Commit 3f4daa4

Browse files
authored
Merge pull request #582 from ginglis13/soci-snapshotter-change-service
Soci snapshotter change service
2 parents bcc64f8 + a32b8f2 commit 3f4daa4

File tree

7 files changed

+49
-2
lines changed

7 files changed

+49
-2
lines changed

packages/containerd-1.7/containerd.service

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Description=containerd container runtime
33
Documentation=https://containerd.io
44
After=network-online.target configured.target
55
Wants=network-online.target configured.target
6+
Requires=configure-snapshotter.service
67

78
[Service]
89
Slice=runtime.slice

packages/containerd-2.0/containerd.service

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Description=containerd container runtime
33
Documentation=https://containerd.io
44
After=network-online.target configured.target
55
Wants=network-online.target configured.target
6+
Requires=configure-snapshotter.service
67

78
[Service]
89
Slice=runtime.slice
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[Unit]
2+
Description=Configure Snapshotter
3+
Before=containerd.service
4+
5+
[Service]
6+
Type=oneshot
7+
EnvironmentFile=-/etc/containerd/selected-snapshotter
8+
EnvironmentFile=-/var/cache/containerd/active-snapshotter
9+
# Skip cleanup if either snapshotter variable is empty
10+
ExecCondition=[ -n "${ACTIVE_SNAPSHOTTER}" ]
11+
ExecCondition=[ -n "${SELECTED_SNAPSHOTTER}" ]
12+
# Check if the active snapshotter has changed
13+
ExecCondition=[ "${SELECTED_SNAPSHOTTER}" != "${ACTIVE_SNAPSHOTTER}" ]
14+
# Don't error if the directories don't exist.
15+
ExecStart=-/usr/bin/find /var/lib/soci-snapshotter -mindepth 1 -delete -true
16+
ExecStart=-/usr/bin/find /var/lib/containerd -mindepth 1 -delete -true
17+
ExecStart=/usr/bin/truncate -s0 /var/cache/containerd/active-snapshotter
18+
ExecStart=/usr/bin/echo 'ACTIVE_SNAPSHOTTER="${SELECTED_SNAPSHOTTER}"'
19+
20+
# Set the ACTIVE_SNAPSHOTTER regardless of if conditions are met for cleanup.
21+
# This mitigates the behavior that an unmet ExecCondition will truncate the active-snapshotter EnvironmentFile.
22+
ExecStopPost=/usr/bin/truncate -s0 /var/cache/containerd/active-snapshotter
23+
ExecStopPost=/usr/bin/echo 'ACTIVE_SNAPSHOTTER="${SELECTED_SNAPSHOTTER}"'
24+
25+
RemainAfterExit=true
26+
# Write the active snapshotter.
27+
StandardOutput=file:/var/cache/containerd/active-snapshotter
28+
29+
[Install]
30+
WantedBy=multi-user.target
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
d /var/cache/containerd 0755 - - -
2+
f /var/cache/containerd/active-snapshotter 0644 - - - ACTIVE_SNAPSHOTTER="overlayfs"

packages/release/release.spec

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Source95: release-systemd-networkd.conf
2323
Source96: release-repart-local.conf
2424
Source98: release-systemd-system.conf
2525
Source99: release-ca-certificates-tmpfiles.conf
26+
Source100: release-snapshotter-tmpfiles.conf
2627

2728
# Templates for the settings API.
2829
Source200: motd.template
@@ -35,6 +36,7 @@ Source206: aws-config
3536
Source207: aws-credentials
3637
Source208: modules-load.template
3738
Source209: log4j-hotpatch-enabled
39+
Source210: selected-snapshotter-template
3840

3941
# Core targets, services, and slices.
4042
Source1001: multi-user.target
@@ -81,6 +83,7 @@ Source1064: [email protected]
8183
Source1065: check-kernel-integrity.service
8284
Source1066: check-fips-modules.service
8385
Source1067: [email protected]
86+
Source1068: configure-snapshotter.service
8487

8588
# Mounts that require build-time edits.
8689
Source1080: var-lib-kernel-devel-lower.mount.in
@@ -177,6 +180,7 @@ install -d %{buildroot}%{_cross_tmpfilesdir}
177180
install -p -m 0644 %{S:93} %{buildroot}%{_cross_tmpfilesdir}/release.conf
178181
install -p -m 0644 %{S:99} %{buildroot}%{_cross_tmpfilesdir}/release-ca-certificates.conf
179182
install -p -m 0644 %{S:94} %{buildroot}%{_cross_tmpfilesdir}/release-fips.conf
183+
install -p -m 0644 %{S:100} %{buildroot}%{_cross_tmpfilesdir}/release-snapshotter.conf
180184

181185
install -d %{buildroot}%{_cross_libdir}/systemd/networkd.conf.d
182186
install -p -m 0644 %{S:95} %{buildroot}%{_cross_libdir}/systemd/networkd.conf.d/80-release.conf
@@ -215,7 +219,7 @@ install -p -m 0644 \
215219
%{S:1045} %{S:1046} %{S:1047} %{S:1048} %{S:1049} \
216220
%{S:1050} \
217221
%{S:1060} %{S:1061} %{S:1062} %{S:1063} %{S:1064} \
218-
%{S:1065} %{S:1066} %{S:1067} \
222+
%{S:1065} %{S:1066} %{S:1067} %{S:1068} \
219223
%{buildroot}%{_cross_unitdir}
220224

221225
install -d %{buildroot}%{_cross_unitdir}/systemd-tmpfiles-setup.service.d
@@ -274,6 +278,7 @@ install -p -m 0644 %{S:206} %{buildroot}%{_cross_templatedir}/aws-config
274278
install -p -m 0644 %{S:207} %{buildroot}%{_cross_templatedir}/aws-credentials
275279
install -p -m 0644 %{S:208} %{buildroot}%{_cross_templatedir}/modules-load
276280
install -p -m 0644 %{S:209} %{buildroot}%{_cross_templatedir}/log4j-hotpatch-enabled
281+
install -p -m 0644 %{S:210} %{buildroot}%{_cross_templatedir}/selected-snapshotter
277282

278283
install -d %{buildroot}%{_cross_unitdir}/systemd-udev-trigger.service.d/
279284
install -p -m 0644 %{S:1105} %{buildroot}%{_cross_unitdir}/systemd-udev-trigger.service.d/00-selinux.conf
@@ -360,6 +365,9 @@ ln -s preconfigured.target %{buildroot}%{_cross_unitdir}/default.target
360365
%{_cross_templatedir}/log4j-hotpatch-enabled
361366
%{_cross_udevrulesdir}/61-mount-cdrom.rules
362367
%{_cross_datadir}/logdog.d/logdog.common.conf
368+
%{_cross_unitdir}/configure-snapshotter.service
369+
%{_cross_templatedir}/selected-snapshotter
370+
%{_cross_tmpfilesdir}/release-snapshotter.conf
363371

364372
%files fips
365373
%{_cross_bootconfigdir}/10-fips.conf
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[required-extensions]
2+
container-runtime = "v1"
3+
std = { version = "v1" }
4+
+++
5+
SELECTED_SNAPSHOTTER="{{#if settings.container-runtime.snapshotter}}{{settings.container-runtime.snapshotter}}{{else}}overlayfs{{/if}}"

packages/selinux-policy/rules.cil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@
251251
(allow api_s private_t (files (mutate)))
252252
(allow clock_s measure_t (files (mutate)))
253253
(allow network_s lease_t (files (mutate)))
254-
(allow runtime_s cache_t (files (mutate)))
254+
(allow trusted_s cache_t (files (mutate)))
255255

256256
; Other components should not be permitted to modify these files,
257257
; or to manage mounts for these directories.

0 commit comments

Comments
 (0)