run git gc instead of repack for git repos

Run 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.

remove git pack-refs because a git gc enables packRefs by default[2]

[1] http://lists.openstack.org/pipermail/openstack-infra/2016-June/004403.html
[2] https://git-scm.com/docs/git-gc

Change-Id: I4e171b17a7b4107c992d0e3cc0e7bff3d9599526
This commit is contained in:
Khai Do 2016-06-14 09:42:44 -07:00
parent a8481587e0
commit 0e89f115a3
2 changed files with 11 additions and 4 deletions

View File

@ -415,11 +415,14 @@ class openstack_project::gerrit (
require => Class['::gerrit'],
}
cron { 'mirror_repack':
ensure => absent,
}
cron { 'mirror_gitgc':
user => 'gerrit2',
weekday => '0',
hour => '4',
minute => '7',
command => "find ${local_git_dir} -type d -name \"*.git\" -print -exec git --git-dir=\"{}\" repack -afd \\;",
command => "find ${local_git_dir} -type d -name \"*.git\" -print -exec git --git-dir=\"{}\" gc \\;",
environment => 'PATH=/usr/bin:/bin:/usr/sbin:/sbin',
}
}

View File

@ -118,10 +118,14 @@ class openstack_project::git_backend (
}
cron { 'mirror_repack':
ensure => absent,
}
cron { 'mirror_gitgc':
user => 'cgit',
hour => '4',
minute => '7',
command => 'find /var/lib/git/ -not -path /var/lib/git/zuul -type d -name "*.git" -print -exec git --git-dir="{}" repack -afd \; -exec git --git-dir="{}" pack-refs --all \;',
command => 'find /var/lib/git/ -not -path /var/lib/git/zuul -type d -name "*.git" -print -exec git --git-dir="{}" gc \;',
environment => 'PATH=/usr/bin:/bin:/usr/sbin:/sbin',
require => User['cgit'],
}
@ -202,12 +206,12 @@ class openstack_project::git_backend (
ensure => absent,
}
cron { 'mirror_repack_zuul':
cron { 'mirror_gitgc_zuul':
user => 'zuul',
weekday => '0',
hour => '4',
minute => '7',
command => 'find /var/lib/git/zuul -type d -name "*.git" -print -exec git --git-dir="{}" repack -afd \; -exec git --git-dir="{}" pack-refs --all \;',
command => 'find /var/lib/git/zuul -type d -name "*.git" -print -exec git --git-dir="{}" git gc \;',
environment => 'PATH=/usr/bin:/bin:/usr/sbin:/sbin',
require => User['zuul'],
}