Skip to content

Commit 47723a6

Browse files
committed
Fix rsync with ionice command building
1 parent ca7c80c commit 47723a6

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
v3.6.4
2+
- Fix rsync with ionice command building
23
- Fix short circuit logic between rsync with and without ionice for storage migrations
34

45
v3.6.3

lib/gitlab_projects.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -318,16 +318,12 @@ def mv_storage
318318
$logger.info "Syncing project #{@project_name} from <#{full_path}> to <#{new_full_path}>."
319319

320320
# 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-
if result
321+
if rsync(source_path, new_full_path, 'ionice -c2 -n7 rsync')
325322
true
326323
else
327324
# If the command fails with `ionice` (maybe because we're on a OS X
328325
# development machine), try again without `ionice`.
329-
rsync_path = 'rsync'
330-
system(*%W(#{rsync_path} -a --delete --rsync-path="#{rsync_path}" #{source_path} #{new_full_path}))
326+
rsync(source_path, new_full_path)
331327
end
332328
else
333329
$logger.error "mv-storage failed: source path <#{full_path}> is waiting for pushes to finish."
@@ -393,4 +389,9 @@ def wait_for_pushes
393389
def gitlab_reference_counter
394390
@gitlab_reference_counter ||= GitlabReferenceCounter.new(full_path)
395391
end
392+
393+
def rsync(src, dest, rsync_path = 'rsync')
394+
command = rsync_path.split + %W(-a --delete --rsync-path="#{rsync_path}" #{src} #{dest})
395+
system(*command)
396+
end
396397
end

spec/gitlab_projects_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@
229229

230230
it "should attempt rsync with ionice first" do
231231
expect(gl_projects).to receive(:system).with(
232-
'ionice -c2 -n7 rsync', '-a', '--delete', '--rsync-path="ionice -c2 -n7 rsync"',
232+
'ionice', '-c2', '-n7', 'rsync', '-a', '--delete', '--rsync-path="ionice -c2 -n7 rsync"',
233233
"#{tmp_repo_path}/", new_repo_path
234234
).and_return(true)
235235

@@ -238,7 +238,7 @@
238238

239239
it "should attempt rsync without ionice if with ionice fails" do
240240
expect(gl_projects).to receive(:system).with(
241-
'ionice -c2 -n7 rsync', '-a', '--delete', '--rsync-path="ionice -c2 -n7 rsync"',
241+
'ionice', '-c2', '-n7', 'rsync', '-a', '--delete', '--rsync-path="ionice -c2 -n7 rsync"',
242242
"#{tmp_repo_path}/", new_repo_path
243243
).and_return(false)
244244

@@ -251,7 +251,7 @@
251251

252252
it "should fail if both rsync attempts fail" do
253253
expect(gl_projects).to receive(:system).with(
254-
'ionice -c2 -n7 rsync', '-a', '--delete', '--rsync-path="ionice -c2 -n7 rsync"',
254+
'ionice', '-c2', '-n7', 'rsync', '-a', '--delete', '--rsync-path="ionice -c2 -n7 rsync"',
255255
"#{tmp_repo_path}/", new_repo_path
256256
).and_return(false)
257257

0 commit comments

Comments
 (0)