summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabio Pitino <fpitino@gitlab.com>2019-05-02 13:29:51 +0100
committerFabio Pitino <fpitino@gitlab.com>2019-05-02 13:29:51 +0100
commit12712470b354c58860915e38c8a79a75623a3697 (patch)
tree31de3725e2e6679b8ea2725f75724619f8e624c9
parent4de06435d0c6fc904081b4da82253a2e025613a4 (diff)
downloadgitlab-ce-12712470b354c58860915e38c8a79a75623a3697.tar.gz
Rescue RuntimeError when "too many loops" are reached by Fugit::Cron
-rw-r--r--lib/gitlab/ci/cron_parser.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/gitlab/ci/cron_parser.rb b/lib/gitlab/ci/cron_parser.rb
index 94f4a4e36c9..ae524654b7d 100644
--- a/lib/gitlab/ci/cron_parser.rb
+++ b/lib/gitlab/ci/cron_parser.rb
@@ -13,7 +13,7 @@ module Gitlab
def next_time_from(time)
@cron_line ||= try_parse_cron(@cron, @cron_timezone)
- @cron_line.next_time(time).utc.in_time_zone(Time.zone) if @cron_line.present?
+ find_next_time(time) if @cron_line.present?
end
def cron_valid?
@@ -49,6 +49,14 @@ module Gitlab
def try_parse_cron(cron, cron_timezone)
Fugit::Cron.parse("#{cron} #{cron_timezone}")
end
+
+ def find_next_time(time)
+ @cron_line.next_time(time).utc.in_time_zone(Time.zone)
+ rescue RuntimeError => error
+ raise error unless error.message =~ /too many loops/
+ # Fugit::Cron raises a RuntimeError if :next_time does not find the next schedule
+ # given an invalid pattern - E.g. try_parse_cron('0 12 31 2 *')
+ end
end
end
end