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 ...@@ -26,8 +26,8 @@ class ProjectMirrorData < ActiveRecord::Base
def set_next_execution_timestamp! def set_next_execution_timestamp!
timestamp = Time.now timestamp = Time.now
retry_factor = [1, self.retry_count].max retry_factor = [1, self.retry_count].max
delay = [base_delay(timestamp) * retry_factor, Gitlab::Mirror.max_delay].min delay = [base_delay(timestamp), Gitlab::Mirror.min_delay].max
delay = [delay, Gitlab::Mirror.min_delay].max delay = [delay * retry_factor, Gitlab::Mirror.max_delay].min
self.next_execution_timestamp = timestamp + delay self.next_execution_timestamp = timestamp + delay
end end
......
...@@ -104,7 +104,7 @@ describe ProjectMirrorData, type: :model do ...@@ -104,7 +104,7 @@ describe ProjectMirrorData, type: :model do
expect do expect do
mirror_data.set_next_execution_timestamp! 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 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