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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
4908e4b3
Commit
4908e4b3
authored
Nov 21, 2018
by
Toon Claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Run repository cleanup on failure
parent
220208c0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
3 deletions
+24
-3
lib/gitlab/background_migration/backfill_project_fullpath_in_repo_config.rb
...und_migration/backfill_project_fullpath_in_repo_config.rb
+8
-1
spec/migrations/backfill_store_project_full_path_in_repo_spec.rb
...grations/backfill_store_project_full_path_in_repo_spec.rb
+16
-2
No files found.
lib/gitlab/background_migration/backfill_project_fullpath_in_repo_config.rb
View file @
4908e4b3
...
@@ -106,6 +106,10 @@ module Gitlab
...
@@ -106,6 +106,10 @@ module Gitlab
repository_service
.
delete_config
([
FULLPATH_CONFIG_KEY
])
repository_service
.
delete_config
([
FULLPATH_CONFIG_KEY
])
end
end
def
cleanup_repository
repository_service
.
cleanup
end
def
storage
def
storage
@storage
||=
@storage
||=
if
hashed_storage?
if
hashed_storage?
...
@@ -138,7 +142,10 @@ module Gitlab
...
@@ -138,7 +142,10 @@ module Gitlab
def
perform
(
project_id
,
retry_count
)
def
perform
(
project_id
,
retry_count
)
project
=
Project
.
find
(
project_id
)
project
=
Project
.
find
(
project_id
)
migration_class
.
new
.
safe_perform_one
(
project
,
retry_count
)
if
project
return
unless
project
project
.
cleanup_repository
migration_class
.
new
.
safe_perform_one
(
project
,
retry_count
)
end
end
end
end
...
...
spec/migrations/backfill_store_project_full_path_in_repo_spec.rb
View file @
4908e4b3
...
@@ -20,6 +20,12 @@ describe BackfillStoreProjectFullPathInRepo, :migration do
...
@@ -20,6 +20,12 @@ describe BackfillStoreProjectFullPathInRepo, :migration do
describe
'#up'
do
describe
'#up'
do
shared_examples_for
'writes the full path to git config'
do
shared_examples_for
'writes the full path to git config'
do
let
(
:repository_service
)
{
spy
(
:repository_service
)
}
def
stub_repository_service
allow
(
Gitlab
::
GitalyClient
::
RepositoryService
).
to
receive
(
:new
).
and_return
(
repository_service
)
end
it
'writes the git config'
do
it
'writes the git config'
do
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
RepositoryService
)
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
RepositoryService
)
.
to
receive
(
:set_config
).
with
(
'gitlab.fullpath'
=>
expected_path
)
.
to
receive
(
:set_config
).
with
(
'gitlab.fullpath'
=>
expected_path
)
...
@@ -28,15 +34,23 @@ describe BackfillStoreProjectFullPathInRepo, :migration do
...
@@ -28,15 +34,23 @@ describe BackfillStoreProjectFullPathInRepo, :migration do
end
end
it
'retries in case of failure'
do
it
'retries in case of failure'
do
repository_service
=
spy
(
:repository_service
)
stub_repository_service
allow
(
Gitlab
::
GitalyClient
::
RepositoryService
).
to
receive
(
:new
).
and_return
(
repository_service
)
allow
(
repository_service
).
to
receive
(
:set_config
).
and_raise
(
GRPC
::
BadStatus
,
'Retry me'
)
allow
(
repository_service
).
to
receive
(
:set_config
).
and_raise
(
GRPC
::
BadStatus
,
'Retry me'
)
expect
(
repository_service
).
to
receive
(
:set_config
).
exactly
(
3
).
times
expect
(
repository_service
).
to
receive
(
:set_config
).
exactly
(
3
).
times
migration
.
up
migration
.
up
end
end
it
'cleans up repository in case of failure'
do
stub_repository_service
allow
(
repository_service
).
to
receive
(
:set_config
).
and_raise
(
GRPC
::
BadStatus
,
'Retry me'
)
expect
(
repository_service
).
to
receive
(
:cleanup
)
migration
.
up
end
context
'legacy storage'
do
context
'legacy storage'
do
it
'finds the repository at the correct location'
do
it
'finds the repository at the correct location'
do
Project
.
find
(
project
.
id
).
create_repository
Project
.
find
(
project
.
id
).
create_repository
...
...
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