diff options
author | Fabio Pitino <fpitino@gitlab.com> | 2019-05-07 08:09:25 +0100 |
---|---|---|
committer | Fabio Pitino <fpitino@gitlab.com> | 2019-05-07 08:09:25 +0100 |
commit | 961da8ed08b7dbafd8db5e61acade43ccf69dded (patch) | |
tree | 821ba0d483291c83510afeb43f2854dff980ea07 | |
parent | c75b8ad4dadfa8f9676e0339e06408af3281f512 (diff) | |
parent | 60a442883169ad3da921473e17579398a4f38a2c (diff) | |
download | gitlab-ce-961da8ed08b7dbafd8db5e61acade43ccf69dded.tar.gz |
Merge branch 'fix-too-many-loops-cron-error' of https://gitlab.com/gitlab-org/gitlab-ce into fix-too-many-loops-cron-error
-rw-r--r-- | lib/gitlab/ci/cron_parser.rb | 10 |
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 |