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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
3066de95
Commit
3066de95
authored
May 03, 2018
by
Toon Claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename methods to make it more clear what they do
parent
0bfc2b14
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
12 deletions
+14
-12
app/workers/repository_check/batch_worker.rb
app/workers/repository_check/batch_worker.rb
+6
-4
app/workers/repository_check/single_repository_worker.rb
app/workers/repository_check/single_repository_worker.rb
+8
-8
No files found.
app/workers/repository_check/batch_worker.rb
View file @
3066de95
...
...
@@ -16,7 +16,7 @@ module RepositoryCheck
# projects to check. By default sidekiq-cron will start a new
# RepositoryCheckWorker each hour so that as long as there are repositories to
# check, only one (or two) will be checked at a time.
find_batch
.
each
do
|
project_id
|
project_ids
.
each
do
|
project_id
|
break
if
Time
.
now
-
start
>=
RUN_TIME
next
unless
try_obtain_lease
(
project_id
)
...
...
@@ -32,7 +32,7 @@ module RepositoryCheck
# array of ID's. This is OK because we do it only once an hour, because
# getting ID's from Postgres is not terribly slow, and because no user
# has to sit and wait for this query to finish.
def
find_batch
(
batch_size
=
BATCH_SIZE
)
def
project_ids
(
batch_size
=
BATCH_SIZE
)
project_ids
=
never_checked_project_ids
(
batch_size
)
remaining_capacity
=
batch_size
-
project_ids
.
count
...
...
@@ -45,12 +45,14 @@ module RepositoryCheck
end
def
never_checked_project_ids
(
batch_size
)
Project
.
where
(
'last_repository_check_at IS NULL AND created_at < ?'
,
24
.
hours
.
ago
)
Project
.
where
(
last_repository_check_at:
nil
)
.
where
(
'created_at < ?'
,
24
.
hours
.
ago
)
.
limit
(
batch_size
).
pluck
(
:id
)
end
def
old_checked_project_ids
(
batch_size
)
Project
.
where
(
'last_repository_check_at < ?'
,
1
.
month
.
ago
)
Project
.
where
.
not
(
last_repository_check_at:
nil
)
.
where
(
'last_repository_check_at < ?'
,
1
.
month
.
ago
)
.
reorder
(
last_repository_check_at: :asc
)
.
limit
(
batch_size
).
pluck
(
:id
)
end
...
...
app/workers/repository_check/single_repository_worker.rb
View file @
3066de95
...
...
@@ -5,31 +5,31 @@ module RepositoryCheck
def
perform
(
project_id
)
project
=
Project
.
find
(
project_id
)
result
=
check
(
project
)
healthy
=
project_healthy?
(
project
)
save_result
(
project
,
result
)
update_repository_check_status
(
project
,
healthy
)
end
private
def
save_result
(
project
,
result
)
def
update_repository_check_status
(
project
,
healthy
)
project
.
update_columns
(
last_repository_check_failed:
!
result
,
last_repository_check_failed:
!
healthy
,
last_repository_check_at:
Time
.
now
)
end
def
check
(
project
)
check_repo
(
project
)
&&
check_wiki_repo
(
project
)
def
project_healthy?
(
project
)
repo_healthy?
(
project
)
&&
wiki_repo_healthy?
(
project
)
end
def
check_repo
(
project
)
def
repo_healthy?
(
project
)
return
true
if
project
.
empty_repo?
git_fsck
(
project
.
repository
)
end
def
check_wiki_repo
(
project
)
def
wiki_repo_healthy?
(
project
)
return
true
unless
project
.
wiki_enabled?
# Historically some projects never had their wiki repos initialized;
...
...
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