diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-28 18:08:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-28 18:08:36 +0300 |
commit | fedf978f9aa1909ed7bb3fad767ad120a1c6bd7b (patch) | |
tree | 1bd0f0b301ad96feda1910abe34eb89c46cc55cd /lib/gitlab/sidekiq_config.rb | |
parent | db24ab2b72dbff24c201410a0561e929ae7e8061 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/sidekiq_config.rb')
-rw-r--r-- | lib/gitlab/sidekiq_config.rb | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/lib/gitlab/sidekiq_config.rb b/lib/gitlab/sidekiq_config.rb index c8719023d40..4e0d3da1868 100644 --- a/lib/gitlab/sidekiq_config.rb +++ b/lib/gitlab/sidekiq_config.rb @@ -13,21 +13,10 @@ module Gitlab (EE_QUEUE_CONFIG_PATH if Gitlab.ee?) ].compact.freeze - # For queues that don't have explicit workers - default and mailers - DummyWorker = Struct.new(:queue, :weight) do - def queue_namespace - nil - end - - def get_weight - weight - end - end - DEFAULT_WORKERS = [ - Gitlab::SidekiqConfig::Worker.new(DummyWorker.new('default', 1), ee: false), - Gitlab::SidekiqConfig::Worker.new(DummyWorker.new('mailers', 2), ee: false) - ].freeze + DummyWorker.new('default', weight: 1), + DummyWorker.new('mailers', weight: 2) + ].map { |worker| Gitlab::SidekiqConfig::Worker.new(worker, ee: false) }.freeze class << self include Gitlab::SidekiqConfig::CliMethods @@ -66,12 +55,13 @@ module Gitlab workers.partition(&:ee?).reverse.map(&:sort) end + # YAML.load_file is OK here as we control the file contents def all_queues_yml_outdated? foss_workers, ee_workers = workers_for_all_queues_yml - return true if foss_workers != YAML.safe_load(File.read(FOSS_QUEUE_CONFIG_PATH)) + return true if foss_workers != YAML.load_file(FOSS_QUEUE_CONFIG_PATH) - Gitlab.ee? && ee_workers != YAML.safe_load(File.read(EE_QUEUE_CONFIG_PATH)) + Gitlab.ee? && ee_workers != YAML.load_file(EE_QUEUE_CONFIG_PATH) end def queues_for_sidekiq_queues_yml @@ -89,9 +79,9 @@ module Gitlab remaining_queues.map(&:queue_and_weight)).sort end + # YAML.load_file is OK here as we control the file contents def sidekiq_queues_yml_outdated? - # YAML.load is OK here as we control the file contents - config_queues = YAML.load(File.read(SIDEKIQ_QUEUES_PATH))[:queues] # rubocop:disable Security/YAMLLoad + config_queues = YAML.load_file(SIDEKIQ_QUEUES_PATH)[:queues] queues_for_sidekiq_queues_yml != config_queues end |