Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2018-12-12 16:31:53 +0300
committerNick Thomas <nick@gitlab.com>2018-12-12 16:31:53 +0300
commitb9ccf013bab3f7ec25b70d83f37b1b0923302379 (patch)
tree90674592fccdb3c2b8bec338f97583cfd17854f7 /app/workers
parent5ee900ee9d2288cbf57007d905acd2a6e9239ff4 (diff)
parentb65cb237cee0b1a8dfdc21a09f2b181d0edf5bde (diff)
Merge branch '54650-send-an-email-to-project-owners-when-a-mirror-update-fails' into 'master'
Send a notification email on mirror update errors Closes #54650 See merge request gitlab-org/gitlab-ce!23595
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/all_queues.yml1
-rw-r--r--app/workers/remote_mirror_notification_worker.rb15
-rw-r--r--app/workers/repository_update_remote_mirror_worker.rb2
3 files changed, 17 insertions, 1 deletions
diff --git a/app/workers/all_queues.yml b/app/workers/all_queues.yml
index dfce00a10a1..bc26b3f8ef2 100644
--- a/app/workers/all_queues.yml
+++ b/app/workers/all_queues.yml
@@ -124,6 +124,7 @@
- propagate_service_template
- reactive_caching
- rebase
+- remote_mirror_notification
- repository_fork
- repository_import
- repository_remove_remote
diff --git a/app/workers/remote_mirror_notification_worker.rb b/app/workers/remote_mirror_notification_worker.rb
new file mode 100644
index 00000000000..70c2e857d09
--- /dev/null
+++ b/app/workers/remote_mirror_notification_worker.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class RemoteMirrorNotificationWorker
+ include ApplicationWorker
+
+ def perform(remote_mirror_id)
+ remote_mirror = RemoteMirrorFinder.new(id: remote_mirror_id).execute
+
+ # We check again if there's an error because a newer run since this job was
+ # fired could've completed successfully.
+ return unless remote_mirror && remote_mirror.last_error.present?
+
+ NotificationService.new.remote_mirror_update_failed(remote_mirror)
+ end
+end
diff --git a/app/workers/repository_update_remote_mirror_worker.rb b/app/workers/repository_update_remote_mirror_worker.rb
index bd429d526bf..c0bae08ba85 100644
--- a/app/workers/repository_update_remote_mirror_worker.rb
+++ b/app/workers/repository_update_remote_mirror_worker.rb
@@ -15,7 +15,7 @@ class RepositoryUpdateRemoteMirrorWorker
end
def perform(remote_mirror_id, scheduled_time)
- remote_mirror = RemoteMirror.find(remote_mirror_id)
+ remote_mirror = RemoteMirrorFinder.new(id: remote_mirror_id).execute
return if remote_mirror.updated_since?(scheduled_time)
raise UpdateAlreadyInProgressError if remote_mirror.update_in_progress?