Skip to content

Commit 63c74ed

Browse files
author
Yorick Peterse
committed
Merge branch 'ionice-mv' into 'master'
Set a low IO priority for storage moves to lower performance impact See merge request !92
2 parents 894d8c1 + a878cf1 commit 63c74ed

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
v3.6.1
2+
- Set a low IO priority for storage moves to lower performance impact
3+
14
v3.6.0
25
- Added full support for `git-lfs-authenticate` to properly handle LFS requests and pass them on to Workhorse
36

lib/gitlab_projects.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,17 @@ def mv_storage
316316

317317
if wait_for_pushes
318318
$logger.info "Syncing project #{@project_name} from <#{full_path}> to <#{new_full_path}>."
319-
system(*%W(rsync -a --delete #{source_path} #{new_full_path}))
319+
320+
# Set a low IO priority with ionice to not choke the server on moves
321+
rsync_path = 'ionice -c2 -n7 rsync'
322+
result = system(*%W(#{rsync_path} -a --delete --rsync-path="#{rsync_path}" #{source_path} #{new_full_path}))
323+
324+
unless result
325+
# If the command fails with `ionice` (maybe because we're on a OS X
326+
# development machine), try again without `ionice`.
327+
rsync_path = 'rsync'
328+
system(*%W(#{rsync_path} -a --delete --rsync-path="#{rsync_path}" #{source_path} #{new_full_path}))
329+
end
320330
else
321331
$logger.error "mv-storage failed: source path <#{full_path}> is waiting for pushes to finish."
322332
false

spec/gitlab_projects_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@
212212

213213
before do
214214
FileUtils.mkdir_p(tmp_repo_path)
215+
FileUtils.mkdir_p(File.join(tmp_repo_path, 'hooks')) # Add some contents to copy
215216
FileUtils.mkdir_p(alternative_storage_path)
216217
allow_any_instance_of(GitlabReferenceCounter).to receive(:value).and_return(0)
217218
end
@@ -222,6 +223,8 @@
222223
File.exists?(tmp_repo_path).should be_true
223224
gl_projects.exec
224225
File.exists?(new_repo_path).should be_true
226+
# Make sure the target directory isn't empty (i.e. contents were copied)
227+
FileUtils.cd(new_repo_path) { Dir['**/*'].length.should_not be(0) }
225228
end
226229

227230
it "should fail if no destination path is provided" do

0 commit comments

Comments
 (0)