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
a32aafdc
Commit
a32aafdc
authored
Nov 07, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Decide what actions to take based on the change in storage_version
parent
51b33e29
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
14 deletions
+42
-14
app/services/geo/hashed_storage_migration_service.rb
app/services/geo/hashed_storage_migration_service.rb
+21
-4
app/workers/geo/hashed_storage_migration_worker.rb
app/workers/geo/hashed_storage_migration_worker.rb
+8
-2
lib/gitlab/geo/log_cursor/daemon.rb
lib/gitlab/geo/log_cursor/daemon.rb
+7
-3
spec/services/geo/hashed_storage_migration_service_spec.rb
spec/services/geo/hashed_storage_migration_service_spec.rb
+6
-5
No files found.
app/services/geo/hashed_storage_migration_service.rb
View file @
a32aafdc
module
Geo
module
Geo
class
HashedStorageMigrationService
class
HashedStorageMigrationService
attr_reader
:project_id
,
:old_disk_path
,
:new_disk_path
attr_reader
:project_id
,
:old_disk_path
,
:new_disk_path
,
:old_storage_version
,
:new_storage_version
def
initialize
(
project_id
,
old_disk_path
,
new_disk_path
)
def
initialize
(
project_id
,
old_disk_path
,
new_disk_path
,
old_storage_version
,
new_storage_version
)
@project_id
=
project_id
@project_id
=
project_id
@old_disk_path
=
old_disk_path
@old_disk_path
=
old_disk_path
@new_disk_path
=
new_disk_path
@new_disk_path
=
new_disk_path
@old_storage_version
=
old_storage_version
@new_storage_version
=
new_storage_version
end
end
def
async_execute
def
async_execute
Geo
::
HashedStorageMigrationWorker
.
perform_async
(
project_id
,
old_disk_path
,
new_disk_path
)
Geo
::
HashedStorageMigrationWorker
.
perform_async
(
project_id
,
old_disk_path
,
new_disk_path
,
old_storage_version
,
new_storage_version
)
end
end
def
execute
def
execute
project
=
Project
.
find
(
project_id
)
project
=
Project
.
find
(
project_id
)
project
.
expire_caches_before_rename
(
old_disk_path
)
project
.
expire_caches_before_rename
(
old_disk_path
)
if
migrating_from_legacy_storage?
Geo
::
MoveRepositoryService
.
new
(
project
,
old_disk_path
,
new_disk_path
).
execute
Geo
::
MoveRepositoryService
.
new
(
project
,
old_disk_path
,
new_disk_path
).
execute
end
end
true
end
private
def
migrating_from_legacy_storage?
from_legacy_storage?
&&
new_storage_version
>=
Project
::
HASHED_STORAGE_FEATURES
[
:repository
]
end
def
from_legacy_storage?
old_storage_version
.
nil?
||
old_storage_version
.
zero?
end
end
end
end
end
app/workers/geo/hashed_storage_migration_worker.rb
View file @
a32aafdc
...
@@ -3,8 +3,14 @@ module Geo
...
@@ -3,8 +3,14 @@ module Geo
include
Sidekiq
::
Worker
include
Sidekiq
::
Worker
include
GeoQueue
include
GeoQueue
def
perform
(
project_id
,
old_disk_path
,
new_disk_path
)
def
perform
(
project_id
,
old_disk_path
,
new_disk_path
,
old_storage_version
,
new_storage_version
)
Geo
::
HashedStorageMigrationService
.
new
(
project_id
,
old_disk_path
,
new_disk_path
).
execute
Geo
::
HashedStorageMigrationService
.
new
(
project_id
,
old_disk_path
,
new_disk_path
,
old_storage_version
,
new_storage_version
).
execute
end
end
end
end
end
end
lib/gitlab/geo/log_cursor/daemon.rb
View file @
a32aafdc
...
@@ -201,9 +201,13 @@ module Gitlab
...
@@ -201,9 +201,13 @@ module Gitlab
event
=
event_log
.
hashed_storage_migrated_event
event
=
event_log
.
hashed_storage_migrated_event
return
unless
event
.
project_id
return
unless
event
.
project_id
job_id
=
::
Geo
::
HashedStorageMigrationService
job_id
=
::
Geo
::
HashedStorageMigrationService
.
new
(
.
new
(
event
.
project_id
,
event
.
old_disk_path
,
event
.
new_disk_path
)
event
.
project_id
,
.
async_execute
event
.
old_disk_path
,
event
.
new_disk_path
,
event
.
old_storage_version
,
event
.
new_storage_version
).
async_execute
log_event_info
(
log_event_info
(
event_log
.
created_at
,
event_log
.
created_at
,
...
...
spec/services/geo/hashed_storage_migration_service_spec.rb
View file @
a32aafdc
...
@@ -3,28 +3,29 @@ require 'spec_helper'
...
@@ -3,28 +3,29 @@ require 'spec_helper'
describe
Geo
::
HashedStorageMigrationService
do
describe
Geo
::
HashedStorageMigrationService
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:new_path
)
{
"
#{
project
.
full_path
}
+renamed"
}
let
(
:new_path
)
{
"
#{
project
.
full_path
}
+renamed"
}
let
(
:new_storage_version
)
{
Project
::
LATEST_STORAGE_VERSION
}
describe
'#execute'
do
describe
'#execute'
do
it
'moves project backed by legacy storage'
do
it
'moves project backed by legacy storage'
do
service
=
described_class
.
new
(
project
.
id
,
project
.
full_path
,
new_path
)
service
=
described_class
.
new
(
project
.
id
,
project
.
full_path
,
new_path
,
project
.
storage_version
,
new_storage_version
)
expect_any_instance_of
(
Geo
::
MoveRepositoryService
).
to
receive
(
:execute
).
once
expect_any_instance_of
(
Geo
::
MoveRepositoryService
).
to
receive
(
:execute
).
once
service
.
execute
service
.
execute
end
end
it
'
moves
project backed by hashed storage'
do
it
'
does not move
project backed by hashed storage'
do
project_hashed_storage
=
create
(
:project
,
:hashed
)
project_hashed_storage
=
create
(
:project
,
:hashed
)
service
=
described_class
.
new
(
project_hashed_storage
.
id
,
project_hashed_storage
.
full_path
,
new_path
)
service
=
described_class
.
new
(
project_hashed_storage
.
id
,
project_hashed_storage
.
full_path
,
new_path
,
project
.
storage_version
,
new_storage_version
)
expect_any_instance_of
(
Geo
::
MoveRepositoryService
).
to
receive
(
:execute
).
once
expect_any_instance_of
(
Geo
::
MoveRepositoryService
).
not_
to
receive
(
:execute
).
once
service
.
execute
service
.
execute
end
end
end
end
describe
'#async_execute'
do
describe
'#async_execute'
do
subject
(
:service
)
{
described_class
.
new
(
project
.
id
,
project
.
full_path
,
new_path
)
}
subject
(
:service
)
{
described_class
.
new
(
project
.
id
,
project
.
full_path
,
new_path
,
project
.
storage_version
,
new_storage_version
)
}
it
'starts the worker'
do
it
'starts the worker'
do
expect
(
Geo
::
HashedStorageMigrationWorker
).
to
receive
(
:perform_async
)
expect
(
Geo
::
HashedStorageMigrationWorker
).
to
receive
(
:perform_async
)
...
...
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