From 6b37f9a290a93207c382cfd0fc8b7e41a4152955 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Wed, 1 Mar 2023 11:21:42 -0800 Subject: [PATCH] puppet: Run delete-old-unclaimed-attachments in archive cron file. After reflecting a bit on the last commit, I think it's substantially easier to understand what's happening for these two tasks to be defined in the same file, because we want the timing to be different to avoid potential races. --- puppet/zulip/files/cron.d/archive-messages | 3 +++ .../zulip/files/cron.d/delete-old-unclaimed-attachments | 6 ------ puppet/zulip/manifests/app_frontend_once.pp | 8 -------- 3 files changed, 3 insertions(+), 14 deletions(-) delete mode 100644 puppet/zulip/files/cron.d/delete-old-unclaimed-attachments diff --git a/puppet/zulip/files/cron.d/archive-messages b/puppet/zulip/files/cron.d/archive-messages index 59e17f08a9..50c77d42c7 100644 --- a/puppet/zulip/files/cron.d/archive-messages +++ b/puppet/zulip/files/cron.d/archive-messages @@ -5,3 +5,6 @@ USER=zulip # Daily cron job for retention policy - archives existing messages based on the policy # and cleans expired entries from the archive. 0 6 * * * zulip /home/zulip/deployments/current/manage.py archive_messages >/dev/null +# Daily cron job for cleaning up old, unclaimed attachments and their corresponding files. +# Ideally should not run at the same time as the previous job, to avoid races. +0 5 * * * zulip /home/zulip/deployments/current/manage.py delete_old_unclaimed_attachments -f >/dev/null diff --git a/puppet/zulip/files/cron.d/delete-old-unclaimed-attachments b/puppet/zulip/files/cron.d/delete-old-unclaimed-attachments deleted file mode 100644 index 7400242460..0000000000 --- a/puppet/zulip/files/cron.d/delete-old-unclaimed-attachments +++ /dev/null @@ -1,6 +0,0 @@ -SHELL=/bin/bash -PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin -USER=zulip - -# Daily cronjob for cleaning up old, unclaimed attachments and their corresponding files. -0 6 * * * zulip /home/zulip/deployments/current/manage.py delete_old_unclaimed_attachments -f >/dev/null diff --git a/puppet/zulip/manifests/app_frontend_once.pp b/puppet/zulip/manifests/app_frontend_once.pp index 4d3ba3bb9e..148015d15e 100644 --- a/puppet/zulip/manifests/app_frontend_once.pp +++ b/puppet/zulip/manifests/app_frontend_once.pp @@ -67,14 +67,6 @@ class zulip::app_frontend_once { source => 'puppet:///modules/zulip/cron.d/archive-messages', } - file { '/etc/cron.d/delete-old-unclaimed-attachments': - ensure => file, - owner => 'root', - group => 'root', - mode => '0644', - source => 'puppet:///modules/zulip/cron.d/delete-old-unclaimed-attachments', - } - file { '/etc/cron.d/clearsessions': ensure => file, owner => 'root',