diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2016-10-07 15:14:39 +0000 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2016-10-07 15:14:39 +0000 |
commit | 32ebd136f96fd1f97701ccc7575fd3be81c493d4 (patch) | |
tree | 8aa4fd3f061cdc9115083627bdb1393dd1f856b9 | |
parent | ca7c80ce2a07a7e581fcf991b5ecc06b0e6224f9 (diff) | |
parent | 47723a6872f5506c38c98386ef215a1aca8a690e (diff) | |
download | gitlab-shell-32ebd136f96fd1f97701ccc7575fd3be81c493d4.tar.gz |
Merge branch 'fix-ionice-again' into 'master'
Fix rsync with ionice command building
See merge request !97
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | lib/gitlab_projects.rb | 13 | ||||
-rw-r--r-- | spec/gitlab_projects_spec.rb | 6 |
3 files changed, 11 insertions, 9 deletions
@@ -1,4 +1,5 @@ v3.6.4 + - Fix rsync with ionice command building - Fix short circuit logic between rsync with and without ionice for storage migrations v3.6.3 diff --git a/lib/gitlab_projects.rb b/lib/gitlab_projects.rb index d3d45ae..58dea50 100644 --- a/lib/gitlab_projects.rb +++ b/lib/gitlab_projects.rb @@ -318,16 +318,12 @@ class GitlabProjects $logger.info "Syncing project #{@project_name} from <#{full_path}> to <#{new_full_path}>." # Set a low IO priority with ionice to not choke the server on moves - rsync_path = 'ionice -c2 -n7 rsync' - result = system(*%W(#{rsync_path} -a --delete --rsync-path="#{rsync_path}" #{source_path} #{new_full_path})) - - if result + if rsync(source_path, new_full_path, 'ionice -c2 -n7 rsync') true else # If the command fails with `ionice` (maybe because we're on a OS X # development machine), try again without `ionice`. - rsync_path = 'rsync' - system(*%W(#{rsync_path} -a --delete --rsync-path="#{rsync_path}" #{source_path} #{new_full_path})) + rsync(source_path, new_full_path) end else $logger.error "mv-storage failed: source path <#{full_path}> is waiting for pushes to finish." @@ -393,4 +389,9 @@ class GitlabProjects def gitlab_reference_counter @gitlab_reference_counter ||= GitlabReferenceCounter.new(full_path) end + + def rsync(src, dest, rsync_path = 'rsync') + command = rsync_path.split + %W(-a --delete --rsync-path="#{rsync_path}" #{src} #{dest}) + system(*command) + end end diff --git a/spec/gitlab_projects_spec.rb b/spec/gitlab_projects_spec.rb index 149d53f..175c929 100644 --- a/spec/gitlab_projects_spec.rb +++ b/spec/gitlab_projects_spec.rb @@ -229,7 +229,7 @@ describe GitlabProjects do it "should attempt rsync with ionice first" do expect(gl_projects).to receive(:system).with( - 'ionice -c2 -n7 rsync', '-a', '--delete', '--rsync-path="ionice -c2 -n7 rsync"', + 'ionice', '-c2', '-n7', 'rsync', '-a', '--delete', '--rsync-path="ionice -c2 -n7 rsync"', "#{tmp_repo_path}/", new_repo_path ).and_return(true) @@ -238,7 +238,7 @@ describe GitlabProjects do it "should attempt rsync without ionice if with ionice fails" do expect(gl_projects).to receive(:system).with( - 'ionice -c2 -n7 rsync', '-a', '--delete', '--rsync-path="ionice -c2 -n7 rsync"', + 'ionice', '-c2', '-n7', 'rsync', '-a', '--delete', '--rsync-path="ionice -c2 -n7 rsync"', "#{tmp_repo_path}/", new_repo_path ).and_return(false) @@ -251,7 +251,7 @@ describe GitlabProjects do it "should fail if both rsync attempts fail" do expect(gl_projects).to receive(:system).with( - 'ionice -c2 -n7 rsync', '-a', '--delete', '--rsync-path="ionice -c2 -n7 rsync"', + 'ionice', '-c2', '-n7', 'rsync', '-a', '--delete', '--rsync-path="ionice -c2 -n7 rsync"', "#{tmp_repo_path}/", new_repo_path ).and_return(false) |