diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
commit | 4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch) | |
tree | 5423a1c7516cffe36384133ade12572cf709398d /app/workers/bulk_imports | |
parent | e570267f2f6b326480d284e0164a6464ba4081bc (diff) |
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'app/workers/bulk_imports')
-rw-r--r-- | app/workers/bulk_imports/entity_worker.rb | 3 | ||||
-rw-r--r-- | app/workers/bulk_imports/export_request_worker.rb | 33 | ||||
-rw-r--r-- | app/workers/bulk_imports/pipeline_worker.rb | 3 | ||||
-rw-r--r-- | app/workers/bulk_imports/relation_export_worker.rb | 27 |
4 files changed, 64 insertions, 2 deletions
diff --git a/app/workers/bulk_imports/entity_worker.rb b/app/workers/bulk_imports/entity_worker.rb index 7f173b738cf..e7fce112ee1 100644 --- a/app/workers/bulk_imports/entity_worker.rb +++ b/app/workers/bulk_imports/entity_worker.rb @@ -5,6 +5,7 @@ module BulkImports include ApplicationWorker feature_category :importers + tags :exclude_from_kubernetes sidekiq_options retry: false, dead: false @@ -26,7 +27,7 @@ module BulkImports entity_id ) end - rescue => e + rescue StandardError => e logger.error( worker: self.class.name, entity_id: entity_id, diff --git a/app/workers/bulk_imports/export_request_worker.rb b/app/workers/bulk_imports/export_request_worker.rb new file mode 100644 index 00000000000..cccc24d3bdc --- /dev/null +++ b/app/workers/bulk_imports/export_request_worker.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +module BulkImports + class ExportRequestWorker + include ApplicationWorker + + idempotent! + worker_has_external_dependencies! + feature_category :importers + + GROUP_EXPORTED_URL_PATH = "/groups/%s/export_relations" + + def perform(entity_id) + entity = BulkImports::Entity.find(entity_id) + + request_export(entity) + end + + private + + def request_export(entity) + http_client(entity.bulk_import.configuration) + .post(GROUP_EXPORTED_URL_PATH % entity.encoded_source_full_path) + end + + def http_client(configuration) + @client ||= Clients::Http.new( + uri: configuration.url, + token: configuration.access_token + ) + end + end +end diff --git a/app/workers/bulk_imports/pipeline_worker.rb b/app/workers/bulk_imports/pipeline_worker.rb index a6de3c36205..256301bf097 100644 --- a/app/workers/bulk_imports/pipeline_worker.rb +++ b/app/workers/bulk_imports/pipeline_worker.rb @@ -5,6 +5,7 @@ module BulkImports include ApplicationWorker feature_category :importers + tags :exclude_from_kubernetes sidekiq_options retry: false, dead: false @@ -46,7 +47,7 @@ module BulkImports pipeline_tracker.pipeline_class.new(context).run pipeline_tracker.finish! - rescue => e + rescue StandardError => e pipeline_tracker.fail_op! logger.error( diff --git a/app/workers/bulk_imports/relation_export_worker.rb b/app/workers/bulk_imports/relation_export_worker.rb new file mode 100644 index 00000000000..9d9449e3a1b --- /dev/null +++ b/app/workers/bulk_imports/relation_export_worker.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +module BulkImports + class RelationExportWorker + include ApplicationWorker + include ExceptionBacktrace + + idempotent! + loggable_arguments 2, 3 + feature_category :importers + tags :exclude_from_kubernetes + sidekiq_options status_expiration: StuckExportJobsWorker::EXPORT_JOBS_EXPIRATION + + def perform(user_id, portable_id, portable_class, relation) + user = User.find(user_id) + portable = portable(portable_id, portable_class) + + RelationExportService.new(user, portable, relation, jid).execute + end + + private + + def portable(portable_id, portable_class) + portable_class.classify.constantize.find(portable_id) + end + end +end |