Commit 6ccdf354 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'change-mirror-re-scheduling-algorithm' into 'master'

Refactors set_next_execution_timestamp in order to make mirror lower bound delay…

See merge request gitlab-org/gitlab-ee!3169
parents 193b1369 7fd811ab
......@@ -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