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
0cd84ba4
Commit
0cd84ba4
authored
Jan 30, 2017
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adds remote sync time feature
parent
7aed5e9f
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
21 additions
and
11 deletions
+21
-11
app/controllers/projects/mirrors_controller.rb
app/controllers/projects/mirrors_controller.rb
+1
-1
app/models/remote_mirror.rb
app/models/remote_mirror.rb
+8
-0
app/views/projects/mirrors/show.html.haml
app/views/projects/mirrors/show.html.haml
+3
-0
app/workers/update_all_remote_mirrors_worker.rb
app/workers/update_all_remote_mirrors_worker.rb
+7
-1
config/gitlab.yml.example
config/gitlab.yml.example
+0
-8
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+1
-1
db/schema.rb
db/schema.rb
+1
-0
No files found.
app/controllers/projects/mirrors_controller.rb
View file @
0cd84ba4
...
...
@@ -48,6 +48,6 @@ class Projects::MirrorsController < Projects::ApplicationController
def
mirror_params
params
.
require
(
:project
).
permit
(
:mirror
,
:import_url
,
:mirror_user_id
,
:mirror_trigger_builds
,
:sync_time
,
remote_mirrors_attributes:
[
:url
,
:id
,
:enabled
])
remote_mirrors_attributes:
[
:url
,
:id
,
:enabled
,
:remote_sync_time
])
end
end
app/models/remote_mirror.rb
View file @
0cd84ba4
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
,
...
...
@@ -11,7 +15,11 @@ class RemoteMirror < ActiveRecord::Base
belongs_to
:project
,
inverse_of: :remote_mirrors
default_value_for
:remote_sync_time
,
gitlab_config_features
.
sync_time
validates
:url
,
presence:
true
,
url:
{
protocols:
%w(ssh git http https)
,
allow_blank:
true
}
validates
:remote_sync_time
,
presence:
true
,
inclusion:
{
in:
Gitlab
::
Mirror
.
sync_time_options
.
values
}
validate
:url_availability
,
if:
->
(
mirror
)
{
mirror
.
url_changed?
||
mirror
.
enabled?
}
after_save
:refresh_remote
,
if: :mirror_url_changed?
...
...
app/views/projects/mirrors/show.html.haml
View file @
0cd84ba4
...
...
@@ -80,6 +80,9 @@
=
rm_form
.
label
:url
,
"Git repository URL"
,
class:
"label-light"
=
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
:remote_sync_time
,
"Remote Mirror synchronisation time"
,
class:
"label-light append-bottom-0"
=
rm_form
.
select
:remote_sync_time
,
options_for_select
(
Gitlab
::
Mirror
.
sync_time_options
,
@remote_mirror
.
remote_sync_time
),
{},
class:
'form-control'
.col-sm-12.text-center
%hr
=
f
.
submit
'Save changes'
,
class:
'btn btn-create'
,
name:
'update_remote_mirror'
app/workers/update_all_remote_mirrors_worker.rb
View file @
0cd84ba4
...
...
@@ -5,7 +5,7 @@ class UpdateAllRemoteMirrorsWorker
def
perform
fail_stuck_mirrors!
RemoteMirror
.
find_each
(
batch_size:
50
).
each
(
&
:sync
)
remote_mirrors_to_sync
.
find_each
(
batch_size:
50
).
each
(
&
:sync
)
end
def
fail_stuck_mirrors!
...
...
@@ -13,4 +13,10 @@ class UpdateAllRemoteMirrorsWorker
remote_mirror
.
mark_as_failed
(
'The mirror update took too long to complete.'
)
end
end
private
def
remote_mirrors_to_sync
RemoteMirror
.
where
(
remote_sync_time:
Gitlab
::
Mirror
.
sync_times
)
end
end
config/gitlab.yml.example
View file @
0cd84ba4
...
...
@@ -210,14 +210,6 @@ production: &base
historical_data_worker:
cron: "0 12 * * *"
# Update mirrored repositories
update_all_mirrors_worker:
cron: "*/15 * * * *"
# Update remote mirrors
update_all_remote_mirrors_worker:
cron: "30 * * * *"
# In addition to refreshing users when they log in,
# periodically refresh LDAP users membership.
# NOTE: This will only take effect if LDAP is enabled
...
...
config/initializers/1_settings.rb
View file @
0cd84ba4
...
...
@@ -375,7 +375,7 @@ 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'
]
||=
'
30
* * * *'
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 * * *'
...
...
db/schema.rb
View file @
0cd84ba4
...
...
@@ -1206,6 +1206,7 @@ ActiveRecord::Schema.define(version: 20170204181513) do
t
.
string
"encrypted_credentials_salt"
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
integer
"remote_sync_time"
,
default:
60
,
null:
false
end
add_index
"remote_mirrors"
,
[
"project_id"
],
name:
"index_remote_mirrors_on_project_id"
,
using: :btree
...
...
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