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
25a46f98
Commit
25a46f98
authored
Jul 16, 2017
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle project deletions in Geo::LogCursor
parent
451943c0
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
2 deletions
+65
-2
lib/gitlab/geo/log_cursor/daemon.rb
lib/gitlab/geo/log_cursor/daemon.rb
+21
-0
spec/factories/geo/event_log.rb
spec/factories/geo/event_log.rb
+16
-1
spec/lib/gitlab/geo/log_cursor/daemon_spec.rb
spec/lib/gitlab/geo/log_cursor/daemon_spec.rb
+28
-1
No files found.
lib/gitlab/geo/log_cursor/daemon.rb
View file @
25a46f98
...
...
@@ -64,6 +64,8 @@ module Gitlab
# Update repository
if
event
.
repository_updated_event
handle_repository_update
(
event
.
repository_updated_event
)
elsif
event
.
repository_deleted_event
handle_repository_delete
(
event
.
repository_deleted_event
)
end
end
end
...
...
@@ -108,6 +110,25 @@ module Gitlab
registry
.
save!
end
def
handle_repository_delete
(
deleted_event
)
# Once we remove system hooks we can refactor
# GeoRepositoryDestroyWorker to avoid doing this
full_path
=
File
.
join
(
deleted_event
.
repository_storage_path
,
deleted_event
.
deleted_path
)
job_id
=
::
GeoRepositoryDestroyWorker
.
perform_async
(
deleted_event
.
project_id
,
deleted_event
.
deleted_project_name
,
full_path
)
Gitlab
::
Geo
::
Logger
.
info
(
class:
self
.
class
.
name
,
message:
"Deleted project"
,
project_id:
deleted_event
.
project_id
,
full_path:
full_path
,
job_id:
job_id
)
# No need to create a project entry if it doesn't exist
::
Geo
::
ProjectRegistry
.
where
(
project_id:
deleted_event
.
project_id
).
delete_all
end
def
exit?
@exit
end
...
...
spec/factories/geo/event_log.rb
View file @
25a46f98
FactoryGirl
.
define
do
factory
:geo_event_log
,
class:
Geo
::
EventLog
do
trait
:updated_event
do
repository_updated_event
factory: :geo_repository_update_event
end
trait
:deleted_event
do
repository_deleted_event
factory: :geo_repository_delete_event
end
end
factory
:geo_repository_update_event
,
class:
Geo
::
RepositoryUpdatedEvent
do
source
0
branches_affected
0
tags_affected
0
project
end
factory
:geo_repository_delete_event
,
class:
Geo
::
RepositoryDeletedEvent
do
project
repository_storage_name
{
project
.
repository_storage
}
repository_storage_path
{
project
.
repository_storage_path
}
deleted_path
{
project
.
path_with_namespace
}
deleted_project_name
{
project
.
name
}
end
end
spec/lib/gitlab/geo/log_cursor/daemon_spec.rb
View file @
25a46f98
...
...
@@ -22,7 +22,7 @@ describe Gitlab::Geo::LogCursor::Daemon do
end
context
'when processing a repository updated event'
do
let
(
:event_log
)
{
create
(
:geo_event_log
)
}
let
(
:event_log
)
{
create
(
:geo_event_log
,
:updated_event
)
}
let!
(
:event_log_state
)
{
create
(
:geo_event_log_state
,
event_id:
event_log
.
id
-
1
)
}
let
(
:repository_updated_event
)
{
event_log
.
repository_updated_event
}
...
...
@@ -52,5 +52,32 @@ describe Gitlab::Geo::LogCursor::Daemon do
expect
(
registry
.
reload
.
resync_wiki
).
to
be
true
end
end
context
'when processing a repository deleted event'
do
let
(
:event_log
)
{
create
(
:geo_event_log
,
:deleted_event
)
}
let
(
:project
)
{
event_log
.
repository_deleted_event
.
project
}
let!
(
:event_log_state
)
{
create
(
:geo_event_log_state
,
event_id:
event_log
.
id
-
1
)
}
let
(
:repository_deleted_event
)
{
event_log
.
repository_deleted_event
}
before
do
allow
(
subject
).
to
receive
(
:exit?
).
and_return
(
false
,
true
)
end
it
'does not create a new project registry'
do
expect
{
subject
.
run!
}.
not_to
change
(
Geo
::
ProjectRegistry
,
:count
)
end
it
'schedules a GeoRepositoryDestroyWorker'
do
project_id
=
repository_deleted_event
.
project_id
project_name
=
repository_deleted_event
.
deleted_project_name
full_path
=
File
.
join
(
repository_deleted_event
.
repository_storage_path
,
repository_deleted_event
.
deleted_path
)
expect
(
::
GeoRepositoryDestroyWorker
).
to
receive
(
:perform_async
)
.
with
(
project_id
,
project_name
,
full_path
)
subject
.
run!
end
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