Commit 7f9cd804 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'georgekoltsov/update-size-validator-pgid' into 'master'

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

See merge request gitlab-org/gitlab!62129
parents 3c2ba0bf 8cfb72c3
......@@ -32,7 +32,16 @@ module Gitlab
Timeout.timeout(TIMEOUT_LIMIT) do
stdin, stdout, stderr, wait_thr = Open3.popen3(command, pgroup: true)
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
if status.success?
......
......@@ -24,6 +24,14 @@ RSpec.describe Gitlab::ImportExport::DecompressedArchiveSizeValidator do
it 'returns true' do
expect(subject.valid?).to eq(true)
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
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