From f7e017e88ba8be60385f289f3aa73fda26650f27 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Tue, 23 Jan 2024 11:23:51 -0800 Subject: Add a pair of test jobs for clearing old schedbot packages It's now confirmed that tidy() has been creating huge (2.6 GiB) state files that the Puppet agent loads before every agent run, which causes runs to take up to 4 days each and use of all RAM on the server. Cleaning files using find is more straightforward and efficient and avoids this problem. The tidy() functions are disabled here and the cron jobs aren't actually deleting files yet, so a follow-up commit will enable deleting imminently, once testing shows it will work. Follow-up to 59d57245 --- modules/buildsystem/manifests/scheduler.pp | 50 +++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/modules/buildsystem/manifests/scheduler.pp b/modules/buildsystem/manifests/scheduler.pp index 9848f109..cacae1e7 100644 --- a/modules/buildsystem/manifests/scheduler.pp +++ b/modules/buildsystem/manifests/scheduler.pp @@ -25,28 +25,48 @@ class buildsystem::scheduler { } if ($buildsystem::var::scheduler::clean_uploads_logs_age != '0') { - tidy { "${buildsystem::var::scheduler::homedir}/uploads": - type => 'ctime', - recurse => true, - age => $buildsystem::var::scheduler::clean_uploads_logs_age, - rmdirs => true, - } +# tidy { "${buildsystem::var::scheduler::homedir}/uploads": +# type => 'ctime', +# recurse => true, +# age => $buildsystem::var::scheduler::clean_uploads_logs_age, +# rmdirs => true, +# } cron { 'clean uploads logs': user => $login, - # TEMPORARY to test what be deleted before replacing the above - command => sprintf("/usr/bin/find %s/uploads -xdev -type f -mtime +14 >/var/lib/schedbot/clean-uploads-logs-test.log", shellquote(${buildsystem::var::scheduler::homedir})), - hour => '*/4', + # TEMPORARY to test what will be deleted before replacing the above + command => sprintf("/usr/bin/find %s/uploads -xdev -depth -type f -ctime +14 >/var/lib/schedbot/clean-uploads-logs-test.log 2>&1", shellquote($homedir)), + hour => '*/1', minute => '51', } + cron { 'clean uploads dirs': + user => $login, + # TEMPORARY to test what will be deleted before replacing the above + # Remove old empty directories. This will take several passes over + # several weeks to delete a directory hierarchy because it is looking + # at ctime instead of mtime, which resets every time a file/directory + # underneath it is deleted. Directories don't take much space, so this + # shouldn't be a real issue. + command => sprintf("/usr/bin/find %s/uploads -ignore_readdir_race -xdev -depth -type d -ctime +14 -empty >/var/lib/schedbot/clean-uploads-dirs-test.log 2>&1", shellquote($homedir)), + hour => '*/1', + minute => '53', + } } if ($buildsystem::var::scheduler::clean_uploads_packages_age != '0') { - tidy { "${buildsystem::var::scheduler::homedir}/uploads/**/*.rpm": - path => "${buildsystem::var::scheduler::homedir}/uploads", - type => 'ctime', - recurse => true, - age => $buildsystem::var::scheduler::clean_uploads_packages_age, - matches => [ '*.rpm' ], +# tidy { "${buildsystem::var::scheduler::homedir}/uploads/**/*.rpm": +# path => "${buildsystem::var::scheduler::homedir}/uploads", +# type => 'ctime', +# recurse => true, +# age => $buildsystem::var::scheduler::clean_uploads_packages_age, +# matches => [ '*.rpm' ], +# } + + cron { 'clean uploads packages': + user => $login, + # TEMPORARY to test what will be deleted before replacing the above + command => sprintf("/usr/bin/find %s/uploads -xdev -depth -type f -name '*.rpm' -ctime +7 >/var/lib/schedbot/clean-uploads-packages-test.log 2>&1", shellquote($homedir)), + hour => '*/1', + minute => '52', } } } -- cgit v1.2.1