diff options
author | Alejandro RodrÃguez <alejorro70@gmail.com> | 2018-12-05 18:22:52 +0300 |
---|---|---|
committer | Alejandro RodrÃguez <alejorro70@gmail.com> | 2018-12-12 05:08:17 +0300 |
commit | b65cb237cee0b1a8dfdc21a09f2b181d0edf5bde (patch) | |
tree | dffc212c6e7ca84c1e61ec1625e53548c0b6de18 /app/workers | |
parent | 80eebd8e33c5f2f26bc0fdd233d9d92c51edd242 (diff) |
Send a notification email on mirror update errors
The email is sent to project maintainers containing the last mirror
update error. This will allow maintainers to set alarms and react
accordingly.
Diffstat (limited to 'app/workers')
-rw-r--r-- | app/workers/all_queues.yml | 1 | ||||
-rw-r--r-- | app/workers/remote_mirror_notification_worker.rb | 15 | ||||
-rw-r--r-- | app/workers/repository_update_remote_mirror_worker.rb | 2 |
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 9d4e67deb9c..a06db4b08cc 100644 --- a/app/workers/repository_update_remote_mirror_worker.rb +++ b/app/workers/repository_update_remote_mirror_worker.rb @@ -16,7 +16,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? |