From aaba9ebbb196ae421178e962ccc1078fdcb98843 Mon Sep 17 00:00:00 2001 From: Gabriel Mazetto Date: Mon, 18 Jul 2016 12:57:57 +0200 Subject: [PATCH] Improve cron_jobs loading error messages --- CHANGELOG | 1 + config/initializers/sidekiq.rb | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index d8ef5866a1a..7bf2c7a5587 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -116,6 +116,7 @@ v 8.10.0 (unreleased) - Fix last update timestamp on issues not preserved on gitlab.com and project imports - Fix issues importing projects from EE to CE - Fix creating group with space in group path + - Improve cron_jobs loading error messages !5318 - Create Todos for Issue author when assign or mention himself (Katarzyna Kobierska) - Limit the number of retries on error to 3 for exporting projects - Allow empty repositories on project import/export diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb index 593c14a289f..b40fd81ff96 100644 --- a/config/initializers/sidekiq.rb +++ b/config/initializers/sidekiq.rb @@ -13,7 +13,14 @@ Sidekiq.configure_server do |config| # UGLY Hack to get nested hash from settingslogic cron_jobs = JSON.parse(Gitlab.config.cron_jobs.to_json) # UGLY hack: Settingslogic doesn't allow 'class' key - cron_jobs.each { |k, v| cron_jobs[k]['class'] = cron_jobs[k].delete('job_class') } + cron_jobs_required_keys = %w(job_class cron) + cron_jobs.each do |k, v| + if cron_jobs[k] && cron_jobs_required_keys.all? { |s| cron_jobs[k].key?(s) } + cron_jobs[k]['class'] = cron_jobs[k].delete('job_class') + else + raise("Invalid cron_jobs config key: '#{k}'. Check your gitlab config file.") + end + end Sidekiq::Cron::Job.load_from_hash! cron_jobs # Database pool should be at least `sidekiq_concurrency` + 2