Skip to content

Ensure repository folder doesn't exist when importing a Project Export

What does this MR do?

related to:

Discover_-_Elastic

For some reason the process of importing a GitLab Project sometimes tries to create the repository twice, which causes the second run to fail with 9:CreateRepositoryFromBundle: target directory is non-empty. My original hypothesis was that this was only happening on sidekiq retries, therefore I tried to solve the problem by deleting the repository when the import failed. Later, the retries for importing jobs were disabled but the errors persisted.

To avoid these errors I propose to ensure the repository folder doesn't exist before importing the project bundle. (Suggested by @georgekoltsov)

Update

I went down to the rabbit hole to see if this fix wouldn't be a problem. I learned that it might happen to a job to get interrupted by some unexpected infra problem, kernel panic for example. When that happens sidekiq-reliable-fetch will put the job back to the queue. For this reason, sometimes, a repository directory might already exist when doing a repository import job. To avoid the job to fail with 9:CreateRepositoryFromBundle: target directory is non-empty, we can ensure the folder doesn't exist when doing the import.

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Mark Chao

Merge request reports