summaryrefslogtreecommitdiff
path: root/app/workers
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-07 12:09:13 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-07 12:09:13 +0000
commit211a8c3361ccf4eb92f36edbdcf15c98fcdcc8b7 (patch)
tree0ad37172721a39b0d57240bb1b4e70f200a0d93e /app/workers
parent456a7247f9e88fc2518b69a1a00e905c6db6d775 (diff)
downloadgitlab-ce-211a8c3361ccf4eb92f36edbdcf15c98fcdcc8b7.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/all_queues.yml2
-rw-r--r--app/workers/propagate_instance_level_service_worker.rb26
-rw-r--r--app/workers/propagate_service_template_worker.rb26
-rw-r--r--app/workers/repository_fork_worker.rb26
4 files changed, 52 insertions, 28 deletions
diff --git a/app/workers/all_queues.yml b/app/workers/all_queues.yml
index 35852742b0d..b344e1e36b8 100644
--- a/app/workers/all_queues.yml
+++ b/app/workers/all_queues.yml
@@ -951,7 +951,7 @@
:latency_sensitive:
:resource_boundary: :unknown
:weight: 1
-- :name: propagate_service_template
+- :name: propagate_instance_level_service
:feature_category: :source_code_management
:has_external_dependencies:
:latency_sensitive:
diff --git a/app/workers/propagate_instance_level_service_worker.rb b/app/workers/propagate_instance_level_service_worker.rb
new file mode 100644
index 00000000000..64ea61cabfa
--- /dev/null
+++ b/app/workers/propagate_instance_level_service_worker.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+# Worker for updating any project specific caches.
+class PropagateInstanceLevelServiceWorker
+ include ApplicationWorker
+
+ feature_category :source_code_management
+
+ LEASE_TIMEOUT = 4.hours.to_i
+
+ # rubocop: disable CodeReuse/ActiveRecord
+ def perform(instance_level_service_id)
+ return unless try_obtain_lease_for(instance_level_service_id)
+
+ Projects::PropagateInstanceLevelService.propagate(Service.find_by(id: instance_level_service_id))
+ end
+ # rubocop: enable CodeReuse/ActiveRecord
+
+ private
+
+ def try_obtain_lease_for(instance_level_service_id)
+ Gitlab::ExclusiveLease
+ .new("propagate_instance_level_service_worker:#{instance_level_service_id}", timeout: LEASE_TIMEOUT)
+ .try_obtain
+ end
+end
diff --git a/app/workers/propagate_service_template_worker.rb b/app/workers/propagate_service_template_worker.rb
deleted file mode 100644
index 73a2b453207..00000000000
--- a/app/workers/propagate_service_template_worker.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-# frozen_string_literal: true
-
-# Worker for updating any project specific caches.
-class PropagateServiceTemplateWorker
- include ApplicationWorker
-
- feature_category :source_code_management
-
- LEASE_TIMEOUT = 4.hours.to_i
-
- # rubocop: disable CodeReuse/ActiveRecord
- def perform(template_id)
- return unless try_obtain_lease_for(template_id)
-
- Projects::PropagateServiceTemplate.propagate(Service.find_by(id: template_id))
- end
- # rubocop: enable CodeReuse/ActiveRecord
-
- private
-
- def try_obtain_lease_for(template_id)
- Gitlab::ExclusiveLease
- .new("propagate_service_template_worker:#{template_id}", timeout: LEASE_TIMEOUT)
- .try_obtain
- end
-end
diff --git a/app/workers/repository_fork_worker.rb b/app/workers/repository_fork_worker.rb
index 0adf745c7ac..ba141f808a7 100644
--- a/app/workers/repository_fork_worker.rb
+++ b/app/workers/repository_fork_worker.rb
@@ -29,7 +29,15 @@ class RepositoryForkWorker
result = gitlab_shell.fork_repository(source_project, target_project)
- raise "Unable to fork project #{target_project.id} for repository #{source_project.disk_path} -> #{target_project.disk_path}" unless result
+ if result
+ link_lfs_objects(source_project, target_project)
+ else
+ raise_fork_failure(
+ source_project,
+ target_project,
+ 'Failed to create fork repository'
+ )
+ end
target_project.after_import
end
@@ -40,4 +48,20 @@ class RepositoryForkWorker
Rails.logger.info("Project #{project.full_path} was in inconsistent state (#{project.import_status}) while forking.") # rubocop:disable Gitlab/RailsLogger
false
end
+
+ def link_lfs_objects(source_project, target_project)
+ Projects::LfsPointers::LfsLinkService
+ .new(target_project)
+ .execute(source_project.lfs_objects_oids)
+ rescue Projects::LfsPointers::LfsLinkService::TooManyOidsError
+ raise_fork_failure(
+ source_project,
+ target_project,
+ 'Source project has too many LFS objects'
+ )
+ end
+
+ def raise_fork_failure(source_project, target_project, reason)
+ raise "Unable to fork project #{target_project.id} for repository #{source_project.disk_path} -> #{target_project.disk_path}: #{reason}"
+ end
end