aboutsummaryrefslogtreecommitdiffstats
path: root/modules/buildsystem/manifests/scheduler.pp
blob: cacae1e74e929aeae056bf23e835d5aef8a97805 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
class buildsystem::scheduler {
        # until ulri is splitted from main iurt rpm
        include buildsystem::iurt::packages
        include buildsystem::iurt::upload
        include buildsystem::var::scheduler

        $login = $buildsystem::var::scheduler::login
        $homedir = $buildsystem::var::scheduler::homedir
        $logdir = $buildsystem::var::scheduler::logdir

        buildsystem::sshuser { $login:
            homedir => $homedir,
        }

        file { $logdir:
            ensure => directory,
            mode   => '0755',
            owner  => $login,
        }

        cron { 'dispatch jobs':
            user    => $login,
            command => "EMI_LOG_FILE=${logdir}/emi.log ULRI_LOG_FILE=${logdir}/ulri.log ulri; EMI_LOG_FILE=${logdir}/emi.log emi",
            minute  => '*',
        }

        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,
#            }

            cron { 'clean uploads logs':
                user    => $login,
                # 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' ],
#            }

            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',
            }
        }
}