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
Léo-Paul Géneau
gitlab-ce
Commits
171f2d97
Commit
171f2d97
authored
Jun 14, 2017
by
Bob Van Landuyt
Committed by
Bob Van Landuyt
Jun 26, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Keep failed renames in redis
parent
d6a0c288
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
1 deletion
+32
-1
lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base.rb
...atabase/rename_reserved_paths_migration/v1/rename_base.rb
+13
-1
spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base_spec.rb
...se/rename_reserved_paths_migration/v1/rename_base_spec.rb
+19
-0
No files found.
lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base.rb
View file @
171f2d97
...
@@ -134,13 +134,25 @@ module Gitlab
...
@@ -134,13 +134,25 @@ module Gitlab
def
reverts_for_type
(
type
)
def
reverts_for_type
(
type
)
key
=
redis_key_for_type
(
type
)
key
=
redis_key_for_type
(
type
)
Gitlab
::
Redis
.
with
do
|
redis
|
Gitlab
::
Redis
.
with
do
|
redis
|
failed_reverts
=
[]
while
rename_info
=
redis
.
lpop
(
key
)
while
rename_info
=
redis
.
lpop
(
key
)
path_before_rename
,
path_after_rename
=
JSON
.
parse
(
rename_info
)
path_before_rename
,
path_after_rename
=
JSON
.
parse
(
rename_info
)
say
"renaming
#{
type
}
from
#{
path_after_rename
}
back to
#{
path_before_rename
}
"
say
"renaming
#{
type
}
from
#{
path_after_rename
}
back to
#{
path_before_rename
}
"
begin
yield
(
path_before_rename
,
path_after_rename
)
yield
(
path_before_rename
,
path_after_rename
)
rescue
StandardError
=>
e
failed_reverts
<<
rename_info
say
"Renaming
#{
type
}
from back to
#{
path_before_rename
}
failed. "
\
"Review the error and try again by running the `down` action.
\n
"
\
"
#{
e
.
message
}
:
\n
#{
e
.
backtrace
.
join
(
"
\n
"
)
}
"
end
end
end
end
failed_reverts
.
each
{
|
rename_info
|
redis
.
lpush
(
key
,
rename_info
)
}
end
end
end
def
redis_key_for_type
(
type
)
def
redis_key_for_type
(
type
)
...
...
spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base_spec.rb
View file @
171f2d97
...
@@ -257,5 +257,24 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameBase, :trunca
...
@@ -257,5 +257,24 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameBase, :trunca
expect
{
|
b
|
subject
.
reverts_for_type
(
'namespace'
,
&
b
)
}
expect
{
|
b
|
subject
.
reverts_for_type
(
'namespace'
,
&
b
)
}
.
to
yield_with_args
(
'namespace_path'
,
'new_namespace_path'
)
.
to
yield_with_args
(
'namespace_path'
,
'new_namespace_path'
)
end
end
it
'keeps the revert in redis if it failed'
do
subject
.
track_rename
(
'project'
,
'old_path'
,
'new_path'
)
subject
.
reverts_for_type
(
'project'
)
do
raise
'whatever happens, keep going!'
end
key
=
'rename:FakeRenameReservedPathMigrationV1:project'
stored_renames
=
nil
rename_count
=
0
Gitlab
::
Redis
.
with
do
|
redis
|
stored_renames
=
redis
.
lrange
(
key
,
0
,
1
)
rename_count
=
redis
.
llen
(
key
)
end
expect
(
rename_count
).
to
eq
(
1
)
expect
(
JSON
.
parse
(
stored_renames
.
first
)).
to
eq
(
%w(old_path new_path)
)
end
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