From ddeb9592c9e5f5d3db6f5f483aebeff18ffc378f Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Tue, 20 Dec 2022 10:24:25 +0100 Subject: [PATCH] Add podman-clean-transient.service service This is a unit that can be enabled when using transient store mode to clean up potential leftovers from previous boots. All it does is run "podman system prune --external" once each boot. Signed-off-by: Alexander Larsson --- Makefile | 4 +++- .../system/podman-clean-transient.service.in | 21 +++++++++++++++++++ podman.spec.rpkg | 1 + 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 contrib/systemd/system/podman-clean-transient.service.in diff --git a/Makefile b/Makefile index ecf642fa37..a88fdd4044 100644 --- a/Makefile +++ b/Makefile @@ -871,7 +871,8 @@ ifneq (,$(findstring systemd,$(BUILDTAGS))) PODMAN_UNIT_FILES = contrib/systemd/auto-update/podman-auto-update.service \ contrib/systemd/system/podman.service \ contrib/systemd/system/podman-restart.service \ - contrib/systemd/system/podman-kube@.service + contrib/systemd/system/podman-kube@.service \ + contrib/systemd/system/podman-clean-transient.service %.service: %.service.in sed -e 's;@@PODMAN@@;$(BINDIR)/podman;g' $< >$@.tmp.$$ \ @@ -893,6 +894,7 @@ install.systemd: $(PODMAN_UNIT_FILES) install ${SELINUXOPT} -m 644 contrib/systemd/system/podman.service ${DESTDIR}${SYSTEMDDIR}/podman.service install ${SELINUXOPT} -m 644 contrib/systemd/system/podman-restart.service ${DESTDIR}${SYSTEMDDIR}/podman-restart.service install ${SELINUXOPT} -m 644 contrib/systemd/system/podman-kube@.service ${DESTDIR}${SYSTEMDDIR}/podman-kube@.service + install ${SELINUXOPT} -m 644 contrib/systemd/system/podman-clean-transient.service ${DESTDIR}${SYSTEMDDIR}/podman-clean-transient.service rm -f $(PODMAN_UNIT_FILES) else install.systemd: diff --git a/contrib/systemd/system/podman-clean-transient.service.in b/contrib/systemd/system/podman-clean-transient.service.in new file mode 100644 index 0000000000..88f5ec823b --- /dev/null +++ b/contrib/systemd/system/podman-clean-transient.service.in @@ -0,0 +1,21 @@ +# This service runs once each boot to remove potential leftover +# container state from previous boots. + +# This is needed when using transient storage mode in podman where the +# database and other configs are stored in tmpfs, but some other files +# are not. If we don't run this after an unclean boot then there may +# be some leftover files that grow over time. + +[Unit] +Description=Clean up podman transient data +RequiresMountsFor=%t/containers +Documentation=man:podman-system-prune(1) +Requires=boot-complete.target +After=local-fs.target boot-complete.target + +[Service] +Type=oneshot +ExecStart=@@PODMAN@@ system prune --external + +[Install] +WantedBy=default.target diff --git a/podman.spec.rpkg b/podman.spec.rpkg index f984d79c2a..36571ef33c 100644 --- a/podman.spec.rpkg +++ b/podman.spec.rpkg @@ -252,6 +252,7 @@ fi %{_unitdir}/%{name}.socket %{_unitdir}/%{name}-restart.service %{_unitdir}/%{name}-kube@.service +%{_unitdir}/%{name}-clean-transient.service %{_userunitdir}/%{name}-auto-update.service %{_userunitdir}/%{name}-auto-update.timer %{_userunitdir}/%{name}.service