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
773a89c7
Commit
773a89c7
authored
Feb 20, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix migrate! method
parent
02e1343b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
11 deletions
+52
-11
ee/app/uploaders/object_storage.rb
ee/app/uploaders/object_storage.rb
+5
-11
ee/lib/tasks/gitlab/data_loss.rake
ee/lib/tasks/gitlab/data_loss.rake
+47
-0
No files found.
ee/app/uploaders/object_storage.rb
View file @
773a89c7
...
@@ -106,7 +106,6 @@ module ObjectStorage
...
@@ -106,7 +106,6 @@ module ObjectStorage
base
.
include
(
ObjectStorage
)
base
.
include
(
ObjectStorage
)
before
:store
,
:verify_license!
before
:store
,
:verify_license!
after
:migrate
,
:delete_migrated_file
end
end
class_methods
do
class_methods
do
...
@@ -205,12 +204,11 @@ module ObjectStorage
...
@@ -205,12 +204,11 @@ module ObjectStorage
cache_stored_file!
if
file_storage?
cache_stored_file!
if
file_storage?
with_callbacks
(
:migrate
,
file_to_delete
)
do
with_callbacks
(
:store
,
file_to_delete
)
do
# for #store_versions!
with_callbacks
(
:store
,
file_to_delete
)
do
# for #store_versions!
new_file
=
storage
.
store!
(
file
)
new_file
=
storage
.
store!
(
file
)
file_to_delete
.
delete
persist_object_store!
persist_object_store!
self
.
file
=
new_file
self
.
file
=
new_file
end
end
end
file
file
...
@@ -244,10 +242,6 @@ module ObjectStorage
...
@@ -244,10 +242,6 @@ module ObjectStorage
false
false
end
end
def
delete_migrated_file
(
migrated_file
)
migrated_file
.
delete
if
exists?
end
def
verify_license!
(
_file
)
def
verify_license!
(
_file
)
return
if
file_storage?
return
if
file_storage?
...
...
ee/lib/tasks/gitlab/data_loss.rake
0 → 100644
View file @
773a89c7
require
'logger'
require
'resolv-replace'
desc
"GitLab | Migrate files for artifacts to comply with new storage format"
namespace
:gitlab
do
namespace
:data_loss
do
task
simulate: :environment
do
logger
=
Logger
.
new
(
STDOUT
)
logger
.
info
(
'Simulating...'
)
SAMPLE
=
100
project
=
Project
.
find_by
(
id:
28
)
user
=
User
.
first
pipeline
=
Ci
::
Pipeline
.
last
last_job_id
=
Ci
::
Build
.
last
.
id
logger
.
info
(
"last_job_id:
#{
last_job_id
}
"
)
loop
do
if
Ci
::
Build
.
where
(
'id > ?'
,
last_job_id
).
count
<
SAMPLE
job
=
FactoryBot
.
create
(
:ci_build
,
:success
,
:trace_live
,
project:
project
,
user:
user
,
pipeline:
pipeline
)
CreateTraceArtifactWorker
.
perform_async
(
job
.
id
)
end
trace_artifacts
=
Ci
::
JobArtifact
.
where
(
file_store:
2
).
where
(
'job_id > ?'
,
last_job_id
)
trace_artifacts
.
each
{
|
t
|
t
.
file
.
migrate!
(
ObjectStorage
::
Store
::
LOCAL
)
}
break
if
Ci
::
JobArtifact
.
where
(
file_store:
1
).
where
(
'job_id > ?'
,
last_job_id
).
count
==
SAMPLE
end
success
=
Ci
::
JobArtifact
.
where
(
'job_id > ?'
,
last_job_id
).
all
.
inject
(
0
)
do
|
sum
,
trace_artifact
|
raise
'Unexpected'
unless
trace_artifact
.
file_store
==
ObjectStorage
::
Store
::
LOCAL
sum
+=
1
if
trace_artifact
.
file
.
file
.
exists?
sum
end
# Ci::JobArtifact.where('job_id > ?', last_job_id).each do |trace_artifact|
# logger.info("trace_artifact: #{trace_artifact.inspect}")
# end
loss
=
((
SAMPLE
-
success
).
to_f
/
SAMPLE
.
to_f
)
*
100.0
logger
.
info
(
"Sample:
#{
SAMPLE
}
. Loss rate:
#{
loss
}
"
)
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