Skip to content

Add error handling for workspace project cloning

Vishal Tak requested to merge vtak/fix_workspace_cloning_issue into master

Issue: BUG: Errors are not properly handled when proje... (#471531 - closed)

What does this MR do and why?

Current logic of project cloning is faulty. If there is some error mid-cloning, the project is not cloned successfully again because we only check for the existence of project folder which will be present.

Ideally, the project should be cloned only if one is not cloned successfully already. This is required to avoid resetting user's modifications to the files. This is achieved by checking for the existence of a file before cloning. If the file does not exist, clone the project. To accommodate for scenarios where the project cloning failed midway in the previous attempt, remove the directory before cloning. Once cloning is successful, create the file which is used in the check above. This will ensure the project is not cloned again on restarts.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

How to set up and validate locally

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

  1. Create a workspace. Check the logs of the project cloner container. It should clone the project from scratch.
$ kubectl logs -f workspace-1-1-ornkbn-67c57bd4c-h4kq8 -c gl-cloner-injector-gl-cloner-injector-command-1
Cloning project
Cloning into '/projects/gitlab-shell'...
Project cloning successful
Updated file to indicate successful project cloning
  1. Restart the workspace. Check the logs of the project cloner container. It should not clone the project.
$ kubectl logs -f workspace-1-1-ornkbn-67c57bd4c-9mx4p -c gl-cloner-injector-gl-cloner-injector-command-1
Project cloning was already successful
Edited by Vishal Tak

Merge request reports