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
8bceb665
Commit
8bceb665
authored
May 25, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use Geo roles to configure Sidekiq cron jobs
parent
340b2f79
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
4 deletions
+21
-4
config/gitlab.yml.example
config/gitlab.yml.example
+4
-0
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+2
-0
lib/gitlab/geo.rb
lib/gitlab/geo.rb
+6
-2
spec/lib/gitlab/geo_spec.rb
spec/lib/gitlab/geo_spec.rb
+9
-2
No files found.
config/gitlab.yml.example
View file @
8bceb665
...
@@ -623,6 +623,8 @@ production: &base
...
@@ -623,6 +623,8 @@ production: &base
# port: 3808
# port: 3808
## GitLab Geo settings (EE-only)
## GitLab Geo settings (EE-only)
geo_primary_role:
enable: false
geo_secondary_role:
geo_secondary_role:
enable: false
enable: false
...
@@ -709,6 +711,8 @@ test:
...
@@ -709,6 +711,8 @@ test:
user_filter: ''
user_filter: ''
group_base: 'ou=groups,dc=example,dc=com'
group_base: 'ou=groups,dc=example,dc=com'
admin_group: ''
admin_group: ''
geo_primary_role:
enable: true
geo_secondary_role:
geo_secondary_role:
enable: true
enable: true
...
...
config/initializers/1_settings.rb
View file @
8bceb665
...
@@ -342,6 +342,8 @@ Settings.pages['external_https'] ||= false unless Settings.pages['external_http
...
@@ -342,6 +342,8 @@ Settings.pages['external_https'] ||= false unless Settings.pages['external_http
# Geo
# Geo
#
#
Settings
.
gitlab
[
'geo_status_timeout'
]
||=
10
Settings
.
gitlab
[
'geo_status_timeout'
]
||=
10
Settings
[
'geo_primary_role'
]
||=
Settingslogic
.
new
({})
Settings
.
geo_primary_role
[
'enable'
]
=
false
if
Settings
.
geo_primary_role
[
'enable'
].
nil?
Settings
[
'geo_secondary_role'
]
||=
Settingslogic
.
new
({})
Settings
[
'geo_secondary_role'
]
||=
Settingslogic
.
new
({})
Settings
.
geo_secondary_role
[
'enable'
]
=
false
if
Settings
.
geo_secondary_role
[
'enable'
].
nil?
Settings
.
geo_secondary_role
[
'enable'
]
=
false
if
Settings
.
geo_secondary_role
[
'enable'
].
nil?
...
...
lib/gitlab/geo.rb
View file @
8bceb665
...
@@ -46,6 +46,10 @@ module Gitlab
...
@@ -46,6 +46,10 @@ module Gitlab
Rails
.
configuration
.
respond_to?
(
:geo_database
)
Rails
.
configuration
.
respond_to?
(
:geo_database
)
end
end
def
self
.
primary_role_enabled?
Gitlab
.
config
.
geo_primary_role
[
'enable'
]
end
def
self
.
secondary_role_enabled?
def
self
.
secondary_role_enabled?
Gitlab
.
config
.
geo_secondary_role
[
'enable'
]
Gitlab
.
config
.
geo_secondary_role
[
'enable'
]
end
end
...
@@ -98,9 +102,9 @@ module Gitlab
...
@@ -98,9 +102,9 @@ module Gitlab
end
end
def
self
.
configure_cron_jobs!
def
self
.
configure_cron_jobs!
if
self
.
primary?
if
self
.
primary
_role_enabled
?
self
.
configure_primary_jobs!
self
.
configure_primary_jobs!
elsif
self
.
secondary?
elsif
self
.
secondary
_role_enabled
?
self
.
configure_secondary_jobs!
self
.
configure_secondary_jobs!
else
else
self
.
disable_all_jobs!
self
.
disable_all_jobs!
...
...
spec/lib/gitlab/geo_spec.rb
View file @
8bceb665
...
@@ -127,7 +127,9 @@ describe Gitlab::Geo, lib: true do
...
@@ -127,7 +127,9 @@ describe Gitlab::Geo, lib: true do
end
end
it
'activates cron jobs for primary'
do
it
'activates cron jobs for primary'
do
allow
(
described_class
).
to
receive
(
:primary?
).
and_return
(
true
)
allow
(
described_class
).
to
receive
(
:primary_role_enabled?
).
and_return
(
true
)
allow
(
described_class
).
to
receive
(
:secondary_role_enabled?
).
and_return
(
false
)
described_class
.
configure_cron_jobs!
described_class
.
configure_cron_jobs!
expect
(
described_class
.
bulk_notify_job
).
to
be_enabled
expect
(
described_class
.
bulk_notify_job
).
to
be_enabled
...
@@ -136,7 +138,9 @@ describe Gitlab::Geo, lib: true do
...
@@ -136,7 +138,9 @@ describe Gitlab::Geo, lib: true do
end
end
it
'activates cron jobs for secondary'
do
it
'activates cron jobs for secondary'
do
allow
(
described_class
).
to
receive
(
:secondary?
).
and_return
(
true
)
allow
(
described_class
).
to
receive
(
:primary_role_enabled?
).
and_return
(
false
)
allow
(
described_class
).
to
receive
(
:secondary_role_enabled?
).
and_return
(
true
)
described_class
.
configure_cron_jobs!
described_class
.
configure_cron_jobs!
expect
(
described_class
.
bulk_notify_job
).
not_to
be_enabled
expect
(
described_class
.
bulk_notify_job
).
not_to
be_enabled
...
@@ -145,6 +149,9 @@ describe Gitlab::Geo, lib: true do
...
@@ -145,6 +149,9 @@ describe Gitlab::Geo, lib: true do
end
end
it
'deactivates all jobs when Geo is not active'
do
it
'deactivates all jobs when Geo is not active'
do
allow
(
described_class
).
to
receive
(
:primary_role_enabled?
).
and_return
(
false
)
allow
(
described_class
).
to
receive
(
:secondary_role_enabled?
).
and_return
(
false
)
described_class
.
configure_cron_jobs!
described_class
.
configure_cron_jobs!
expect
(
described_class
.
bulk_notify_job
).
not_to
be_enabled
expect
(
described_class
.
bulk_notify_job
).
not_to
be_enabled
...
...
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