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
26e90431
Commit
26e90431
authored
Dec 19, 2018
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
feb01536
05b16421
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
4 deletions
+25
-4
changelogs/unreleased/mk-avoid-read-only-error.yml
changelogs/unreleased/mk-avoid-read-only-error.yml
+5
-0
lib/tasks/gitlab/storage.rake
lib/tasks/gitlab/storage.rake
+8
-2
spec/tasks/gitlab/storage_rake_spec.rb
spec/tasks/gitlab/storage_rake_spec.rb
+12
-2
No files found.
changelogs/unreleased/mk-avoid-read-only-error.yml
0 → 100644
View file @
26e90431
---
title
:
Prevent admins from attempting hashed storage migration on read only DB
merge_request
:
23597
author
:
type
:
fixed
lib/tasks/gitlab/storage.rake
View file @
26e90431
...
...
@@ -2,6 +2,12 @@ namespace :gitlab do
namespace
:storage
do
desc
'GitLab | Storage | Migrate existing projects to Hashed Storage'
task
migrate_to_hashed: :environment
do
if
Gitlab
::
Database
.
read_only?
warn
'This task requires database write access. Exiting.'
next
end
storage_migrator
=
Gitlab
::
HashedStorage
::
Migrator
.
new
helper
=
Gitlab
::
HashedStorage
::
RakeHelper
...
...
@@ -9,7 +15,7 @@ namespace :gitlab do
project
=
Project
.
with_unmigrated_storage
.
find_by
(
id:
helper
.
range_from
)
unless
project
puts
"There are no projects requiring storage migration with ID=
#{
helper
.
range_from
}
"
warn
"There are no projects requiring storage migration with ID=
#{
helper
.
range_from
}
"
next
end
...
...
@@ -23,7 +29,7 @@ namespace :gitlab do
legacy_projects_count
=
Project
.
with_unmigrated_storage
.
count
if
legacy_projects_count
==
0
puts
'There are no projects requiring storage migration. Nothing to do!'
warn
'There are no projects requiring storage migration. Nothing to do!'
next
end
...
...
spec/tasks/gitlab/storage_rake_spec.rb
View file @
26e90431
...
...
@@ -46,6 +46,16 @@ describe 'rake gitlab:storage:*' do
describe
'gitlab:storage:migrate_to_hashed'
do
let
(
:task
)
{
'gitlab:storage:migrate_to_hashed'
}
context
'read-only database'
do
it
'does nothing'
do
expect
(
Gitlab
::
Database
).
to
receive
(
:read_only?
).
and_return
(
true
)
expect
(
Project
).
not_to
receive
(
:with_unmigrated_storage
)
expect
{
run_rake_task
(
task
)
}.
to
output
(
/This task requires database write access. Exiting./
).
to_stderr
end
end
context
'0 legacy projects'
do
it
'does nothing'
do
expect
(
StorageMigratorWorker
).
not_to
receive
(
:perform_async
)
...
...
@@ -92,7 +102,7 @@ describe 'rake gitlab:storage:*' do
stub_env
(
'ID_FROM'
,
99999
)
stub_env
(
'ID_TO'
,
99999
)
expect
{
run_rake_task
(
task
)
}.
to
output
(
/There are no projects requiring storage migration with ID=99999/
).
to_std
out
expect
{
run_rake_task
(
task
)
}.
to
output
(
/There are no projects requiring storage migration with ID=99999/
).
to_std
err
end
it
'displays a message when project exists but its already migrated'
do
...
...
@@ -100,7 +110,7 @@ describe 'rake gitlab:storage:*' do
stub_env
(
'ID_FROM'
,
project
.
id
)
stub_env
(
'ID_TO'
,
project
.
id
)
expect
{
run_rake_task
(
task
)
}.
to
output
(
/There are no projects requiring storage migration with ID=
#{
project
.
id
}
/
).
to_std
out
expect
{
run_rake_task
(
task
)
}.
to
output
(
/There are no projects requiring storage migration with ID=
#{
project
.
id
}
/
).
to_std
err
end
it
'enqueues migration when project can be found'
do
...
...
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