Commit 50962b17 authored by Dylan Griffith's avatar Dylan Griffith

Merge branch 'sh-avoid-current-settings-rake-task' into 'master'

Only load usage ping cron schedule for Sidekiq

See merge request gitlab-org/gitlab!25325
parents 0613aa98 435e913d
---
title: Only load usage ping cron schedule for Sidekiq
merge_request: 25325
author:
type: other
......@@ -446,7 +446,7 @@ Settings.cron_jobs['stuck_import_jobs_worker'] ||= Settingslogic.new({})
Settings.cron_jobs['stuck_import_jobs_worker']['cron'] ||= '15 * * * *'
Settings.cron_jobs['stuck_import_jobs_worker']['job_class'] = 'StuckImportJobsWorker'
Settings.cron_jobs['gitlab_usage_ping_worker'] ||= Settingslogic.new({})
Settings.cron_jobs['gitlab_usage_ping_worker']['cron'] ||= Settings.__send__(:cron_for_usage_ping)
Settings.cron_jobs['gitlab_usage_ping_worker']['cron'] ||= nil # This is dynamically loaded in the sidekiq initializer
Settings.cron_jobs['gitlab_usage_ping_worker']['job_class'] = 'GitlabUsagePingWorker'
Settings.cron_jobs['stuck_merge_jobs_worker'] ||= Settingslogic.new({})
Settings.cron_jobs['stuck_merge_jobs_worker']['cron'] ||= '0 */2 * * *'
......
# frozen_string_literal: true
require 'sidekiq/web'
def enable_reliable_fetch?
......@@ -71,6 +73,8 @@ Sidekiq.configure_server do |config|
Sidekiq::ReliableFetch.setup_reliable_fetch!(config)
end
Gitlab.config.load_dynamic_cron_schedules!
# Sidekiq-cron: load recurring jobs from gitlab.yml
# UGLY Hack to get nested hash from settingslogic
cron_jobs = JSON.parse(Gitlab.config.cron_jobs.to_json)
......
# frozen_string_literal: true
require 'settingslogic'
require 'digest/md5'
......@@ -143,6 +145,10 @@ class Settings < Settingslogic
Gitlab::Application.secrets.db_key_base
end
def load_dynamic_cron_schedules!
cron_jobs['gitlab_usage_ping_worker']['cron'] ||= cron_for_usage_ping
end
private
def base_url(config)
......
......@@ -9,6 +9,12 @@ describe Settings do
end
end
describe '.load_dynamic_cron_schedules!' do
it 'generates a valid cron schedule' do
expect(Fugit::Cron.parse(described_class.load_dynamic_cron_schedules!)).to be_a(Fugit::Cron)
end
end
describe '.attr_encrypted_db_key_base_truncated' do
it 'is a string with maximum 32 bytes size' do
expect(described_class.attr_encrypted_db_key_base_truncated.bytesize)
......
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