Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
97f4ffff
Commit
97f4ffff
authored
Apr 12, 2016
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a 'circuit breaker' for repo checks
parent
b37d3b94
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
1 deletion
+31
-1
app/views/admin/application_settings/_form.html.haml
app/views/admin/application_settings/_form.html.haml
+13
-0
app/workers/repository_check_worker.rb
app/workers/repository_check_worker.rb
+8
-0
lib/gitlab/current_settings.rb
lib/gitlab/current_settings.rb
+2
-1
spec/workers/repository_check_worker_spec.rb
spec/workers/repository_check_worker_spec.rb
+8
-0
No files found.
app/views/admin/application_settings/_form.html.haml
View file @
97f4ffff
...
...
@@ -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'
app/workers/repository_check_worker.rb
View file @
97f4ffff
...
...
@@ -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
lib/gitlab/current_settings.rb
View file @
97f4ffff
...
...
@@ -34,7 +34,8 @@ module Gitlab
max_artifacts_size:
Settings
.
artifacts
[
'max_size'
],
require_two_factor_authentication:
false
,
two_factor_grace_period:
48
,
akismet_enabled:
false
akismet_enabled:
false
,
repository_checks_enabled:
true
,
)
end
...
...
spec/workers/repository_check_worker_spec.rb
View file @
97f4ffff
...
...
@@ -28,4 +28,12 @@ describe RepositoryCheckWorker do
expect
(
subject
.
perform
).
to
eq
([
projects
[
1
].
id
])
end
it
'does nothing when repository checks are disabled'
do
create
(
:empty_project
)
current_settings
=
double
(
'settings'
,
repository_checks_enabled:
false
)
expect
(
subject
).
to
receive
(
:current_settings
)
{
current_settings
}
expect
(
subject
.
perform
).
to
eq
(
nil
)
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment