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
35a1da0e
Commit
35a1da0e
authored
Nov 07, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use keyword argument on Geo::HashedStorageMigrationService
parent
c57fe5aa
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
25 deletions
+33
-25
app/services/geo/hashed_storage_migration_service.rb
app/services/geo/hashed_storage_migration_service.rb
+11
-8
app/workers/geo/hashed_storage_migration_worker.rb
app/workers/geo/hashed_storage_migration_worker.rb
+4
-5
lib/gitlab/geo/log_cursor/daemon.rb
lib/gitlab/geo/log_cursor/daemon.rb
+3
-4
spec/lib/gitlab/geo/log_cursor/daemon_spec.rb
spec/lib/gitlab/geo/log_cursor/daemon_spec.rb
+1
-2
spec/services/geo/hashed_storage_migration_service_spec.rb
spec/services/geo/hashed_storage_migration_service_spec.rb
+14
-6
No files found.
app/services/geo/hashed_storage_migration_service.rb
View file @
35a1da0e
module
Geo
class
HashedStorageMigrationService
attr_reader
:project_id
,
:old_disk_path
,
:new_disk_path
,
:old_storage_version
,
:new_storage_version
attr_reader
:project_id
,
:old_disk_path
,
:new_disk_path
,
:old_storage_version
def
initialize
(
project_id
,
old_disk_path
,
new_disk_path
,
old_storage_version
,
new_storage_version
)
def
initialize
(
project_id
,
old_disk_path
:,
new_disk_path
:,
old_storage_version
:
)
@project_id
=
project_id
@old_disk_path
=
old_disk_path
@new_disk_path
=
new_disk_path
@old_storage_version
=
old_storage_version
@new_storage_version
=
new_storage_version
end
def
async_execute
Geo
::
HashedStorageMigrationWorker
.
perform_async
(
project_id
,
old_disk_path
,
new_disk_path
,
old_storage_version
,
new_storage_version
)
Geo
::
HashedStorageMigrationWorker
.
perform_async
(
project_id
,
old_disk_path
,
new_disk_path
,
old_storage_version
)
end
def
execute
project
=
Project
.
find
(
project_id
)
project
.
expire_caches_before_rename
(
old_disk_path
)
if
migrating_from_legacy_storage?
if
migrating_from_legacy_storage?
(
project
)
Geo
::
MoveRepositoryService
.
new
(
project
,
old_disk_path
,
new_disk_path
).
execute
end
...
...
@@ -28,8 +31,8 @@ module Geo
private
def
migrating_from_legacy_storage?
from_legacy_storage?
&&
new_storage_version
>=
Project
::
HASHED_STORAGE_FEATURES
[
:repository
]
def
migrating_from_legacy_storage?
(
project
)
from_legacy_storage?
&&
project
.
hashed_storage?
(
:repository
)
end
def
from_legacy_storage?
...
...
app/workers/geo/hashed_storage_migration_worker.rb
View file @
35a1da0e
...
...
@@ -3,13 +3,12 @@ module Geo
include
Sidekiq
::
Worker
include
GeoQueue
def
perform
(
project_id
,
old_disk_path
,
new_disk_path
,
old_storage_version
,
new_storage_version
)
def
perform
(
project_id
,
old_disk_path
,
new_disk_path
,
old_storage_version
)
Geo
::
HashedStorageMigrationService
.
new
(
project_id
,
old_disk_path
,
new_disk_path
,
old_storage_version
,
new_storage_version
old_disk_path:
old_disk_path
,
new_disk_path:
new_disk_path
,
old_storage_version:
old_storage_version
).
execute
end
end
...
...
lib/gitlab/geo/log_cursor/daemon.rb
View file @
35a1da0e
...
...
@@ -203,10 +203,9 @@ module Gitlab
job_id
=
::
Geo
::
HashedStorageMigrationService
.
new
(
event
.
project_id
,
event
.
old_disk_path
,
event
.
new_disk_path
,
event
.
old_storage_version
,
event
.
new_storage_version
old_disk_path:
event
.
old_disk_path
,
new_disk_path:
event
.
new_disk_path
,
old_storage_version:
event
.
old_storage_version
).
async_execute
log_event_info
(
...
...
spec/lib/gitlab/geo/log_cursor/daemon_spec.rb
View file @
35a1da0e
...
...
@@ -230,10 +230,9 @@ describe Gitlab::Geo::LogCursor::Daemon, :postgresql do
old_disk_path
=
hashed_storage_migrated_event
.
old_disk_path
new_disk_path
=
hashed_storage_migrated_event
.
new_disk_path
old_storage_version
=
project
.
storage_version
new_storage_version
=
hashed_storage_migrated_event
.
new_storage_version
expect
(
::
Geo
::
HashedStorageMigrationWorker
).
to
receive
(
:perform_async
)
.
with
(
project
.
id
,
old_disk_path
,
new_disk_path
,
old_storage_version
,
new_storage_version
)
.
with
(
project
.
id
,
old_disk_path
,
new_disk_path
,
old_storage_version
)
daemon
.
run_once!
end
...
...
spec/services/geo/hashed_storage_migration_service_spec.rb
View file @
35a1da0e
require
'spec_helper'
describe
Geo
::
HashedStorageMigrationService
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:project
)
{
create
(
:project
,
:repository
,
:hashed
)
}
let
(
:new_path
)
{
"
#{
project
.
full_path
}
+renamed"
}
let
(
:new_storage_version
)
{
Project
::
LATEST_STORAGE_VERSION
}
describe
'#execute'
do
it
'moves project backed by legacy storage'
do
service
=
described_class
.
new
(
project
.
id
,
project
.
full_path
,
new_path
,
project
.
storage_version
,
new_storage_version
)
service
=
described_class
.
new
(
project
.
id
,
old_disk_path:
project
.
full_path
,
new_disk_path:
new_path
,
old_storage_version:
nil
)
expect_any_instance_of
(
Geo
::
MoveRepositoryService
).
to
receive
(
:execute
).
once
...
...
@@ -15,8 +19,12 @@ describe Geo::HashedStorageMigrationService do
end
it
'does not move project backed by hashed storage'
do
project_hashed_storage
=
create
(
:project
,
:hashed
)
service
=
described_class
.
new
(
project_hashed_storage
.
id
,
project_hashed_storage
.
full_path
,
new_path
,
project
.
storage_version
,
new_storage_version
)
service
=
described_class
.
new
(
project
.
id
,
old_disk_path:
project
.
full_path
,
new_disk_path:
"
#{
project
.
full_path
}
+renamed"
,
old_storage_version:
project
.
storage_version
)
expect_any_instance_of
(
Geo
::
MoveRepositoryService
).
not_to
receive
(
:execute
).
once
...
...
@@ -25,7 +33,7 @@ describe Geo::HashedStorageMigrationService do
end
describe
'#async_execute'
do
subject
(
:service
)
{
described_class
.
new
(
project
.
id
,
project
.
full_path
,
new_path
,
project
.
storage_version
,
new_storage_version
)
}
subject
(
:service
)
{
described_class
.
new
(
project
.
id
,
old_disk_path:
project
.
full_path
,
new_disk_path:
new_path
,
old_storage_version:
nil
)
}
it
'starts the worker'
do
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