Module: UpdateRepositoryStorageMethods

Includes:
Gitlab::Utils::StrongMemoize
Included in:
Projects::UpdateRepositoryStorageService, Snippets::UpdateRepositoryStorageService
Defined in:
app/services/concerns/update_repository_storage_methods.rb

Constant Summary collapse

MAX_ERROR_LENGTH =
256
Error =
Class.new(StandardError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#repository_storage_moveObject (readonly)

Returns the value of attribute repository_storage_move.



10
11
12
# File 'app/services/concerns/update_repository_storage_methods.rb', line 10

def repository_storage_move
  @repository_storage_move
end

Instance Method Details

#executeObject



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
49
50
51
52
# File 'app/services/concerns/update_repository_storage_methods.rb', line 18

def execute
  response = repository_storage_move.with_lock do
    next ServiceResponse.success unless repository_storage_move.scheduled?

    repository_storage_move.start!

    nil
  end

  return response if response

  unless same_filesystem?
    # Mirror the object pool first, as we'll later provide the pool's disk path as
    # partitioning hints when mirroring member repositories.
    mirror_object_pool(destination_storage_name)
    mirror_repositories
  end

  repository_storage_move.transaction do
    track_repository(destination_storage_name)
  end

  repository_storage_move.finish_replication!

  remove_old_paths unless same_filesystem?

  repository_storage_move.finish_cleanup!

  ServiceResponse.success
rescue StandardError => e
  repository_storage_move.update_column(:error_message, e.message.truncate(MAX_ERROR_LENGTH))
  repository_storage_move.do_fail!

  Gitlab::ErrorTracking.track_and_raise_exception(e, container_klass: container.class.to_s, container_path: container.full_path)
end

#initialize(repository_storage_move) ⇒ Object



14
15
16
# File 'app/services/concerns/update_repository_storage_methods.rb', line 14

def initialize(repository_storage_move)
  @repository_storage_move = repository_storage_move
end