diff --git a/.github/workflows/apt.yml b/.github/workflows/apt.yml index 3f320f969..45b997b2b 100644 --- a/.github/workflows/apt.yml +++ b/.github/workflows/apt.yml @@ -253,6 +253,7 @@ jobs: - "update-without-data-lost.sh v6 v7" - "update-without-data-lost.sh v7 v6" - "obsolete-plugins.sh" + - "tmpfiles.sh" include: - label: Debian bookworm amd64 rake-job: debian-bookworm diff --git a/.github/workflows/yum.yml b/.github/workflows/yum.yml index 1c65c4d55..2cae27ecd 100644 --- a/.github/workflows/yum.yml +++ b/.github/workflows/yum.yml @@ -310,6 +310,7 @@ jobs: - "update-without-data-lost.sh v6 v7" - "update-without-data-lost.sh v7 v6" - "obsolete-plugins.sh" + - "tmpfiles.sh" include: ${{ fromJSON(needs.define-matrix.outputs.matrix).include }} exclude: - label: Amazon Linux 2023 x86_64 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..a2fd5e5c5 --- /dev/null +++ b/fluent-package/yum/systemd-test/tmpfiles.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +set -exu + +. $(dirname $0)/common.sh + +# Display unit info for debug +sudo systemctl cat systemd-tmpfiles-clean.service +sudo systemctl cat systemd-tmpfiles-clean.timer + +# Install the built package +install_current + +# 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-*