Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
1143411a
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,发现更多精彩内容 >>
提交
1143411a
编写于
11月 23, 2018
作者:
G
Grzegorz Bizon
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reduce Sidekiq signature of scheduled tokens migration
上级
627b4833
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
23 addition
and
10 deletion
+23
-10
db/post_migrate/20181121111200_schedule_runners_token_encryption.rb
...grate/20181121111200_schedule_runners_token_encryption.rb
+1
-1
lib/gitlab/background_migration/encrypt_runners_tokens.rb
lib/gitlab/background_migration/encrypt_runners_tokens.rb
+9
-1
spec/lib/gitlab/background_migration/encrypt_runners_tokens_spec.rb
...itlab/background_migration/encrypt_runners_tokens_spec.rb
+6
-8
spec/migrations/schedule_runners_token_encryption_spec.rb
spec/migrations/schedule_runners_token_encryption_spec.rb
+7
-0
未找到文件。
db/post_migrate/20181121111200_schedule_runners_token_encryption.rb
浏览文件 @
1143411a
...
...
@@ -24,7 +24,7 @@ class ScheduleRunnersTokenEncryption < ActiveRecord::Migration
relation
.
each_batch
(
of:
RANGE_SIZE
)
do
|
relation
|
range
=
relation
.
pluck
(
'MIN(id)'
,
'MAX(id)'
).
first
args
=
[
model
,
model
.
encrypted_attributes
.
keys
,
*
range
]
args
=
[
model
.
name
.
demodulize
.
downcase
,
*
range
]
BackgroundMigrationWorker
.
perform_in
(
delay
,
MIGRATION
,
args
)
end
...
...
lib/gitlab/background_migration/encrypt_runners_tokens.rb
浏览文件 @
1143411a
...
...
@@ -15,6 +15,14 @@ module Gitlab
#
# https://gitlab.com/gitlab-org/gitlab-ce/issues/54328
#
class
EncryptRunnersTokens
<
EncryptColumns
;
end
class
EncryptRunnersTokens
<
EncryptColumns
def
perform
(
model
,
from
,
to
)
resource
=
"::Gitlab::BackgroundMigration::Models::EncryptColumns::
#{
model
.
to_s
.
capitalize
}
"
model
=
resource
.
constantize
attributes
=
model
.
encrypted_attributes
.
keys
super
(
model
,
attributes
,
from
,
to
)
end
end
end
end
spec/lib/gitlab/background_migration/encrypt_runners_tokens_spec.rb
浏览文件 @
1143411a
...
...
@@ -12,7 +12,7 @@ describe Gitlab::BackgroundMigration::EncryptRunnersTokens, :migration, schema:
end
it
'migrates runners registration tokens'
do
migrate!
(
:settings
,
:runners_registration_token
,
1
,
1
)
migrate!
(
:settings
,
1
,
1
)
encrypted_token
=
settings
.
first
.
runners_registration_token_encrypted
decrypted_token
=
::
Gitlab
::
CryptoHelper
.
aes256_gcm_decrypt
(
encrypted_token
)
...
...
@@ -30,7 +30,7 @@ describe Gitlab::BackgroundMigration::EncryptRunnersTokens, :migration, schema:
end
it
'migrates runners registration tokens'
do
migrate!
(
:namespace
,
:runners_token
,
11
,
22
)
migrate!
(
:namespace
,
11
,
22
)
expect
(
namespaces
.
all
.
reload
).
to
all
(
have_attributes
(
runners_token:
nil
,
runners_token_encrypted:
be_a
(
String
))
...
...
@@ -47,7 +47,7 @@ describe Gitlab::BackgroundMigration::EncryptRunnersTokens, :migration, schema:
end
it
'migrates runners registration tokens'
do
migrate!
(
:project
,
:runners_token
,
111
,
116
)
migrate!
(
:project
,
111
,
116
)
expect
(
projects
.
all
.
reload
).
to
all
(
have_attributes
(
runners_token:
nil
,
runners_token_encrypted:
be_a
(
String
))
...
...
@@ -63,7 +63,7 @@ describe Gitlab::BackgroundMigration::EncryptRunnersTokens, :migration, schema:
end
it
'migrates runners communication tokens'
do
migrate!
(
:runner
,
:token
,
201
,
203
)
migrate!
(
:runner
,
201
,
203
)
expect
(
runners
.
all
.
reload
).
to
all
(
have_attributes
(
token:
nil
,
token_encrypted:
be_a
(
String
))
...
...
@@ -71,9 +71,7 @@ describe Gitlab::BackgroundMigration::EncryptRunnersTokens, :migration, schema:
end
end
def
migrate!
(
model
,
attribute
,
from
,
to
)
model
=
"::Gitlab::BackgroundMigration::Models::EncryptColumns::
#{
model
.
to_s
.
capitalize
}
"
subject
.
perform
(
model
,
[
attribute
],
from
,
to
)
def
migrate!
(
model
,
from
,
to
)
subject
.
perform
(
model
,
from
,
to
)
end
end
spec/migrations/schedule_runners_token_encryption_spec.rb
浏览文件 @
1143411a
...
...
@@ -24,6 +24,13 @@ describe ScheduleRunnersTokenEncryption, :migration do
Timecop
.
freeze
do
migrate!
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_delayed_migration
(
2
.
minutes
,
'settings'
,
1
,
1
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_delayed_migration
(
2
.
minutes
,
'namespace'
,
11
,
11
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_delayed_migration
(
4
.
minutes
,
'namespace'
,
12
,
12
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_delayed_migration
(
2
.
minutes
,
'project'
,
111
,
111
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_delayed_migration
(
4
.
minutes
,
'project'
,
114
,
114
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_delayed_migration
(
2
.
minutes
,
'runner'
,
201
,
201
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_delayed_migration
(
4
.
minutes
,
'runner'
,
202
,
202
)
expect
(
BackgroundMigrationWorker
.
jobs
.
size
).
to
eq
7
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录