Class: ContainerRegistry::RecordDataRepairDetailWorker
- Inherits:
-
Object
- Object
- ContainerRegistry::RecordDataRepairDetailWorker
- Includes:
- ApplicationWorker, CronjobChildWorker, ExclusiveLeaseGuard, Gitlab::Utils::StrongMemoize, LimitedCapacity::Worker
- Defined in:
- app/workers/container_registry/record_data_repair_detail_worker.rb
Constant Summary collapse
- LEASE_TIMEOUT =
1.hour.to_i
Constants included from ApplicationWorker
ApplicationWorker::LOGGING_EXTRA_KEY, ApplicationWorker::SAFE_PUSH_BULK_LIMIT
Constants included from Gitlab::Loggable
Constants included from WorkerAttributes
WorkerAttributes::DEFAULT_CONCURRENCY_LIMIT_PERCENTAGE_BY_URGENCY, WorkerAttributes::DEFAULT_DATA_CONSISTENCY, WorkerAttributes::DEFAULT_DATA_CONSISTENCY_PER_DB, WorkerAttributes::DEFAULT_DEFER_DELAY, WorkerAttributes::LOAD_BALANCED_DATA_CONSISTENCIES, WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_DATA_CONSISTENCIES, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES
Instance Method Summary collapse
Methods included from LimitedCapacity::Worker
#perform, #remove_failed_jobs, #report_prometheus_metrics
Methods included from ExclusiveLeaseGuard
#exclusive_lease, #lease_release?, #lease_taken_log_level, #lease_taken_message, #log_lease_taken, #release_lease, #renew_lease!, #try_obtain_lease
Methods included from Gitlab::Loggable
Methods included from Gitlab::SidekiqVersioning::Worker
Methods included from WorkerContext
Instance Method Details
#max_running_jobs ⇒ Object
62 63 64 |
# File 'app/workers/container_registry/record_data_repair_detail_worker.rb', line 62 def max_running_jobs current_application_settings.container_registry_data_repair_detail_worker_max_concurrency.to_i end |
#perform_work ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/workers/container_registry/record_data_repair_detail_worker.rb', line 20 def perform_work return unless Gitlab.com_except_jh? return unless next_project return if next_project.container_registry_data_repair_detail missing_count = 0 try_obtain_lease do detail = create_data_repair_detail GitlabApiClient.each_sub_repositories_with_tag_page(path: next_project.full_path, page_size: 50) do |repositories| next if repositories.empty? paths = repositories.map { |repo| ContainerRegistry::Path.new(repo["path"]) } paths, invalid_paths = paths.partition(&:valid?) unless invalid_paths.empty? ( :invalid_paths_parsed_in_container_repository_repair, invalid_paths.join(' ,') ) end found_repositories = next_project.container_repositories.where(name: paths.map(&:repository_name)) # rubocop:disable CodeReuse/ActiveRecord missing_count += repositories.count - found_repositories.count end detail.update!(missing_count: missing_count, status: :completed) end rescue StandardError => exception next_project.reset.container_registry_data_repair_detail&.update(status: :failed) Gitlab::ErrorTracking.log_exception(exception, class: self.class.name) end |
#remaining_work_count ⇒ Object
54 55 56 57 58 59 60 |
# File 'app/workers/container_registry/record_data_repair_detail_worker.rb', line 54 def remaining_work_count return 0 unless Gitlab.com_except_jh? return 0 unless Feature.enabled?(:registry_data_repair_worker) return 0 unless ContainerRegistry::GitlabApiClient.supports_gitlab_api? Project.pending_data_repair_analysis.limit(max_running_jobs + 1).count end |