2018-09-29 22:34:47 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-05-17 16:17:15 +00:00
|
|
|
module API
|
|
|
|
class CircuitBreakers < Grape::API
|
|
|
|
before { authenticated_as_admin! }
|
|
|
|
|
|
|
|
resource :circuit_breakers do
|
|
|
|
params do
|
|
|
|
requires :type,
|
|
|
|
type: String,
|
|
|
|
desc: "The type of circuitbreaker",
|
|
|
|
values: ['repository_storage']
|
|
|
|
end
|
|
|
|
resource ':type' do
|
|
|
|
namespace '', requirements: { type: 'repository_storage' } do
|
|
|
|
helpers do
|
|
|
|
def failing_storage_health
|
|
|
|
@failing_storage_health ||= Gitlab::Git::Storage::Health.for_failing_storages
|
|
|
|
end
|
|
|
|
|
|
|
|
def storage_health
|
2018-01-15 11:03:39 +00:00
|
|
|
@storage_health ||= Gitlab::Git::Storage::Health.for_all_storages
|
2017-05-17 16:17:15 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-01-15 11:03:39 +00:00
|
|
|
desc 'Get all git storages' do
|
2017-05-17 16:17:15 +00:00
|
|
|
detail 'This feature was introduced in GitLab 9.5'
|
|
|
|
success Entities::RepositoryStorageHealth
|
|
|
|
end
|
|
|
|
get do
|
|
|
|
present storage_health, with: Entities::RepositoryStorageHealth
|
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Get all failing git storages' do
|
|
|
|
detail 'This feature was introduced in GitLab 9.5'
|
|
|
|
success Entities::RepositoryStorageHealth
|
|
|
|
end
|
|
|
|
get 'failing' do
|
|
|
|
present failing_storage_health, with: Entities::RepositoryStorageHealth
|
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Reset all storage failures and open circuitbreaker' do
|
|
|
|
detail 'This feature was introduced in GitLab 9.5'
|
|
|
|
end
|
|
|
|
delete do
|
2017-11-13 15:52:07 +00:00
|
|
|
Gitlab::Git::Storage::FailureInfo.reset_all!
|
2017-05-17 16:17:15 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|