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
c7a39ffa
Commit
c7a39ffa
authored
Nov 21, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Schedule background migration for encrypting runners tokens
parent
64c23778
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
1 deletion
+59
-1
db/post_migrate/20181121111200_schedule_runners_token_encryption.rb
...grate/20181121111200_schedule_runners_token_encryption.rb
+38
-0
db/schema.rb
db/schema.rb
+1
-1
lib/gitlab/background_migration/encrypt_runners_tokens.rb
lib/gitlab/background_migration/encrypt_runners_tokens.rb
+20
-0
No files found.
db/post_migrate/20181121111200_schedule_runners_token_encryption.rb
0 → 100644
View file @
c7a39ffa
# frozen_string_literal: true
class
ScheduleRunnersTokenEncryption
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
BATCH_SIZE
=
10000
RANGE_SIZE
=
100
MIGRATION
=
'EncryptRunnersTokens'
MODELS
=
[
::
Gitlab
::
BackgroundMigration
::
Models
::
EncryptColumns
::
Settings
,
::
Gitlab
::
BackgroundMigration
::
Models
::
EncryptColumns
::
Namespace
,
::
Gitlab
::
BackgroundMigration
::
Models
::
EncryptColumns
::
Project
,
::
Gitlab
::
BackgroundMigration
::
Models
::
EncryptColumns
::
Runner
].
freeze
disable_ddl_transaction!
def
up
MODELS
.
each
do
|
model
|
model
.
each_batch
(
of:
BATCH_SIZE
)
do
|
relation
,
index
|
delay
=
index
*
2
.
minutes
relation
.
each_batch
(
of:
RANGE_SIZE
)
do
|
relation
|
range
=
relation
.
pluck
(
'MIN(id)'
,
'MAX(id)'
).
first
args
=
[
model
,
model
.
encrypted_attributes
.
keys
,
*
range
]
BackgroundMigrationWorker
.
perform_in
(
delay
,
MIGRATION
,
args
)
end
end
end
end
def
down
# no-op
end
end
db/schema.rb
View file @
c7a39ffa
...
...
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
201811211
01802
)
do
ActiveRecord
::
Schema
.
define
(
version:
201811211
11200
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
lib/gitlab/background_migration/encrypt_runners_tokens.rb
0 → 100644
View file @
c7a39ffa
# frozen_string_literal: true
module
Gitlab
module
BackgroundMigration
# EncryptColumn migrates data from an unencrypted column - `foo`, say - to
# an encrypted column - `encrypted_foo`, say.
#
# We only create a subclass here because we want to isolate this migration
# (migrating unencrypted runner registration tokens to encrypted columns)
# from other `EncryptColumns` migration. This class name is going to be
# serialized and stored in Redis and later picked by Sidekiq, so we need to
# create a separate class name in order to isolate these migration tasks.
#
# We can solve this differently, see tech debt issue:
#
# https://gitlab.com/gitlab-org/gitlab-ce/issues/54328
#
class
EncryptRunnersTokens
<
EncryptColumns
;
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