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
Léo-Paul Géneau
gitlab-ce
Commits
0736397e
Commit
0736397e
authored
Jul 12, 2016
by
Paco Guzman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reset project pushes_since_gc when we enqueue the git gc call
parent
97999fd4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
19 deletions
+48
-19
CHANGELOG
CHANGELOG
+1
-0
app/services/projects/housekeeping_service.rb
app/services/projects/housekeeping_service.rb
+14
-10
spec/services/projects/housekeeping_service_spec.rb
spec/services/projects/housekeeping_service_spec.rb
+33
-9
No files found.
CHANGELOG
View file @
0736397e
...
@@ -75,6 +75,7 @@ v 8.10.0 (unreleased)
...
@@ -75,6 +75,7 @@ v 8.10.0 (unreleased)
- Fix 404 redirect after validation fails importing a GitLab project
- Fix 404 redirect after validation fails importing a GitLab project
- Added setting to set new users by default as external !4545 (Dravere)
- Added setting to set new users by default as external !4545 (Dravere)
- Add min value for project limit field on user's form !3622 (jastkand)
- Add min value for project limit field on user's form !3622 (jastkand)
- Reset project pushes_since_gc when we enqueue the git gc call
- Add reminder to not paste private SSH keys !4399 (Ingo Blechschmidt)
- Add reminder to not paste private SSH keys !4399 (Ingo Blechschmidt)
- Remove duplicate `description` field in `MergeRequest` entities (Ben Boeckel)
- Remove duplicate `description` field in `MergeRequest` entities (Ben Boeckel)
- Style of import project buttons were fixed in the new project page. !5183 (rdemirbay)
- Style of import project buttons were fixed in the new project page. !5183 (rdemirbay)
...
...
app/services/projects/housekeeping_service.rb
View file @
0736397e
...
@@ -22,11 +22,7 @@ module Projects
...
@@ -22,11 +22,7 @@ module Projects
def
execute
def
execute
raise
LeaseTaken
unless
try_obtain_lease
raise
LeaseTaken
unless
try_obtain_lease
GitGarbageCollectWorker
.
perform_async
(
@project
.
id
)
execute_gitlab_shell_gc
ensure
Gitlab
::
Metrics
.
measure
(
:reset_pushes_since_gc
)
do
update_pushes_since_gc
(
0
)
end
end
end
def
needed?
def
needed?
...
@@ -34,18 +30,26 @@ module Projects
...
@@ -34,18 +30,26 @@ module Projects
end
end
def
increment!
def
increment!
if
Gitlab
::
ExclusiveLease
.
new
(
"project_housekeeping:increment!:
#{
@project
.
id
}
"
,
timeout:
60
).
try_obtain
Gitlab
::
Metrics
.
measure
(
:increment_pushes_since_gc
)
do
Gitlab
::
Metrics
.
measure
(
:increment_pushes_since_gc
)
do
update_pushes_since_gc
(
@project
.
pushes_since_gc
+
1
)
update_pushes_since_gc
(
@project
.
pushes_since_gc
+
1
)
end
end
end
end
end
private
private
def
execute_gitlab_shell_gc
GitGarbageCollectWorker
.
perform_async
(
@project
.
id
)
ensure
Gitlab
::
Metrics
.
measure
(
:reset_pushes_since_gc
)
do
update_pushes_since_gc
(
0
)
end
end
def
update_pushes_since_gc
(
new_value
)
def
update_pushes_since_gc
(
new_value
)
if
Gitlab
::
ExclusiveLease
.
new
(
"project_housekeeping:update_pushes_since_gc:
#{
project
.
id
}
"
,
timeout:
60
).
try_obtain
@project
.
update_column
(
:pushes_since_gc
,
new_value
)
@project
.
update_column
(
:pushes_since_gc
,
new_value
)
end
end
end
def
try_obtain_lease
def
try_obtain_lease
Gitlab
::
Metrics
.
measure
(
:obtain_housekeeping_lease
)
do
Gitlab
::
Metrics
.
measure
(
:obtain_housekeeping_lease
)
do
...
...
spec/services/projects/housekeeping_service_spec.rb
View file @
0736397e
...
@@ -15,15 +15,25 @@ describe Projects::HousekeepingService do
...
@@ -15,15 +15,25 @@ describe Projects::HousekeepingService do
expect
(
GitGarbageCollectWorker
).
to
receive
(
:perform_async
).
with
(
project
.
id
)
expect
(
GitGarbageCollectWorker
).
to
receive
(
:perform_async
).
with
(
project
.
id
)
subject
.
execute
subject
.
execute
expect
(
project
.
pushes_since_gc
).
to
eq
(
0
)
expect
(
project
.
reload
.
pushes_since_gc
).
to
eq
(
0
)
end
end
it
'does not enqueue a job when no lease can be obtained'
do
context
'when no lease can be obtained'
do
before
(
:each
)
do
expect
(
subject
).
to
receive
(
:try_obtain_lease
).
and_return
(
false
)
expect
(
subject
).
to
receive
(
:try_obtain_lease
).
and_return
(
false
)
end
it
'does not enqueue a job'
do
expect
(
GitGarbageCollectWorker
).
not_to
receive
(
:perform_async
)
expect
(
GitGarbageCollectWorker
).
not_to
receive
(
:perform_async
)
expect
{
subject
.
execute
}.
to
raise_error
(
Projects
::
HousekeepingService
::
LeaseTaken
)
expect
{
subject
.
execute
}.
to
raise_error
(
Projects
::
HousekeepingService
::
LeaseTaken
)
expect
(
project
.
pushes_since_gc
).
to
eq
(
0
)
end
it
'does not reset pushes_since_gc'
do
expect
do
expect
{
subject
.
execute
}.
to
raise_error
(
Projects
::
HousekeepingService
::
LeaseTaken
)
end
.
not_to
change
{
project
.
pushes_since_gc
}.
from
(
3
)
end
end
end
end
end
...
@@ -39,10 +49,24 @@ describe Projects::HousekeepingService do
...
@@ -39,10 +49,24 @@ describe Projects::HousekeepingService do
end
end
describe
'increment!'
do
describe
'increment!'
do
let
(
:lease_key
)
{
"project_housekeeping:increment!:
#{
project
.
id
}
"
}
it
'increments the pushes_since_gc counter'
do
it
'increments the pushes_since_gc counter'
do
expect
(
project
.
pushes_since_gc
).
to
eq
(
0
)
lease
=
double
(
:lease
,
try_obtain:
true
)
expect
(
Gitlab
::
ExclusiveLease
).
to
receive
(
:new
).
with
(
lease_key
,
anything
).
and_return
(
lease
)
expect
do
subject
.
increment!
end
.
to
change
{
project
.
pushes_since_gc
}.
from
(
0
).
to
(
1
)
end
it
'does not increment when no lease can be obtained'
do
lease
=
double
(
:lease
,
try_obtain:
false
)
expect
(
Gitlab
::
ExclusiveLease
).
to
receive
(
:new
).
with
(
lease_key
,
anything
).
and_return
(
lease
)
expect
do
subject
.
increment!
subject
.
increment!
e
xpect
(
project
.
pushes_since_gc
).
to
eq
(
1
)
e
nd
.
not_to
change
{
project
.
pushes_since_gc
}
end
end
end
end
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