Commit f82b746f authored by Bob Van Landuyt's avatar Bob Van Landuyt Committed by Stan Hu

Increase the number of attempts for gpg cleanup

By default Retriable would only try 3 times. Which would never hit our
limit of 10s in sidekiq. Raising the number of tries means we'll only
be limited by the maximum runtime.
parent c40faffd
......@@ -6,7 +6,7 @@ module Gitlab
CleanupError = Class.new(StandardError)
BG_CLEANUP_RUNTIME_S = 10
FG_CLEANUP_RUNTIME_S = 0.5
FG_CLEANUP_RUNTIME_S = 1
MUTEX = Mutex.new
......@@ -127,7 +127,10 @@ module Gitlab
# error.
# Failing to remove the tmp directory could leave the `gpg-agent` process
# 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)
end
rescue => e
......
......@@ -208,8 +208,8 @@ describe Gitlab::Gpg do
allow(FileUtils).to receive(:remove_entry).with(any_args).and_call_original
end
it "tries for #{seconds}" do
expect(Retriable).to receive(:retriable).with(a_hash_including(max_elapsed_time: seconds))
it "tries for #{seconds} or 15 times" do
expect(Retriable).to receive(:retriable).with(a_hash_including(max_elapsed_time: seconds, tries: 15))
described_class.using_tmp_keychain {}
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