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
5948a497
Commit
5948a497
authored
Aug 01, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
392178e5
536ebecf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
45 deletions
+3
-45
app/models/namespace/aggregation_schedule.rb
app/models/namespace/aggregation_schedule.rb
+3
-11
spec/models/namespace/aggregation_schedule_spec.rb
spec/models/namespace/aggregation_schedule_spec.rb
+0
-34
No files found.
app/models/namespace/aggregation_schedule.rb
View file @
5948a497
...
...
@@ -6,21 +6,13 @@ class Namespace::AggregationSchedule < ApplicationRecord
self
.
primary_key
=
:namespace_id
DEFAULT_LEASE_TIMEOUT
=
3
.
hours
DEFAULT_LEASE_TIMEOUT
=
1.5
.
hours
.
to_i
REDIS_SHARED_KEY
=
'gitlab:update_namespace_statistics_delay'
.
freeze
belongs_to
:namespace
after_create
:schedule_root_storage_statistics
def
self
.
delay_timeout
redis_timeout
=
Gitlab
::
Redis
::
SharedState
.
with
do
|
redis
|
redis
.
get
(
REDIS_SHARED_KEY
)
end
redis_timeout
.
nil?
?
DEFAULT_LEASE_TIMEOUT
:
redis_timeout
.
to_i
end
def
schedule_root_storage_statistics
run_after_commit_or_now
do
try_obtain_lease
do
...
...
@@ -28,7 +20,7 @@ class Namespace::AggregationSchedule < ApplicationRecord
.
perform_async
(
namespace_id
)
Namespaces
::
RootStatisticsWorker
.
perform_in
(
self
.
class
.
delay_timeout
,
namespace_id
)
.
perform_in
(
DEFAULT_LEASE_TIMEOUT
,
namespace_id
)
end
end
end
...
...
@@ -37,7 +29,7 @@ class Namespace::AggregationSchedule < ApplicationRecord
# Used by ExclusiveLeaseGuard
def
lease_timeout
self
.
class
.
delay_timeout
DEFAULT_LEASE_TIMEOUT
end
# Used by ExclusiveLeaseGuard
...
...
spec/models/namespace/aggregation_schedule_spec.rb
View file @
5948a497
...
...
@@ -7,24 +7,6 @@ RSpec.describe Namespace::AggregationSchedule, :clean_gitlab_redis_shared_state,
it
{
is_expected
.
to
belong_to
:namespace
}
describe
'.delay_timeout'
do
context
'when timeout is set on redis'
do
it
'uses personalized timeout'
do
Gitlab
::
Redis
::
SharedState
.
with
do
|
redis
|
redis
.
set
(
described_class
::
REDIS_SHARED_KEY
,
1
.
hour
)
end
expect
(
described_class
.
delay_timeout
).
to
eq
(
1
.
hour
)
end
end
context
'when timeout is not set on redis'
do
it
'uses default timeout'
do
expect
(
described_class
.
delay_timeout
).
to
eq
(
3
.
hours
)
end
end
end
describe
'#schedule_root_storage_statistics'
do
let
(
:namespace
)
{
create
(
:namespace
)
}
let
(
:aggregation_schedule
)
{
namespace
.
build_aggregation_schedule
}
...
...
@@ -87,21 +69,5 @@ RSpec.describe Namespace::AggregationSchedule, :clean_gitlab_redis_shared_state,
aggregation_schedule
.
schedule_root_storage_statistics
end
end
context
'with a personalized lease timeout'
do
before
do
Gitlab
::
Redis
::
SharedState
.
with
do
|
redis
|
redis
.
set
(
described_class
::
REDIS_SHARED_KEY
,
1
.
hour
)
end
end
it
'uses a personalized time'
do
expect
(
Namespaces
::
RootStatisticsWorker
)
.
to
receive
(
:perform_in
)
.
with
(
1
.
hour
,
aggregation_schedule
.
namespace_id
)
aggregation_schedule
.
save!
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