Class: Projects::UpdateRepositoryStorageService

Inherits:
Object
  • Object
show all
Defined in:
app/services/projects/update_repository_storage_service.rb

Constant Summary collapse

Error =
Class.new(StandardError)
SameFilesystemError =
Class.new(Error)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository_storage_move) ⇒ UpdateRepositoryStorageService

Returns a new instance of UpdateRepositoryStorageService.


11
12
13
# File 'app/services/projects/update_repository_storage_service.rb', line 11

def initialize(repository_storage_move)
  @repository_storage_move = repository_storage_move
end

Instance Attribute Details

#repository_storage_moveObject (readonly)

Returns the value of attribute repository_storage_move


8
9
10
# File 'app/services/projects/update_repository_storage_service.rb', line 8

def repository_storage_move
  @repository_storage_move
end

Instance Method Details

#executeObject


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/services/projects/update_repository_storage_service.rb', line 15

def execute
  repository_storage_move.with_lock do
    return ServiceResponse.success unless repository_storage_move.scheduled? # rubocop:disable Cop/AvoidReturnFromBlocks

    repository_storage_move.start!
  end

  raise SameFilesystemError if same_filesystem?(source_storage_name, destination_storage_name)

  mirror_repositories

  repository_storage_move.transaction do
    repository_storage_move.finish_replication!

    project.leave_pool_repository
    project.track_project_repository
  end

  remove_old_paths
  enqueue_housekeeping

  repository_storage_move.finish_cleanup!

  ServiceResponse.success

rescue StandardError => e
  repository_storage_move.do_fail!

  Gitlab::ErrorTracking.track_exception(e, project_path: project.full_path)

  ServiceResponse.error(
    message: s_("UpdateRepositoryStorage|Error moving repository storage for %{project_full_path} - %{message}") % { project_full_path: project.full_path, message: e.message }
  )
end