Prevent GitHub Import to continue running workers when import fails
What does this MR do and why?
Check if the import process is no longer in progress and halt the workers to prevent them from running.
To provide some context, the workers were previously only stopping when the import state was canceled. However, it is also necessary to halt operations if the import state is in other final states such as failed or finished. This is because the workers should not perform any actions in these states.
Related to: https://gitlab.com/gitlab-org/gitlab/-/issues/411213#note_1411597409
Screenshots or screen recordings
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
-
Enable GitHub Import in Admin -> Settings -> General -> Visibility and access controls -> Import sources -> GitHub
-
Go to new project
-
Select import project
-
Select GitHub
-
Provide an access token
-
Select a project to import
-
Then on the Rails console, simulate that the project import failed by running the command
Project.last.import_state.mark_as_failed('Error')
-
In Sidekiq dashboard, check if all workers related to GitHub Import stopped being re-enqueued
Note: Using the GitHub Import API, it's possible to import public repositories.
curl --location 'http://gdk.test:3000/api/v4/import/github' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer GITLAB_ACCESS_TOKEN' \
--data '{
"personal_access_token": "GITHUB_ACCESS_TOKEN",
"repo_id": "238983", // rspec-rails repo id
"target_namespace": "root",
"new_name": "rspec-rails"
}'
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.