Commit fe3981bf authored by Stan Hu's avatar Stan Hu

Merge branch 'bvl-increase-gpg-cleanup-tries' into 'master'

Tweak GPG cleanup attempts

See merge request gitlab-org/gitlab!23581
parents c40faffd f82b746f
...@@ -6,7 +6,7 @@ module Gitlab ...@@ -6,7 +6,7 @@ module Gitlab
CleanupError = Class.new(StandardError) CleanupError = Class.new(StandardError)
BG_CLEANUP_RUNTIME_S = 10 BG_CLEANUP_RUNTIME_S = 10
FG_CLEANUP_RUNTIME_S = 0.5 FG_CLEANUP_RUNTIME_S = 1
MUTEX = Mutex.new MUTEX = Mutex.new
...@@ -127,7 +127,10 @@ module Gitlab ...@@ -127,7 +127,10 @@ module Gitlab
# error. # error.
# Failing to remove the tmp directory could leave the `gpg-agent` process # Failing to remove the tmp directory could leave the `gpg-agent` process
# running forever. # running forever.
Retriable.retriable(max_elapsed_time: cleanup_time, base_interval: 0.1) do #
# 15 tries will never complete within the maximum time with exponential
# backoff. So our limit is the runtime, not the number of tries.
Retriable.retriable(max_elapsed_time: cleanup_time, base_interval: 0.1, tries: 15) do
FileUtils.remove_entry(tmp_dir) if File.exist?(tmp_dir) FileUtils.remove_entry(tmp_dir) if File.exist?(tmp_dir)
end end
rescue => e rescue => e
......
...@@ -208,8 +208,8 @@ describe Gitlab::Gpg do ...@@ -208,8 +208,8 @@ describe Gitlab::Gpg do
allow(FileUtils).to receive(:remove_entry).with(any_args).and_call_original allow(FileUtils).to receive(:remove_entry).with(any_args).and_call_original
end end
it "tries for #{seconds}" do it "tries for #{seconds} or 15 times" do
expect(Retriable).to receive(:retriable).with(a_hash_including(max_elapsed_time: seconds)) expect(Retriable).to receive(:retriable).with(a_hash_including(max_elapsed_time: seconds, tries: 15))
described_class.using_tmp_keychain {} described_class.using_tmp_keychain {}
end end
......
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