Commit 06154624 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'support-forum_816' into 'master'

Mark the import as failed if a temporary or unknown error happened.

https://gitlab.com/gitlab-com/support-forum/issues/816

I've seen some users have reported that the updated of their mirror
repositories is being stuck, it basically happens because a temporary or
unknown error happened and the import status was kept in `started`
instead of being marked as `failed`.

See merge request !526
parents 5fb44f45 8af8a683
class RepositoryUpdateMirrorWorker
class UpdateMirrorError < StandardError; end
include Sidekiq::Worker
include Gitlab::ShellAdapter
......@@ -9,6 +11,7 @@ class RepositoryUpdateMirrorWorker
attr_accessor :project, :repository, :current_user
def perform(project_id)
begin
return unless try_obtain_lease(project_id)
@project = Project.find(project_id)
......@@ -21,6 +24,11 @@ class RepositoryUpdateMirrorWorker
end
project.import_finish
rescue => ex
project.mark_import_as_failed("We're sorry, a temporary error occurred, please try again.")
raise UpdateMirrorError, "#{ex.class}: #{ex.message}"
end
end
private
......
class RepositoryUpdateRemoteMirrorWorker
class UpdateRemoteMirrorError < StandardError; end
include Sidekiq::Worker
include Gitlab::ShellAdapter
sidekiq_options queue: :gitlab_shell
def perform(remote_mirror_id)
begin
remote_mirror = RemoteMirror.find(remote_mirror_id)
project = remote_mirror.project
current_user = project.creator
......@@ -15,5 +18,10 @@ class RepositoryUpdateRemoteMirrorWorker
else
remote_mirror.update_finish
end
rescue => ex
remote_mirror.mark_as_failed("We're sorry, a temporary error occurred, please try again.")
raise UpdateRemoteMirrorError, "#{ex.class}: #{ex.message}"
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment