Skip to content
代码片段 群组 项目
未验证 提交 c0fd5737 编辑于 作者: Michael Trainor's avatar Michael Trainor 提交者: GitLab
浏览文件

Ensure daily limit can't be zero

The daily limit is currently not validated, so it
can be any value within the underlying datatype for
the column. This can be a number larger than 1440.

When a number is greater than 1440 is configured for
the daily limit, the integer provided in the natural
expression to Fugit contains zero. This results in a
ZeroDivisionError from Fugit.

This commit ensures that the expression provided to
Fugit can't contain a zero. If the result of the
expression is less than 1, it will be treated like
a 1, eg 'every 1 minutes'.
上级 36ca6b3f
No related branches found
No related tags found
无相关合并请求
......@@ -47,7 +47,13 @@ def plan_cron
every_x_minutes = (1.day.in_minutes / daily_limit).to_i
Gitlab::Ci::CronParser.parse_natural("every #{every_x_minutes} minutes", Time.zone.name)
begin
Gitlab::Ci::CronParser.parse_natural("every #{every_x_minutes} minutes", Time.zone.name)
rescue ZeroDivisionError
# Fugit returns ZeroDivision Error if provided a number
# less than 1 in the expression.
nil
end
end
end
end
......
......@@ -30,6 +30,8 @@
# 1.day / 2.hours => 12 times a day and it is invalid because there is a minimum for plan limits.
# See: https://docs.gitlab.com/ee/administration/instance_limits.html#limit-the-number-of-pipelines-created-by-a-pipeline-schedule-per-day
'*/5 * * * *' | '0 * * * *' | 1.day / 2.hours | Time.zone.local(2021, 5, 27, 11, 0) | Time.zone.local(2021, 5, 27, 12, 5)
'*/5 * * * *' | '0 * * * *' | 2000 | Time.zone.local(2021, 5, 27, 11, 0) | Time.zone.local(2021, 5, 27, 12, 5)
'*/5 * * * *' | '0 * * * *' | -24 | Time.zone.local(2021, 5, 27, 11, 0) | Time.zone.local(2021, 5, 27, 12, 5)
end
with_them do
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册