Commit f4bc346e authored by Robert Speicher's avatar Robert Speicher Committed by Ruben Davila

Merge branch 'sh-handle-deleted-project-mirror' into 'master'

Ignore unknown project ID in RepositoryUpdateMirrorWorker

Projects that are in pending_delete could still trigger the mirror,
leading to undefined method `mark_import_as_failed` errors and
repeated Sidekiq retries.

See merge request !754
parent dd406a71
......@@ -10,10 +10,13 @@ class RepositoryUpdateMirrorWorker
def perform(project_id)
begin
@project = Project.find(project_id)
@current_user = @project.mirror_user || @project.creator
project = Project.find(project_id)
result = Projects::UpdateMirrorService.new(@project, @current_user).execute
return unless project
@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
......@@ -21,9 +24,10 @@ class RepositoryUpdateMirrorWorker
project.import_finish
rescue => ex
if project
project.mark_import_as_failed("We're sorry, a temporary error occurred, please try again.")
raise UpdateMirrorError, "#{ex.class}: #{Gitlab::UrlSanitizer.sanitize(ex.message)}"
end
end
end
end
......@@ -19,5 +19,9 @@ describe RepositoryUpdateMirrorWorker do
expect { described_class.new.perform(project.id) }
.to change { project.reload.import_status }.to('failed')
end
it 'does nothing if project does not exist' do
expect(described_class.new.perform(1000000)).to be_nil
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