diff --git a/.github/workflows/apt.yml b/.github/workflows/apt.yml index 20bb244a5..48d322253 100644 --- a/.github/workflows/apt.yml +++ b/.github/workflows/apt.yml @@ -213,6 +213,7 @@ jobs: - "install-newly.sh local" - "install-newly.sh v5" - "install-newly.sh lts" + - "tmpfiles.sh" include: - label: Debian bullseye amd64 rake-job: debian-bullseye diff --git a/.github/workflows/yum.yml b/.github/workflows/yum.yml index 0b94691e1..e0deb989d 100644 --- a/.github/workflows/yum.yml +++ b/.github/workflows/yum.yml @@ -226,6 +226,7 @@ jobs: - "install-newly.sh local" - "install-newly.sh v5" - "install-newly.sh lts" + - "tmpfiles.sh" include: - label: RockyLinux 8 x86_64 rake-job: rockylinux-8 diff --git a/fluent-package/apt/systemd-test/tmpfiles.sh b/fluent-package/apt/systemd-test/tmpfiles.sh new file mode 100755 index 000000000..2784a7200 --- /dev/null +++ b/fluent-package/apt/systemd-test/tmpfiles.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +set -exu + +. $(dirname $0)/../commonvar.sh + +# Display unit info for debug +sudo systemctl cat systemd-tmpfiles-clean.service +sudo systemctl cat systemd-tmpfiles-clean.timer + +# Install the built package +sudo apt install -V -y \ + /host/${distribution}/pool/${code_name}/${channel}/*/*/fluent-package_*_${architecture}.deb + +# Wait all processes to start +systemctl status --no-pager fluentd +sleep 3 + +# Test: the files under /tmp/ exist and not be cleaned up by default +ls -d /tmp/fluent +ls -d /tmp/fluentd-lock-* +sudo systemd-tmpfiles --clean +ls -d /tmp/fluent +ls -d /tmp/fluentd-lock-* + +# Make timestamps old +touch -d "2 months ago" /tmp/fluentd +touch -d "2 months ago" /tmp/fluentd-lock-* + +# Test: the files under /tmp/ not be cleaned up even if they are old +sudo systemd-tmpfiles --clean +ls -d /tmp/fluent +ls -d /tmp/fluentd-lock-* diff --git a/fluent-package/templates/usr/lib/tmpfiles.d/fluentd.conf b/fluent-package/templates/usr/lib/tmpfiles.d/fluentd.conf index 016b56a18..2c3b2906a 100644 --- a/fluent-package/templates/usr/lib/tmpfiles.d/fluentd.conf +++ b/fluent-package/templates/usr/lib/tmpfiles.d/fluentd.conf @@ -19,3 +19,4 @@ d /var/run/<%= package_dir %> 0755 <%= service_name %> <%= service_name %> - - # Exclude <%= service_name %> x /tmp/<%= package_dir %> +X /tmp/fluentd-lock-* diff --git a/fluent-package/yum/systemd-test/tmpfiles.sh b/fluent-package/yum/systemd-test/tmpfiles.sh new file mode 100755 index 000000000..1ec79d268 --- /dev/null +++ b/fluent-package/yum/systemd-test/tmpfiles.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +set -exu + +. $(dirname $0)/commonvar.sh + +# Display unit info for debug +sudo systemctl cat systemd-tmpfiles-clean.service +sudo systemctl cat systemd-tmpfiles-clean.timer + +# Install the built package +sudo $DNF install -y \ + /host/${distribution}/${DISTRIBUTION_VERSION}/x86_64/Packages/fluent-package-[0-9]*.rpm + +# Wait all processes to start +(! systemctl status --no-pager fluentd) +sudo systemctl enable --now fluentd +systemctl status --no-pager fluentd +sleep 3 + +# Test: the files under /tmp/ exist and not be cleaned up by default +ls -d /tmp/fluent +ls -d /tmp/fluentd-lock-* +sudo systemd-tmpfiles --clean +ls -d /tmp/fluent +ls -d /tmp/fluentd-lock-* + +# Make timestamps old +touch -d "2 months ago" /tmp/fluentd +touch -d "2 months ago" /tmp/fluentd-lock-* + +# Test: the files under /tmp/ not be cleaned up even if they are old +sudo systemd-tmpfiles --clean +ls -d /tmp/fluent +ls -d /tmp/fluentd-lock-*