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
a8600fc4
Commit
a8600fc4
authored
Jan 19, 2018
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds logging to remove remote worker
parent
c8e6c91c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
20 deletions
+27
-20
app/models/repository.rb
app/models/repository.rb
+4
-4
app/workers/repository_remove_remote_worker.rb
app/workers/repository_remove_remote_worker.rb
+12
-2
ee/app/models/ee/project.rb
ee/app/models/ee/project.rb
+1
-1
ee/app/models/remote_mirror.rb
ee/app/models/remote_mirror.rb
+5
-8
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+4
-4
spec/workers/repository_remove_remote_worker_spec.rb
spec/workers/repository_remove_remote_worker_spec.rb
+1
-1
No files found.
app/models/repository.rb
View file @
a8600fc4
...
...
@@ -1005,22 +1005,22 @@ class Repository
add_remote
(
remote_name
,
url
,
mirror_refmap:
refmap
)
fetch_remote
(
remote_name
,
forced:
forced
)
ensure
schedule
_remove_remote
(
remote_name
)
if
tmp_remote_name
async
_remove_remote
(
remote_name
)
if
tmp_remote_name
end
def
fetch_remote
(
remote
,
forced:
false
,
ssh_auth:
nil
,
no_tags:
false
)
gitlab_shell
.
fetch_remote
(
raw_repository
,
remote
,
ssh_auth:
ssh_auth
,
forced:
forced
,
no_tags:
no_tags
)
end
def
schedule
_remove_remote
(
remote_name
)
def
async
_remove_remote
(
remote_name
)
return
unless
remote_name
job_id
=
RepositoryRemoveRemoteWorker
.
perform_async
(
project
.
id
,
remote_name
)
if
job_id
Rails
.
logger
.
info
(
"Re
positoryRemoveRemoteWorker
job scheduled for
#{
project
.
id
}
with remote name:
#{
remote_name
}
job ID
#{
job_id
}
."
)
Rails
.
logger
.
info
(
"Re
move remote
job scheduled for
#{
project
.
id
}
with remote name:
#{
remote_name
}
job ID
#{
job_id
}
."
)
else
Rails
.
logger
.
info
(
"Re
positoryRemoveRemoteWorker
job failed to create for
#{
project
.
id
}
with remote name
#{
remote_name
}
."
)
Rails
.
logger
.
info
(
"Re
move remote
job failed to create for
#{
project
.
id
}
with remote name
#{
remote_name
}
."
)
end
job_id
...
...
app/workers/repository_remove_remote_worker.rb
View file @
a8600fc4
...
...
@@ -8,10 +8,20 @@ class RepositoryRemoveRemoteWorker
def
perform
(
project_id
,
remote_name
)
@remote_name
=
remote_name
@project
=
Project
.
find
(
project_id
)
@project
=
Project
.
find_by_id
(
project_id
)
return
unless
@project
logger
.
info
(
"Removing remote
#{
remote_name
}
from project
#{
project
.
id
}
"
)
try_obtain_lease
do
@project
.
repository
.
remove_remote
(
remote_name
)
remove_remote
=
@project
.
repository
.
remove_remote
(
remote_name
)
if
remove_remote
logger
.
info
(
"Remote
#{
remote_name
}
was successfully removed from project
#{
project
.
id
}
"
)
else
logger
.
error
(
"Could not remove remote
#{
remote_name
}
from project
#{
project
.
id
}
"
)
end
end
end
...
...
ee/app/models/ee/project.rb
View file @
a8600fc4
...
...
@@ -329,7 +329,7 @@ module EE
end
def
remove_mirror_repository_reference
repository
.
schedule
_remove_remote
(
::
Repository
::
MIRROR_REMOTE
)
repository
.
async
_remove_remote
(
::
Repository
::
MIRROR_REMOTE
)
end
def
import_url_availability
...
...
ee/app/models/remote_mirror.rb
View file @
a8600fc4
...
...
@@ -72,12 +72,7 @@ class RemoteMirror < ActiveRecord::Base
end
def
remote_name
name
=
read_attribute
(
:remote_name
)
return
name
if
name
return
unless
id
fallback_remote_name
super
||
fallback_remote_name
end
def
update_failed?
...
...
@@ -160,6 +155,8 @@ class RemoteMirror < ActiveRecord::Base
end
def
fallback_remote_name
return
unless
id
"remote_mirror_
#{
id
}
"
end
...
...
@@ -211,7 +208,7 @@ class RemoteMirror < ActiveRecord::Base
# the previous remote name
prev_remote_name
=
remote_name_was
||
fallback_remote_name
run_after_commit
do
project
.
repository
.
schedule
_remove_remote
(
prev_remote_name
)
project
.
repository
.
async
_remove_remote
(
prev_remote_name
)
end
project
.
repository
.
add_remote
(
remote_name
,
url
)
...
...
@@ -220,7 +217,7 @@ class RemoteMirror < ActiveRecord::Base
def
remove_remote
return
unless
project
# could be pending to delete so don't need to touch the git repository
project
.
repository
.
schedule
_remove_remote
(
remote_name
)
project
.
repository
.
async
_remove_remote
(
remote_name
)
end
def
mirror_url_changed?
...
...
spec/models/repository_spec.rb
View file @
a8600fc4
...
...
@@ -701,7 +701,7 @@ describe Repository do
end
end
describe
'#
schedule
_remove_remote'
do
describe
'#
async
_remove_remote'
do
before
do
masterrev
=
repository
.
find_branch
(
'master'
).
dereferenced_target
create_remote_branch
(
'joe'
,
'remote_branch'
,
masterrev
)
...
...
@@ -716,7 +716,7 @@ describe Repository do
end
it
'returns job_id'
do
expect
(
repository
.
schedule
_remove_remote
(
'joe'
)).
to
eq
(
'1234'
)
expect
(
repository
.
async
_remove_remote
(
'joe'
)).
to
eq
(
'1234'
)
end
end
...
...
@@ -726,9 +726,9 @@ describe Repository do
end
it
'returns nil'
do
expect
(
Rails
.
logger
).
to
receive
(
:info
).
with
(
"Re
positoryRemoveRemoteWorker
job failed to create for
#{
project
.
id
}
with remote name joe."
)
expect
(
Rails
.
logger
).
to
receive
(
:info
).
with
(
"Re
move remote
job failed to create for
#{
project
.
id
}
with remote name joe."
)
expect
(
repository
.
schedule
_remove_remote
(
'joe'
)).
to
be_nil
expect
(
repository
.
async
_remove_remote
(
'joe'
)).
to
be_nil
end
end
end
...
...
spec/workers/repository_remove_remote_worker_spec.rb
View file @
a8600fc4
...
...
@@ -25,7 +25,7 @@ describe RepositoryRemoveRemoteWorker do
context
'when project does not exist'
do
it
'returns nil'
do
expect
{
worker
.
perform
(
-
1
,
'remote_name'
)
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
expect
(
worker
.
perform
(
-
1
,
'remote_name'
)).
to
be_nil
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