diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 16:16:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 16:16:36 +0300 |
commit | 311b0269b4eb9839fa63f80c8d7a58f32b8138a0 (patch) | |
tree | 07e7870bca8aed6d61fdcc810731c50d2c40af47 /lib/gitlab/sidekiq_config.rb | |
parent | 27909cef6c4170ed9205afa7426b8d3de47cbb0c (diff) |
Add latest changes from gitlab-org/gitlab@14-5-stable-eev14.5.0-rc42
Diffstat (limited to 'lib/gitlab/sidekiq_config.rb')
-rw-r--r-- | lib/gitlab/sidekiq_config.rb | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/lib/gitlab/sidekiq_config.rb b/lib/gitlab/sidekiq_config.rb index 5663c51bb7a..07ddac209f8 100644 --- a/lib/gitlab/sidekiq_config.rb +++ b/lib/gitlab/sidekiq_config.rb @@ -6,11 +6,13 @@ module Gitlab module SidekiqConfig FOSS_QUEUE_CONFIG_PATH = 'app/workers/all_queues.yml' EE_QUEUE_CONFIG_PATH = 'ee/app/workers/all_queues.yml' + JH_QUEUE_CONFIG_PATH = 'jh/app/workers/all_queues.yml' SIDEKIQ_QUEUES_PATH = 'config/sidekiq_queues.yml' QUEUE_CONFIG_PATHS = [ FOSS_QUEUE_CONFIG_PATH, - (EE_QUEUE_CONFIG_PATH if Gitlab.ee?) + (EE_QUEUE_CONFIG_PATH if Gitlab.ee?), + (JH_QUEUE_CONFIG_PATH if Gitlab.jh?) ].compact.freeze # This maps workers not in our application code to queues. We need @@ -33,7 +35,7 @@ module Gitlab weight: 2, tags: [] ) - }.transform_values { |worker| Gitlab::SidekiqConfig::Worker.new(worker, ee: false) }.freeze + }.transform_values { |worker| Gitlab::SidekiqConfig::Worker.new(worker, ee: false, jh: false) }.freeze class << self include Gitlab::SidekiqConfig::CliMethods @@ -58,10 +60,14 @@ module Gitlab @workers ||= begin result = [] result.concat(DEFAULT_WORKERS.values) - result.concat(find_workers(Rails.root.join('app', 'workers'), ee: false)) + result.concat(find_workers(Rails.root.join('app', 'workers'), ee: false, jh: false)) if Gitlab.ee? - result.concat(find_workers(Rails.root.join('ee', 'app', 'workers'), ee: true)) + result.concat(find_workers(Rails.root.join('ee', 'app', 'workers'), ee: true, jh: false)) + end + + if Gitlab.jh? + result.concat(find_workers(Rails.root.join('jh', 'app', 'workers'), ee: false, jh: true)) end result @@ -69,16 +75,26 @@ module Gitlab end def workers_for_all_queues_yml - workers.partition(&:ee?).reverse.map(&:sort) + workers.each_with_object([[], [], []]) do |worker, array| + if worker.jh? + array[2].push(worker) + elsif worker.ee? + array[1].push(worker) + else + array[0].push(worker) + end + end.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 + foss_workers, ee_workers, jh_workers = workers_for_all_queues_yml return true if foss_workers != YAML.load_file(FOSS_QUEUE_CONFIG_PATH) - Gitlab.ee? && ee_workers != YAML.load_file(EE_QUEUE_CONFIG_PATH) + return true if Gitlab.ee? && ee_workers != YAML.load_file(EE_QUEUE_CONFIG_PATH) + + Gitlab.jh? && File.exist?(JH_QUEUE_CONFIG_PATH) && jh_workers != YAML.load_file(JH_QUEUE_CONFIG_PATH) end def queues_for_sidekiq_queues_yml @@ -120,14 +136,14 @@ module Gitlab private - def find_workers(root, ee:) + def find_workers(root, ee:, jh:) concerns = root.join('concerns').to_s Dir[root.join('**', '*.rb')] .reject { |path| path.start_with?(concerns) } .map { |path| worker_from_path(path, root) } .select { |worker| worker < Sidekiq::Worker } - .map { |worker| Gitlab::SidekiqConfig::Worker.new(worker, ee: ee) } + .map { |worker| Gitlab::SidekiqConfig::Worker.new(worker, ee: ee, jh: jh) } end def worker_from_path(path, root) |