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
LEASE_TIMEOUT = 300
sidekiq_options queue: :gitlab_shell
attr_accessor :project, :repository, :current_user
def perform(project_id)
return unless try_obtain_lease(project_id)
begin
return unless try_obtain_lease(project_id)
@project = Project.find(project_id)
@current_user = @project.mirror_user || @project.creator
@project = Project.find(project_id)
@current_user = @project.mirror_user || @project.creator
result = Projects::UpdateMirrorService.new(@project, @current_user).execute
if result[:status] == :error
project.mark_import_as_failed(result[:message])
return
end
result = Projects::UpdateMirrorService.new(@project, @current_user).execute
if result[:status] == :error
project.mark_import_as_failed(result[:message])
return
end
project.import_finish
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)
remote_mirror = RemoteMirror.find(remote_mirror_id)
project = remote_mirror.project
current_user = project.creator
result = Projects::UpdateRemoteMirrorService.new(project, current_user).execute(remote_mirror)
begin
remote_mirror = RemoteMirror.find(remote_mirror_id)
project = remote_mirror.project
current_user = project.creator
result = Projects::UpdateRemoteMirrorService.new(project, current_user).execute(remote_mirror)
if result[:status] == :error
remote_mirror.mark_as_failed(result[:message])
else
remote_mirror.update_finish
end
rescue => ex
remote_mirror.mark_as_failed("We're sorry, a temporary error occurred, please try again.")
if result[:status] == :error
remote_mirror.mark_as_failed(result[:message])
else
remote_mirror.update_finish
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