Cancel project imports from GitHub - backend
Problem to solve
Currently, when a user imports projects into GitLab there is no way for them to cancel an import in-progress.
Proposal
Allow users to cancel a repository that is importing.
- User can start the cancel process when an import is:
- Pending
- In progress
- User can't cancel after an import is complete.
- An import that is cancelled can not be resumed*
- Any files that have been imported stay in the project
- In the future we plan to offer the ability to delete after cancelling.
*However, it might be desirable in the future.
Solution
Flow | Mock |
---|---|
![]() |
![]() |
- Show a Cancel button on the importer page for imports that are pending or in progress.
- Cancel button should have a popover that gives more information and a link to the (yet to be created) docs.
-
Cancel import
Imported files will be kept. You can import this repository again later. Learn more.
-
Cancel import
As part of this MVC there will be no change to the functionality in import history and project view (details).
Backend
For this first iteration (Cancel) we need the backend to extend our api with cancel functionality.
The most straight strategy is to stop all background jobs via Sidekiq API that matches condition: it's inside Gitlab::GithubImport
namespace & the first argument which is project_id
is eq our importing project that we need to cancel.
Based on the discussion !98931 (comment 1116507182)
The jobs should return and do nothing if project import is canceled. Any remaining jobs will clear themselves out.
Context
The scope of this issue is for GitHub importer only. Cancel flows are tracked in this epic → Cancel import flows (&8218)
Original work and scope of issue
Problem to solve
Currently, when a user imports projects into GitLab there is no way for them to cancel an import in-progress. The below scenario illustrates the problem:
Import all repositories
- User authenticates their GitHub account.
🙂 - Selects "Import 234 repositories" from the
Import repositories from GitHub
page which initiates the import.🙂 - User realizes they had made a mistake and needs to cancel their import and correct the error.
😕 - User finds no way to cancel the import.
😡 - User must go into GitLab project settings for each imported project and delete them manually.
😩
This process is quite cumbersome and could cause a lot of frustration for the users.
Proposal
Allow the user to cancel imports once a project import has been initiated.
View the Figma file for the user flow:
View the Figma prototype for:
Notes
Canceling should be service agnostic if possible so we can use it for services other than GitHub.
Metrics on how often the feature is used are desirable. Being able to see them in Sisense would be the most helpful.
This work likely should be broken down into separate tasks:
-
adding 'canceled' state: #366427 (closed) -
adding changes to the the backend on the controller level -
adding the api endpoints and ensuring all github workers respect the cancelled state - GitHub importer has many workers enqueuing and running many jobs, so we need to make sure these are all cancelled when cancelling imports. Once this is done the API Documentation needs updating. https://docs.gitlab.com/ee/api/project_import_export.html#import-status