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
04aff518
Commit
04aff518
authored
May 09, 2018
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added geo:git:housekeeping:* rake tasks
parent
1e63d87b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
1 deletion
+69
-1
ee/app/models/geo/project_registry.rb
ee/app/models/geo/project_registry.rb
+7
-1
ee/lib/tasks/geo/git.rake
ee/lib/tasks/geo/git.rake
+28
-0
ee/spec/tasks/geo/git_rake_spec.rb
ee/spec/tasks/geo/git_rake_spec.rb
+34
-0
No files found.
ee/app/models/geo/project_registry.rb
View file @
04aff518
...
...
@@ -72,10 +72,16 @@ class Geo::ProjectRegistry < Geo::BaseRegistry
Gitlab
::
Redis
::
SharedState
.
with
{
|
redis
|
redis
.
del
(
fetches_since_gc_redis_key
)
}
end
def
set_syncs_since_gc!
(
value
)
return
false
if
!
value
.
is_a?
(
Integer
)
||
value
<
0
Gitlab
::
Redis
::
SharedState
.
with
{
|
redis
|
redis
.
set
(
fetches_since_gc_redis_key
,
value
)
}
end
private
def
fetches_since_gc_redis_key
"projects/
#{
project
.
id
}
/fetches_since_gc"
"projects/
#{
project
_
id
}
/fetches_since_gc"
end
def
never_synced_repository?
...
...
ee/lib/tasks/geo/git.rake
0 → 100644
View file @
04aff518
namespace
:geo
do
namespace
:git
do
namespace
:housekeeping
do
desc
"GitLab | Git | Housekeeping | Garbage Collection"
task
gc: :gitlab_environment
do
flag_for_housekeeping
(
Gitlab
::
CurrentSettings
.
housekeeping_gc_period
)
end
desc
"GitLab | Git | Housekeeping | Full Repack"
task
full_repack: :gitlab_environment
do
flag_for_housekeeping
(
Gitlab
::
CurrentSettings
.
housekeeping_full_repack_period
)
end
desc
"GitLab | Git | Housekeeping | Incremental Repack"
task
incremental_repack: :gitlab_environment
do
flag_for_housekeeping
(
Gitlab
::
CurrentSettings
.
housekeeping_incremental_repack_period
)
end
def
flag_for_housekeeping
(
period
)
Geo
::
ProjectRegistry
.
select
(
:id
,
:project_id
).
find_in_batches
do
|
batches
|
batches
.
each
do
|
registry
|
registry
.
set_syncs_since_gc!
(
period
-
1
)
end
end
end
end
end
end
ee/spec/tasks/geo/git_rake_spec.rb
0 → 100644
View file @
04aff518
require
'rake_helper'
describe
'geo:git:housekeeping'
do
set
(
:project
)
{
create
(
:project
,
:repository
)
}
set
(
:registry
)
{
::
Geo
::
ProjectRegistry
.
find_or_create_by!
(
project:
project
)
}
shared_examples
'housekeeping task'
do
|
task_name
,
period_name
|
it
"sets existing projects syncs_gc count to
#{
period_name
}
-1"
do
period
=
Gitlab
::
CurrentSettings
.
send
(
period_name
)
expect
{
run_rake_task
(
task_name
)
}.
to
change
{
registry
.
syncs_since_gc
}.
to
(
period
-
1
)
end
end
before
do
Rake
.
application
.
rake_require
'tasks/geo/git'
end
after
do
registry
.
reset_syncs_since_gc!
end
describe
'geo:git:housekeeping:gc'
do
it_behaves_like
'housekeeping task'
,
'geo:git:housekeeping:gc'
,
:housekeeping_gc_period
end
describe
'geo:git:housekeeping:full_repack'
do
it_behaves_like
'housekeeping task'
,
'geo:git:housekeeping:full_repack'
,
:housekeeping_full_repack_period
end
describe
'geo:git:housekeeping:incremental_repack'
do
it_behaves_like
'housekeeping task'
,
'geo:git:housekeeping:incremental_repack'
,
:housekeeping_incremental_repack_period
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