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
5f90fd69
Commit
5f90fd69
authored
Apr 25, 2017
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adds migration to remove sync time from remote mirrors
parent
e3ef8f2b
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
30 additions
and
22 deletions
+30
-22
app/models/remote_mirror.rb
app/models/remote_mirror.rb
+0
-7
app/services/git_push_service.rb
app/services/git_push_service.rb
+1
-1
app/views/projects/mirrors/_show.html.haml
app/views/projects/mirrors/_show.html.haml
+1
-0
app/workers/repository_update_remote_mirror_worker.rb
app/workers/repository_update_remote_mirror_worker.rb
+8
-9
db/migrate/20170411165711_remove_sync_time_column_from_remote_mirrors.rb
...0411165711_remove_sync_time_column_from_remote_mirrors.rb
+17
-0
db/schema.rb
db/schema.rb
+0
-2
spec/models/project_spec.rb
spec/models/project_spec.rb
+1
-1
spec/services/git_push_service_spec.rb
spec/services/git_push_service_spec.rb
+2
-2
No files found.
app/models/remote_mirror.rb
View file @
5f90fd69
...
...
@@ -2,9 +2,6 @@ class RemoteMirror < ActiveRecord::Base
include
AfterCommitQueue
include
IgnorableColumn
BACKOFF_DELAY
=
5
MAX_RETRIES
=
5
attr_encrypted
:credentials
,
key:
Gitlab
::
Application
.
secrets
.
db_key_base
,
marshal:
true
,
...
...
@@ -42,10 +39,6 @@ class RemoteMirror < ActiveRecord::Base
transition
started: :failed
end
event
:update_retry
do
transition
failed: :started
end
state
:started
state
:finished
state
:failed
...
...
app/services/git_push_service.rb
View file @
5f90fd69
...
...
@@ -100,7 +100,7 @@ class GitPushService < BaseService
def
update_remote_mirrors
return
if
@project
.
remote_mirrors
.
empty?
@project
.
mark_remote_mirrors_as_failed!
@project
.
mark_
stuck_
remote_mirrors_as_failed!
@project
.
update_remote_mirrors
end
...
...
app/views/projects/mirrors/_show.html.haml
View file @
5f90fd69
...
...
@@ -74,6 +74,7 @@
=
rm_form
.
label
:enabled
,
"Remote mirror repository"
,
class:
"label-light append-bottom-0"
%p
.light.append-bottom-0
Automatically update the remote mirror's branches, tags, and commits from this repository five minutes after every push.
In case of failure the mirroring will be retried 5 more times each adding a longer backoff period.
.form-group.has-feedback
=
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'
...
...
app/workers/repository_update_remote_mirror_worker.rb
View file @
5f90fd69
...
...
@@ -4,20 +4,19 @@ class RepositoryUpdateRemoteMirrorWorker
include
Sidekiq
::
Worker
include
Gitlab
::
ShellAdapter
sidekiq_options
queue: :project_mirror
,
retry:
RemoteMirror
::
MAX_RETRIES
BACKOFF_DELAY
=
5
.
minutes
.
to_i
MAX_RETRIES
=
5
sidekiq_retry_in
do
|
count
|
RemoteMirror
::
BACKOFF_DELAY
**
count
end
sidekiq_options
queue: :project_mirror
,
retry:
MAX_RETRIES
sidekiq_retry_in
{
|
count
|
BACKOFF_DELAY
**
count
}
def
perform
(
remote_mirror_id
,
current_time
)
begin
remote_mirror
=
RemoteMirror
.
find
(
remote_mirror_id
)
last_update_at
=
remote_mirror
.
last_update_at
project
=
remote_mirror
.
project
current_user
=
project
.
creator
remote_mirror
=
RemoteMirror
.
find
(
remote_mirror_id
)
return
if
remote_mirror
&
.
last_update_at
.
to_i
>
current_time
.
to_i
return
if
last_update_at
&&
last_update_at
>
current_time
project
=
remote_mirror
.
project
current_user
=
project
.
creator
result
=
Projects
::
UpdateRemoteMirrorService
.
new
(
project
,
current_user
).
execute
(
remote_mirror
)
...
...
db/migrate/20170411165711_remove_sync_time_column_from_remote_mirrors.rb
0 → 100644
View file @
5f90fd69
class
RemoveSyncTimeColumnFromRemoteMirrors
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
remove_concurrent_index
:remote_mirrors
,
[
:sync_time
]
if
index_exists?
:remote_mirrors
,
[
:sync_time
]
remove_column
:remote_mirrors
,
:sync_time
,
:integer
end
def
down
add_column
:remote_mirrors
,
:sync_time
,
:integer
add_concurrent_index
:remote_mirrors
,
[
:sync_time
]
end
end
db/schema.rb
View file @
5f90fd69
...
...
@@ -1241,12 +1241,10 @@ ActiveRecord::Schema.define(version: 20170426175636) do
t
.
string
"encrypted_credentials_salt"
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
integer
"sync_time"
,
default:
60
,
null:
false
end
add_index
"remote_mirrors"
,
[
"last_successful_update_at"
],
name:
"index_remote_mirrors_on_last_successful_update_at"
,
using: :btree
add_index
"remote_mirrors"
,
[
"project_id"
],
name:
"index_remote_mirrors_on_project_id"
,
using: :btree
add_index
"remote_mirrors"
,
[
"sync_time"
],
name:
"index_remote_mirrors_on_sync_time"
,
using: :btree
create_table
"routes"
,
force: :cascade
do
|
t
|
t
.
integer
"source_id"
,
null:
false
...
...
spec/models/project_spec.rb
View file @
5f90fd69
...
...
@@ -205,7 +205,7 @@ describe Project, models: true do
)
expect
do
project
.
mark_
as_failed_stuck_remote_mirrors
(
'some message'
)
project
.
mark_
stuck_remote_mirrors_as_failed!
end
.
to
change
{
project
.
remote_mirrors
.
stuck
.
count
}.
from
(
1
).
to
(
0
)
end
end
...
...
spec/services/git_push_service_spec.rb
View file @
5f90fd69
...
...
@@ -25,13 +25,13 @@ describe GitPushService, services: true do
end
it
'fails stuck remote mirrors'
do
expect
(
subject
).
to
receive
(
:update_remote_mirrors
)
expect
(
project
).
to
receive
(
:mark_stuck_remote_mirrors_as_failed!
)
subject
.
execute
end
it
'updates remote mirrors'
do
expect
(
sub
ject
).
to
receive
(
:update_remote_mirrors
)
expect
(
pro
ject
).
to
receive
(
:update_remote_mirrors
)
subject
.
execute
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