Ensure repository folder doesn't exist when importing a Project Export
What does this MR do?
related to:
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
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
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