Commit 8cfb72c3 authored by George Koltsov's avatar George Koltsov Committed by Douglas Barbosa Alexandre

Do not raise during archive size validation when wait thread is finished

parent 32ae1801
...@@ -32,7 +32,16 @@ module Gitlab ...@@ -32,7 +32,16 @@ module Gitlab
Timeout.timeout(TIMEOUT_LIMIT) do Timeout.timeout(TIMEOUT_LIMIT) do
stdin, stdout, stderr, wait_thr = Open3.popen3(command, pgroup: true) stdin, stdout, stderr, wait_thr = Open3.popen3(command, pgroup: true)
stdin.close stdin.close
pgrp = Process.getpgid(wait_thr[:pid])
# When validation is performed on a small archive (e.g. 100 bytes)
# `wait_thr` finishes before we can get process group id. Do not
# raise exception in this scenario.
pgrp = begin
Process.getpgid(wait_thr[:pid])
rescue Errno::ESRCH
nil
end
status = wait_thr.value status = wait_thr.value
if status.success? if status.success?
......
...@@ -24,6 +24,14 @@ RSpec.describe Gitlab::ImportExport::DecompressedArchiveSizeValidator do ...@@ -24,6 +24,14 @@ RSpec.describe Gitlab::ImportExport::DecompressedArchiveSizeValidator do
it 'returns true' do it 'returns true' do
expect(subject.valid?).to eq(true) expect(subject.valid?).to eq(true)
end end
context 'when waiter thread no longer exists' do
it 'does not raise exception' do
allow(Process).to receive(:getpgid).and_raise(Errno::ESRCH)
expect(subject.valid?).to eq(true)
end
end
end end
context 'when file exceeds allowed decompressed size' do context 'when file exceeds allowed decompressed size' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment