From 0e89f115a39c655635069ec4ac6ce2d66f95d7b7 Mon Sep 17 00:00:00 2001 From: Khai Do Date: Tue, 14 Jun 2016 09:42:44 -0700 Subject: [PATCH] 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 --- modules/openstack_project/manifests/gerrit.pp | 5 ++++- modules/openstack_project/manifests/git_backend.pp | 10 +++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/modules/openstack_project/manifests/gerrit.pp b/modules/openstack_project/manifests/gerrit.pp index af41884579..d7d8cb556c 100644 --- a/modules/openstack_project/manifests/gerrit.pp +++ b/modules/openstack_project/manifests/gerrit.pp @@ -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', } } diff --git a/modules/openstack_project/manifests/git_backend.pp b/modules/openstack_project/manifests/git_backend.pp index 9b2b17aaf2..8cf1a13f3d 100644 --- a/modules/openstack_project/manifests/git_backend.pp +++ b/modules/openstack_project/manifests/git_backend.pp @@ -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'], }