summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorJacob Vosmaer <contact@jacobvosmaer.nl>2016-04-12 17:07:54 +0200
committerJacob Vosmaer <contact@jacobvosmaer.nl>2016-04-12 17:07:54 +0200
commit97f4ffff1e7b5da94e18edc20c009ffb46784187 (patch)
tree5d49026f25bfacb529dafc9142250681f4263cfb /app
parentb37d3b9423991763ad03fca791a1daf473dafed1 (diff)
downloadgitlab-ce-97f4ffff1e7b5da94e18edc20c009ffb46784187.tar.gz
Add a 'circuit breaker' for repo checks
Diffstat (limited to 'app')
-rw-r--r--app/views/admin/application_settings/_form.html.haml13
-rw-r--r--app/workers/repository_check_worker.rb8
2 files changed, 21 insertions, 0 deletions
diff --git a/app/views/admin/application_settings/_form.html.haml b/app/views/admin/application_settings/_form.html.haml
index de86dacbb12..afd88465a78 100644
--- a/app/views/admin/application_settings/_form.html.haml
+++ b/app/views/admin/application_settings/_form.html.haml
@@ -275,5 +275,18 @@
.col-sm-10
= f.text_field :sentry_dsn, class: 'form-control'
+ %fieldset
+ %legend Repository Checks
+ .form-group
+ .col-sm-offset-2.col-sm-10
+ .checkbox
+ = f.label :repository_checks_enabled do
+ = f.check_box :repository_checks_enabled
+ Enable Repository Checks
+ .help-block
+ GitLab will periodically run
+ %a{ href: 'https://www.kernel.org/pub/software/scm/git/docs/git-fsck.html', target: 'blank' } 'git fsck'
+ in all project and wiki repositories to look for silent disk corruption issues.
+
.form-actions
= f.submit 'Save', class: 'btn btn-save'
diff --git a/app/workers/repository_check_worker.rb b/app/workers/repository_check_worker.rb
index afdc6a4c63a..017f49de08c 100644
--- a/app/workers/repository_check_worker.rb
+++ b/app/workers/repository_check_worker.rb
@@ -15,6 +15,7 @@ class RepositoryCheckWorker
# check, only one (or two) will be checked at a time.
project_ids.each do |project_id|
break if Time.now - start >= RUN_TIME
+ break unless current_settings.repository_checks_enabled
next if !try_obtain_lease(project_id)
@@ -45,4 +46,11 @@ class RepositoryCheckWorker
)
lease.try_obtain
end
+
+ def current_settings
+ # No caching of the settings! If we cache them and an admin disables
+ # this feature, an active RepositoryCheckWorker would keep going for up
+ # to 1 hour after the feature was disabled.
+ ApplicationSetting.current || Gitlab::CurrentSettings.fake_application_settings
+ end
end