allow override to run git gc instead of repack on repos

Allow running git gc instead of repack on all repos.  Testing[1]
indicates that gc-ing reduces repo size and helps maintain better
performance for apps that host the repos.

[1] http://lists.openstack.org/pipermail/openstack-infra/2016-June/004403.html

Change-Id: I7a5364a07c3e07ffc9a053a73fab0c16861fc1c5
This commit is contained in:
Khai Do 2016-06-27 16:25:37 -07:00
parent 1eefbbb653
commit f4295f686f
1 changed files with 17 additions and 3 deletions

View File

@ -3,25 +3,39 @@
class gerrit::cron (
$replicate_local = true,
$replicate_path = '/opt/lib/git',
# run `git repack` on gerrit repos by default, set true run `git gc` instead
$gitgc_repos = false,
) {
if $gitgc_repos {
$git_cmd = 'gc'
} else {
$git_cmd = 'repack -afd'
}
cron { 'gerrit_repack':
ensure => absent,
}
cron { 'optimize_git_repo':
user => 'gerrit2',
weekday => '0',
hour => '4',
minute => '7',
command => 'find /home/gerrit2/review_site/git/ -type d -name "*.git" -print -exec git --git-dir="{}" repack -afd \;',
command => "find /home/gerrit2/review_site/git/ -type d -name \"*.git\" -print -exec git --git-dir=\"{}\" ${git_cmd} \\;",
environment => 'PATH=/usr/bin:/bin:/usr/sbin:/sbin',
}
# if local replication is enabled, repack this mirror as well
# if local replication is enabled, optimize this mirror as well
if $replicate_local {
cron { 'mirror_repack_local':
ensure => absent,
}
cron { 'optimize_git_repo_local_replication':
user => 'gerrit2',
weekday => '0',
hour => '4',
minute => '17',
command => "find ${replicate_path} -type d -name \"*.git\" -print -exec git --git-dir=\"{}\" repack -afd \\;",
command => "find ${replicate_path} -type d -name \"*.git\" -print -exec git --git-dir=\"{}\" ${git_cmd} \\;",
environment => 'PATH=/usr/bin:/bin:/usr/sbin:/sbin',
}
}