Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
9f80f040
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
9f80f040
编写于
12月 19, 2018
作者:
M
Michael Kozono
提交者:
Douglas Barbosa Alexandre
12月 19, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Prevent admins from attempting hashed storage migration on read only DB
上级
baad9fb8
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
25 addition
and
4 deletion
+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
未找到文件。
changelogs/unreleased/mk-avoid-read-only-error.yml
0 → 100644
浏览文件 @
9f80f040
---
title
:
Prevent admins from attempting hashed storage migration on read only DB
merge_request
:
23597
author
:
type
:
fixed
lib/tasks/gitlab/storage.rake
浏览文件 @
9f80f040
...
...
@@ -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
浏览文件 @
9f80f040
...
...
@@ -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
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录