Commit d6cf6597 authored by Stan Hu's avatar Stan Hu Committed by Filipa Lacerda
Browse files

Merge branch...

Merge branch '5409-geo-recovery-from-geo-temporary-directory-doesn-t-work-if-the-namespace-directory-doesn-t-exist' into 'master'

Resolve "Geo: Recovery from @geo-temporary directory doesn't work if the namespace directory doesn't exist"

Closes #5409

See merge request gitlab-org/gitlab-ee!5100
parent 362fd878
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -212,6 +212,8 @@ def set_temp_repository_as_main
        raise Gitlab::Shell::Error, 'Can not move original repository out of the way'
      end

      gitlab_shell.add_namespace(project.repository_storage_path, repository.disk_path)

      unless gitlab_shell.mv_repository(project.repository_storage_path, disk_path_temp, repository.disk_path)
        raise Gitlab::Shell::Error, 'Can not move temporary repository'
      end
+6 −0
Original line number Diff line number Diff line
---
title: 'Geo: Recovery from temporary directory doesn''t work if the namespace directory
  doesn''t exist'
merge_request:
author:
type: fixed
+11 −4
Original line number Diff line number Diff line
@@ -242,14 +242,21 @@

        expect(subject).to receive(:sync_repository).with(true).and_call_original
        expect(subject.gitlab_shell).to receive(:mv_repository).exactly(2).times.and_call_original

        expect(subject.gitlab_shell).to receive(:add_namespace).with(
          project.repository_storage_path,
          "@failed-geo-sync/#{repository.disk_path}"
        ).and_call_original

        expect(subject.gitlab_shell).to receive(:add_namespace).with(
          project.repository_storage_path,
          repository.disk_path
        ).and_call_original

        expect(subject.gitlab_shell).to receive(:remove_repository).exactly(2).times.and_call_original

        subject.execute

        # gitlab-shell always appends .git to the end of the repository, so
        # we're relying on the fact that projects can't contain + in the name
        deleted_dir = File.join(project.repository_storage_path, project.path) + "+failed-geo-sync.git"
        expect(File.directory?(deleted_dir)).to be false
        expect(File.directory?(project.repository.path)).to be true
      end