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
4c50e915
Commit
4c50e915
authored
Feb 05, 2017
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
applies changes to gitlab settings and gitlab yaml file
parent
24cb7c63
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
20 additions
and
27 deletions
+20
-27
app/models/remote_mirror.rb
app/models/remote_mirror.rb
+0
-4
app/views/projects/mirrors/show.html.haml
app/views/projects/mirrors/show.html.haml
+2
-2
app/workers/update_all_mirrors_worker.rb
app/workers/update_all_mirrors_worker.rb
+2
-3
app/workers/update_all_remote_mirrors_worker.rb
app/workers/update_all_remote_mirrors_worker.rb
+1
-1
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+0
-6
config/initializers/sidekiq.rb
config/initializers/sidekiq.rb
+4
-0
lib/gitlab/mirror.rb
lib/gitlab/mirror.rb
+3
-3
spec/controllers/projects/mirrors_controller_spec.rb
spec/controllers/projects/mirrors_controller_spec.rb
+1
-1
spec/workers/update_all_mirrors_worker_spec.rb
spec/workers/update_all_mirrors_worker_spec.rb
+4
-4
spec/workers/update_all_remote_mirrors_worker.rb
spec/workers/update_all_remote_mirrors_worker.rb
+3
-3
No files found.
app/models/remote_mirror.rb
View file @
4c50e915
class
RemoteMirror
<
ActiveRecord
::
Base
include
AfterCommitQueue
include
Gitlab
::
ConfigHelper
include
Gitlab
::
CurrentSettings
extend
Gitlab
::
ConfigHelper
attr_encrypted
:credentials
,
key:
Gitlab
::
Application
.
secrets
.
db_key_base
,
...
...
app/views/projects/mirrors/show.html.haml
View file @
4c50e915
...
...
@@ -46,7 +46,7 @@
-
if
@project
.
builds_enabled?
=
render
"shared/mirror_trigger_builds_setting"
,
f:
f
.form-group
=
f
.
label
:sync_time
,
"Synchroni
s
ation time"
,
class:
"label-light append-bottom-0"
=
f
.
label
:sync_time
,
"Synchroni
z
ation time"
,
class:
"label-light append-bottom-0"
=
f
.
select
:sync_time
,
options_for_select
(
Gitlab
::
Mirror
.
sync_time_options
,
@project
.
sync_time
),
{},
class:
'form-control'
.col-sm-12
%hr
...
...
@@ -81,7 +81,7 @@
=
rm_form
.
text_field
:url
,
class:
"form-control"
,
placeholder:
'https://username:password@gitlab.company.com/group/project.git'
=
render
"instructions"
.form-group
=
rm_form
.
label
:sync_time
,
"Synchroni
s
ation time"
,
class:
"label-light append-bottom-0"
=
rm_form
.
label
:sync_time
,
"Synchroni
z
ation time"
,
class:
"label-light append-bottom-0"
=
rm_form
.
select
:sync_time
,
options_for_select
(
Gitlab
::
Mirror
.
sync_time_options
,
@remote_mirror
.
sync_time
),
{},
class:
'form-control'
.col-sm-12.text-center
%hr
...
...
app/workers/update_all_mirrors_worker.rb
View file @
4c50e915
...
...
@@ -2,7 +2,7 @@ class UpdateAllMirrorsWorker
include
Sidekiq
::
Worker
include
CronjobQueue
LEASE_TIMEOUT
=
360
0
LEASE_TIMEOUT
=
84
0
def
perform
return
unless
try_obtain_lease
...
...
@@ -27,11 +27,10 @@ class UpdateAllMirrorsWorker
private
def
mirrors_to_sync
Project
.
mirror
.
where
(
sync_time:
Gitlab
::
Mirror
.
sync_times
)
Project
.
mirror
.
where
(
"NOW() >= mirror_last_update_at + sync_time * interval '1 minute' OR sync_time IN (?)"
,
Gitlab
::
Mirror
.
sync_times
)
end
def
try_obtain_lease
# Using 30 minutes timeout based on the 95th percent of timings (currently max of 10 minutes)
lease
=
::
Gitlab
::
ExclusiveLease
.
new
(
"update_all_mirrors"
,
timeout:
LEASE_TIMEOUT
)
lease
.
try_obtain
end
...
...
app/workers/update_all_remote_mirrors_worker.rb
View file @
4c50e915
...
...
@@ -17,6 +17,6 @@ class UpdateAllRemoteMirrorsWorker
private
def
remote_mirrors_to_sync
RemoteMirror
.
where
(
sync_time:
Gitlab
::
Mirror
.
sync_times
)
RemoteMirror
.
where
(
"NOW() >= updated_at + sync_time * interval '1 minute' OR sync_time IN (?)"
,
Gitlab
::
Mirror
.
sync_times
)
end
end
config/initializers/1_settings.rb
View file @
4c50e915
...
...
@@ -370,12 +370,6 @@ Settings.cron_jobs['repository_archive_cache_worker']['job_class'] = 'Repository
Settings
.
cron_jobs
[
'historical_data_worker'
]
||=
Settingslogic
.
new
({})
Settings
.
cron_jobs
[
'historical_data_worker'
][
'cron'
]
||=
'0 12 * * *'
Settings
.
cron_jobs
[
'historical_data_worker'
][
'job_class'
]
=
'HistoricalDataWorker'
Settings
.
cron_jobs
[
'update_all_mirrors_worker'
]
||=
Settingslogic
.
new
({})
Settings
.
cron_jobs
[
'update_all_mirrors_worker'
][
'cron'
]
||=
'*/15 * * * *'
Settings
.
cron_jobs
[
'update_all_mirrors_worker'
][
'job_class'
]
=
'UpdateAllMirrorsWorker'
Settings
.
cron_jobs
[
'update_all_remote_mirrors_worker'
]
||=
Settingslogic
.
new
({})
Settings
.
cron_jobs
[
'update_all_remote_mirrors_worker'
][
'cron'
]
||=
'*/15 * * * *'
Settings
.
cron_jobs
[
'update_all_remote_mirrors_worker'
][
'job_class'
]
=
'UpdateAllRemoteMirrorsWorker'
Settings
.
cron_jobs
[
'ldap_sync_worker'
]
||=
Settingslogic
.
new
({})
Settings
.
cron_jobs
[
'ldap_sync_worker'
][
'cron'
]
||=
'30 1 * * *'
Settings
.
cron_jobs
[
'ldap_sync_worker'
][
'job_class'
]
=
'LdapSyncWorker'
...
...
config/initializers/sidekiq.rb
View file @
4c50e915
...
...
@@ -34,6 +34,10 @@ Sidekiq.configure_server do |config|
end
Sidekiq
::
Cron
::
Job
.
load_from_hash!
cron_jobs
# These jobs should not be allowed to be configured in gitlab.yml
Sidekiq
::
Cron
::
Job
.
create
(
name:
'update_all_remote_mirrors_worker'
,
cron:
'*/15 * * * *'
,
class:
'UpdateAllRemoteMirrorsWorker'
)
Sidekiq
::
Cron
::
Job
.
create
(
name:
'update_all_mirrors_worker'
,
cron:
'*/15 * * * *'
,
class:
'UpdateAllMirrorsWorker'
)
# Gitlab Geo: enable bulk notify job only on primary node
Gitlab
::
Geo
.
bulk_notify_job
.
disable!
unless
Gitlab
::
Geo
.
primary?
...
...
lib/gitlab/mirror.rb
View file @
4c50e915
...
...
@@ -2,7 +2,7 @@ module Gitlab
module
Mirror
FIFTEEN
=
15
HOURLY
=
60
DA
YLY
=
1440
DA
ILY
=
1440
INTERVAL_BEFORE_FIFTEEN
=
14
.
minutes
...
...
@@ -11,13 +11,13 @@ module Gitlab
{
"Update every 15 minutes"
=>
FIFTEEN
,
"Update hourly"
=>
HOURLY
,
"Update every day"
=>
DA
Y
LY
,
"Update every day"
=>
DA
I
LY
,
}
end
def
sync_times
sync_times
=
[
FIFTEEN
]
sync_times
<<
DA
Y
LY
if
at_beginning_of_day?
sync_times
<<
DA
I
LY
if
at_beginning_of_day?
sync_times
<<
HOURLY
if
at_beginning_of_hour?
sync_times
...
...
spec/controllers/projects/mirrors_controller_spec.rb
View file @
4c50e915
require
'spec_helper'
describe
Projects
::
MirrorsController
do
let
(
:sync_times
)
{
[
Gitlab
::
Mirror
::
FIFTEEN
,
Gitlab
::
Mirror
::
HOURLY
,
Gitlab
::
Mirror
::
DAYLY
]
}
let
(
:sync_times
)
{
Gitlab
::
Mirror
.
sync_time_options
.
values
}
describe
'setting up a mirror'
do
context
'when the current project is a mirror'
do
...
...
spec/workers/update_all_mirrors_worker_spec.rb
View file @
4c50e915
...
...
@@ -7,15 +7,15 @@ describe UpdateAllMirrorsWorker do
end
describe
'#perform'
do
PROJECT_COUNT_WITH_TIME
=
{
DateTime
.
now
.
beginning_of_hour
+
15
.
minutes
=>
1
,
project_count_with_time
=
{
DateTime
.
now
.
beginning_of_hour
+
15
.
minutes
=>
1
,
DateTime
.
now
.
beginning_of_hour
=>
2
,
DateTime
.
now
.
beginning_of_day
=>
3
}
let!
(
:mirror1
)
{
create
(
:empty_project
,
:mirror
,
sync_time:
Gitlab
::
Mirror
::
FIFTEEN
)
}
let!
(
:mirror2
)
{
create
(
:empty_project
,
:mirror
,
sync_time:
Gitlab
::
Mirror
::
HOURLY
)
}
let!
(
:mirror3
)
{
create
(
:empty_project
,
:mirror
,
sync_time:
Gitlab
::
Mirror
::
DA
Y
LY
)
}
let
(
:mirrors
)
{
Project
.
where
(
mirror:
true
,
sync_time:
Gitlab
::
Mirror
.
sync_times
)
}
let!
(
:mirror3
)
{
create
(
:empty_project
,
:mirror
,
sync_time:
Gitlab
::
Mirror
::
DA
I
LY
)
}
let
(
:mirrors
)
{
Project
.
mirror
.
where
(
sync_time:
Gitlab
::
Mirror
.
sync_times
)
}
it
'fails stuck mirrors'
do
worker
=
described_class
.
new
...
...
@@ -25,7 +25,7 @@ describe UpdateAllMirrorsWorker do
worker
.
perform
end
PROJECT_COUNT_WITH_TIME
.
each
do
|
time
,
project_count
|
project_count_with_time
.
each
do
|
time
,
project_count
|
describe
"at
#{
time
}
"
do
before
do
allow
(
DateTime
).
to
receive
(
:now
).
and_return
(
time
)
...
...
spec/workers/update_all_remote_mirrors_worker.rb
View file @
4c50e915
...
...
@@ -2,14 +2,14 @@ require 'rails_helper'
describe
UpdateAllRemoteMirrorsWorker
do
describe
"#perform"
do
PROJECT_COUNT_WITH_TIME
=
{
DateTime
.
now
.
beginning_of_hour
+
15
.
minutes
=>
1
,
project_count_with_time
=
{
DateTime
.
now
.
beginning_of_hour
+
15
.
minutes
=>
1
,
DateTime
.
now
.
beginning_of_hour
=>
2
,
DateTime
.
now
.
beginning_of_day
=>
3
}
let!
(
:mirror1
)
{
create
(
:project
,
:remote_mirror
,
sync_time:
Gitlab
::
Mirror
::
FIFTEEN
)
}
let!
(
:mirror2
)
{
create
(
:project
,
:remote_mirror
,
sync_time:
Gitlab
::
Mirror
::
HOURLY
)
}
let!
(
:mirror3
)
{
create
(
:project
,
:remote_mirror
,
sync_time:
Gitlab
::
Mirror
::
DA
Y
LY
)
}
let!
(
:mirror3
)
{
create
(
:project
,
:remote_mirror
,
sync_time:
Gitlab
::
Mirror
::
DA
I
LY
)
}
let
(
:mirrors
)
{
RemoteMirror
.
where
(
sync_time:
Gitlab
::
Mirror
.
sync_times
)
}
it
'fails stuck mirrors'
do
...
...
@@ -20,7 +20,7 @@ describe UpdateAllRemoteMirrorsWorker do
worker
.
perform
end
PROJECT_COUNT_WITH_TIME
.
each
do
|
time
,
project_count
|
project_count_with_time
.
each
do
|
time
,
project_count
|
describe
"at
#{
time
}
"
do
before
do
allow
(
DateTime
).
to
receive
(
:now
).
and_return
(
time
)
...
...
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