summaryrefslogtreecommitdiff
path: root/lib/api/circuit_breakers.rb
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@gitlab.com>2017-05-17 18:17:15 +0200
committerBob Van Landuyt <bob@vanlanduyt.co>2017-08-04 15:38:48 +0200
commit3598e60bf20b185b3f8d4e9a88a8eff39c8f729b (patch)
treeba84a7e7972d4a2563bb79485933fb78462868de /lib/api/circuit_breakers.rb
parent990feb9f2b886c5bd0ac37339f149b8e80202019 (diff)
downloadgitlab-ce-3598e60bf20b185b3f8d4e9a88a8eff39c8f729b.tar.gz
Add a Circuitbreaker for storage paths
Diffstat (limited to 'lib/api/circuit_breakers.rb')
-rw-r--r--lib/api/circuit_breakers.rb50
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/api/circuit_breakers.rb b/lib/api/circuit_breakers.rb
new file mode 100644
index 00000000000..118883f5ea5
--- /dev/null
+++ b/lib/api/circuit_breakers.rb
@@ -0,0 +1,50 @@
+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
+ @failing_storage_health ||= Gitlab::Git::Storage::Health.for_all_storages
+ end
+ end
+
+ desc 'Get all failing git storages' do
+ 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
+ Gitlab::Git::Storage::CircuitBreaker.reset_all!
+ end
+ end
+ end
+ end
+ end
+end