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
77986484
Commit
77986484
authored
Apr 21, 2016
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added project_destroy replication support for Geo
parent
34eaf32f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
69 additions
and
11 deletions
+69
-11
app/services/geo/schedule_repo_destroy_service.rb
app/services/geo/schedule_repo_destroy_service.rb
+15
-0
app/services/projects/destroy_service.rb
app/services/projects/destroy_service.rb
+32
-11
app/workers/geo_repository_destroy_worker.rb
app/workers/geo_repository_destroy_worker.rb
+19
-0
lib/api/geo.rb
lib/api/geo.rb
+3
-0
No files found.
app/services/geo/schedule_repo_destroy_service.rb
0 → 100644
View file @
77986484
module
Geo
class
ScheduleRepoDestroyService
attr_reader
:id
,
:name
,
:path_with_namespace
def
initialize
(
params
)
@id
=
params
[
'project_id'
]
@name
=
params
[
'name'
]
@path_with_namespace
=
params
[
'path_with_namespace'
]
end
def
execute
GeoRepositoryDestroyWorker
.
perform_async
(
id
,
name
,
path_with_namespace
)
end
end
end
app/services/projects/destroy_service.rb
View file @
77986484
...
...
@@ -17,9 +17,6 @@ module Projects
project
.
team
.
truncate
repo_path
=
project
.
path_with_namespace
wiki_path
=
repo_path
+
'.wiki'
# Flush the cache for both repositories. This has to be done _before_
# removing the physical repositories as some expiration code depends on
# Git data (e.g. a list of branch names).
...
...
@@ -27,14 +24,7 @@ module Projects
Project
.
transaction
do
project
.
destroy!
unless
remove_repository
(
repo_path
)
raise_error
(
'Failed to remove project repository. Please try again or contact administrator'
)
end
unless
remove_repository
(
wiki_path
)
raise_error
(
'Failed to remove wiki repository. Please try again or contact administrator'
)
end
trash_repositories!
end
log_info
(
"Project
\"
#{
project
.
name
}
\"
was removed"
)
...
...
@@ -42,8 +32,39 @@ module Projects
true
end
# Removes physical repository in a Geo replicated secondary node
# There is no need to do any database operation as it will be
# replicated by itself.
def
geo_replicate
# Flush the cache for both repositories. This has to be done _before_
# removing the physical repositories as some expiration code depends on
# Git data (e.g. a list of branch names).
flush_caches
(
project
,
wiki_path
)
trash_repositories!
log_info
(
"Project
\"
#{
project
.
name
}
\"
was removed"
)
end
private
def
repo_path
project
.
path_with_namespace
end
def
wiki_path
repo_path
+
'.wiki'
end
def
trash_repositories!
unless
remove_repository
(
repo_path
)
raise_error
(
'Failed to remove project repository. Please try again or contact administrator'
)
end
unless
remove_repository
(
wiki_path
)
raise_error
(
'Failed to remove wiki repository. Please try again or contact administrator'
)
end
end
def
remove_repository
(
path
)
# Skip repository removal. We use this flag when remove user or group
return
true
if
params
[
:skip_repo
]
==
true
...
...
app/workers/geo_repository_destroy_worker.rb
0 → 100644
View file @
77986484
class
GeoRepositoryDestroyWorker
include
Sidekiq
::
Worker
sidekiq_options
queue: :default
def
perform
(
id
,
name
,
path_with_namespace
)
# We don't have access to the original model anymore, so we are
# rebuilding only what our service class requires
project
=
FakeProject
.
new
(
id
,
name
,
path_with_namespace
)
::
Projects
::
DestroyService
.
new
(
project
,
nil
).
geo_replicate
end
FakeProject
=
Struct
.
new
(
:id
,
:name
,
:path_with_namespace
)
do
def
repository
@repository
||=
Repository
.
new
(
path_with_namespace
,
self
)
end
end
end
lib/api/geo.rb
View file @
77986484
...
...
@@ -30,6 +30,9 @@ module API
when
'tag_push'
required_attributes!
%w(event_name project_id project)
::
Geo
::
ScheduleWikiRepoUpdateService
.
new
(
params
).
execute
when
'project_destroy'
required_attributes!
%w(event_name project_id path_with_namespace)
::
Geo
::
ScheduleRepoDestroyService
.
new
(
params
).
execute
end
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