Commit cd0e93a0 authored by Stan Hu's avatar Stan Hu

Fail import state whenever repository import fails

If you mistakenly omit the `.git` extension from an import URL, Gitaly
will return an error message, "The requested URL returned error: 301",
because we disabled following redirections in a security release.

In https://gitlab.com/gitlab-org/gitlab/-/merge_requests/35344, we
disabled retries outright in RepositoryImportWorker, but the import
state would only be failed if the project were an import/export. As a
result, an import by URL would be stalled with an "Import in progress"
forever if a user entered in the wrong URL.

To fix this, we now always fail the import state whenever the repository
failed to clone.

Relates to https://gitlab.com/gitlab-org/gitlab/-/issues/238214
parent c2bedf7c
......@@ -30,7 +30,7 @@ class RepositoryImportWorker # rubocop:disable Scalability/IdempotentWorker
return if service.async?
if result[:status] == :error
fail_import(result[:message]) if template_import?
fail_import(result[:message])
raise result[:message]
end
......
---
title: Fail import state whenever repository import fails
merge_request: 49682
author:
type: fixed
......@@ -58,6 +58,7 @@ RSpec.describe RepositoryImportWorker do
subject.perform(project.id)
end.to raise_error(RuntimeError, error)
expect(import_state.reload.jid).not_to be_nil
expect(import_state.status).to eq('failed')
end
it 'updates the error on Import/Export' do
......@@ -74,6 +75,7 @@ RSpec.describe RepositoryImportWorker do
end.to raise_error(RuntimeError, error)
expect(import_state.reload.last_error).not_to be_nil
expect(import_state.status).to eq('failed')
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