Skip to content

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

github-failed.mp4

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Enable GitHub Import in Admin -> Settings -> General -> Visibility and access controls -> Import sources -> GitHub

  2. Go to new project

  3. Select import project

  4. Select GitHub

  5. Provide an access token

  6. Select a project to import

  7. Then on the Rails console, simulate that the project import failed by running the command

    Project.last.import_state.mark_as_failed('Error')

  8. 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.

Edited by Rodrigo Tomonari

Merge request reports