Commit 7fd811ab authored by Tiago Botelho's avatar Tiago Botelho

Refactors set_next_execution_timestamp in order to make mirror lower bound...

Refactors set_next_execution_timestamp in order to make mirror lower bound delay to be under effect of the mirror current retry count as well.
parent 0bf399f5
......@@ -26,8 +26,8 @@ class ProjectMirrorData < ActiveRecord::Base
def set_next_execution_timestamp!
timestamp = Time.now
retry_factor = [1, self.retry_count].max
delay = [base_delay(timestamp) * retry_factor, Gitlab::Mirror.max_delay].min
delay = [delay, Gitlab::Mirror.min_delay].max
delay = [base_delay(timestamp), Gitlab::Mirror.min_delay].max
delay = [delay * retry_factor, Gitlab::Mirror.max_delay].min
self.next_execution_timestamp = timestamp + delay
end
......
......@@ -104,7 +104,7 @@ describe ProjectMirrorData, type: :model do
expect do
mirror_data.set_next_execution_timestamp!
end.to change { mirror_data.next_execution_timestamp }.to be_within(interval).of(timestamp + 15.minutes)
end.to change { mirror_data.next_execution_timestamp }.to be_within(interval).of(timestamp + 45.minutes)
end
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