From 97ff86e07cdfce1915d574772f80e21263ad43e6 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 3 Jun 2015 11:50:08 +0200 Subject: Move repository when project is removed Ths commit does next: * When we remove project we move repository to path+deleted.git * Then we schedule removal of path+deleted with sidekiq * If repository move failed we abort project removal This should help us with NFS issue when project get removed but repository stayed. The full explanation of problem is below: * rm -rf project.git * rm -rf removes project.git/objects/foo * NFS server renames foo to foo.nfsXXXX because some NFS client (think * Unicorn) still has the file open * rm -rf exits, but project.git/objects/foo.nfsXXX still exists * Unicorn closes the file, the NFS client closes the file (foo), and the * NFS server removes foo.nfsXXX * the directory project.git/objects/ still exists => problem So now we move repository and even if repository removal failed Repository directory is moved so no bugs with project removed but repository directory taken. User still able to create new project with same name. From administrator perspective you can easily find stalled repositories by searching `*+deleted.git` Signed-off-by: Dmitriy Zaporozhets --- lib/gitlab/backend/shell.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/gitlab/backend/shell.rb b/lib/gitlab/backend/shell.rb index 530f9d93de4..172d4902add 100644 --- a/lib/gitlab/backend/shell.rb +++ b/lib/gitlab/backend/shell.rb @@ -244,6 +244,16 @@ module Gitlab end end + # Check if such directory exists in repositories. + # + # Usage: + # exists?('gitlab') + # exists?('gitlab/cookies.git') + # + def exists?(dir_name) + File.exists?(full_path(dir_name)) + end + protected def gitlab_shell_path @@ -264,10 +274,6 @@ module Gitlab File.join(repos_path, dir_name) end - def exists?(dir_name) - File.exists?(full_path(dir_name)) - end - def gitlab_shell_projects_path File.join(gitlab_shell_path, 'bin', 'gitlab-projects') end -- cgit v1.2.3