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
daa1c701
Commit
daa1c701
authored
Nov 23, 2017
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port rename of artifacts_* to legacy_artifacts_* to EE
parent
2ef226b8
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
20 additions
and
64 deletions
+20
-64
app/models/ci/build.rb
app/models/ci/build.rb
+1
-1
ee/app/uploaders/object_store_uploader.rb
ee/app/uploaders/object_store_uploader.rb
+12
-11
spec/controllers/projects/artifacts_controller_spec.rb
spec/controllers/projects/artifacts_controller_spec.rb
+1
-1
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+1
-1
spec/tasks/gitlab/artifacts_rake_spec.rb
spec/tasks/gitlab/artifacts_rake_spec.rb
+3
-27
spec/workers/object_storage_upload_worker_spec.rb
spec/workers/object_storage_upload_worker_spec.rb
+2
-23
No files found.
app/models/ci/build.rb
View file @
daa1c701
...
...
@@ -45,7 +45,7 @@ module Ci
end
scope
:with_artifacts_not_expired
,
->
()
{
with_artifacts
.
where
(
'artifacts_expire_at IS NULL OR artifacts_expire_at > ?'
,
Time
.
now
)
}
scope
:with_expired_artifacts
,
->
()
{
with_artifacts
.
where
(
'artifacts_expire_at < ?'
,
Time
.
now
)
}
scope
:with_artifacts_stored_locally
,
->
()
{
with_artifacts
.
where
(
artifacts_file_store:
[
nil
,
ArtifactUploader
::
LOCAL_STORE
])
}
scope
:with_artifacts_stored_locally
,
->
()
{
with_artifacts
.
where
(
artifacts_file_store:
[
nil
,
Legacy
ArtifactUploader
::
LOCAL_STORE
])
}
scope
:last_month
,
->
()
{
where
(
'created_at > ?'
,
Date
.
today
-
1
.
month
)
}
scope
:manual_actions
,
->
()
{
where
(
when: :manual
,
status:
COMPLETED_STATUSES
+
[
:manual
])
}
scope
:ref_protected
,
->
{
where
(
protected:
true
)
}
...
...
ee/app/uploaders/object_store_uploader.rb
View file @
daa1c701
...
...
@@ -38,13 +38,6 @@ class ObjectStoreUploader < CarrierWave::Uploader::Base
end
end
attr_reader
:subject
,
:field
def
initialize
(
subject
,
field
)
@subject
=
subject
@field
=
field
end
def
file_storage?
storage
.
is_a?
(
CarrierWave
::
Storage
::
File
)
end
...
...
@@ -54,7 +47,7 @@ class ObjectStoreUploader < CarrierWave::Uploader::Base
end
def
real_object_store
subject
.
public_send
(
:"
#{
field
}
_store"
)
# rubocop:disable GitlabSecurity/PublicSend
model
.
public_send
(
store_serialization_column
)
# rubocop:disable GitlabSecurity/PublicSend
end
def
object_store
...
...
@@ -63,7 +56,7 @@ class ObjectStoreUploader < CarrierWave::Uploader::Base
def
object_store
=
(
value
)
@storage
=
nil
subject
.
public_send
(
:"
#{
field
}
_store
="
,
value
)
# rubocop:disable GitlabSecurity/PublicSend
model
.
public_send
(
:"
#{
store_serialization_column
}
="
,
value
)
# rubocop:disable GitlabSecurity/PublicSend
end
def
store_dir
...
...
@@ -111,7 +104,7 @@ class ObjectStoreUploader < CarrierWave::Uploader::Base
# since we change storage store the new storage
# in case of failure delete new file
begin
subject
.
save!
model
.
save!
rescue
=>
e
new_file
.
delete
self
.
object_store
=
old_store
...
...
@@ -125,7 +118,7 @@ class ObjectStoreUploader < CarrierWave::Uploader::Base
def
schedule_migration_to_object_storage
(
new_file
)
if
self
.
class
.
object_store_enabled?
&&
licensed?
&&
file_storage?
ObjectStorageUploadWorker
.
perform_async
(
self
.
class
.
name
,
subject
.
class
.
name
,
field
,
subject
.
id
)
ObjectStorageUploadWorker
.
perform_async
(
self
.
class
.
name
,
model
.
class
.
name
,
mounted_as
,
model
.
id
)
end
end
...
...
@@ -194,6 +187,14 @@ class ObjectStoreUploader < CarrierWave::Uploader::Base
raise
NotImplementedError
end
def
serialization_column
model
.
class
.
uploader_option
(
mounted_as
,
:mount_on
)
||
mounted_as
end
def
store_serialization_column
:"
#{
serialization_column
}
_store"
end
def
storage
@storage
||=
if
object_store
==
REMOTE_STORE
...
...
spec/controllers/projects/artifacts_controller_spec.rb
View file @
daa1c701
...
...
@@ -149,7 +149,7 @@ describe Projects::ArtifactsController do
context
'when using local file storage'
do
it_behaves_like
'a valid file'
do
let
(
:store
)
{
ObjectStoreUploader
::
LOCAL_STORE
}
let
(
:archive_path
)
{
ArtifactUploader
.
local_store_path
}
let
(
:archive_path
)
{
Legacy
ArtifactUploader
.
local_store_path
}
end
end
...
...
spec/models/ci/build_spec.rb
View file @
daa1c701
...
...
@@ -163,7 +163,7 @@ describe Ci::Build do
context
'artifacts metadata does not exist'
do
before
do
build
.
update_attributes
(
artifacts_metadata:
nil
)
build
.
update_attributes
(
legacy_
artifacts_metadata:
nil
)
end
it
{
is_expected
.
to
be_falsy
}
...
...
spec/tasks/gitlab/artifacts_rake_spec.rb
View file @
daa1c701
...
...
@@ -15,38 +15,14 @@ describe 'gitlab:artifacts namespace rake task' do
context
'legacy artifacts'
do
describe
'migrate'
do
let
(
:build
)
{
create
(
:ci_build
,
artifacts_file_store:
store
,
artifacts_metadata_store:
store
)
}
before
do
# Mock the legacy way of artifacts
path
=
Rails
.
root
.
join
(
ArtifactUploader
.
local_store_path
,
build
.
created_at
.
utc
.
strftime
(
'%Y_%m'
),
build
.
project_id
.
to_s
,
build
.
id
.
to_s
)
FileUtils
.
mkdir_p
(
path
)
FileUtils
.
copy
(
Rails
.
root
.
join
(
'spec/fixtures/ci_build_artifacts.zip'
),
File
.
join
(
path
,
"ci_build_artifacts.zip"
))
FileUtils
.
copy
(
Rails
.
root
.
join
(
'spec/fixtures/ci_build_artifacts_metadata.gz'
),
File
.
join
(
path
,
"ci_build_artifacts_metadata.gz"
))
build
.
update_columns
(
artifacts_file:
'ci_build_artifacts.zip'
,
artifacts_metadata:
'ci_build_artifacts_metadata.gz'
)
end
let!
(
:build
)
{
create
(
:ci_build
,
:legacy_artifacts
,
artifacts_file_store:
store
,
artifacts_metadata_store:
store
)
}
context
'when local storage is used'
do
let
(
:store
)
{
ObjectStoreUploader
::
LOCAL_STORE
}
context
'and job does not have file store defined'
do
let
(
:object_storage_enabled
)
{
true
}
before
do
build
.
update
(
artifacts_file_store:
nil
)
end
let
(
:store
)
{
nil
}
it
"migrates file to remote storage"
do
subject
...
...
spec/workers/object_storage_upload_worker_spec.rb
View file @
daa1c701
...
...
@@ -49,33 +49,12 @@ describe ObjectStorageUploadWorker do
end
context
'for legacy artifacts'
do
let
(
:build
)
{
create
(
:ci_build
)
}
let
(
:uploader_class
)
{
ArtifactUploader
}
let
(
:build
)
{
create
(
:ci_build
,
:legacy_artifacts
)
}
let
(
:uploader_class
)
{
Legacy
ArtifactUploader
}
let
(
:subject_class
)
{
Ci
::
Build
}
let
(
:file_field
)
{
:artifacts_file
}
let
(
:subject_id
)
{
build
.
id
}
before
do
# Mock the legacy way of artifacts
path
=
Rails
.
root
.
join
(
uploader_class
.
local_store_path
,
build
.
created_at
.
utc
.
strftime
(
'%Y_%m'
),
build
.
project_id
.
to_s
,
build
.
id
.
to_s
)
FileUtils
.
mkdir_p
(
path
)
FileUtils
.
copy
(
Rails
.
root
.
join
(
'spec/fixtures/ci_build_artifacts.zip'
),
File
.
join
(
path
,
"ci_build_artifacts.zip"
))
FileUtils
.
copy
(
Rails
.
root
.
join
(
'spec/fixtures/ci_build_artifacts_metadata.gz'
),
File
.
join
(
path
,
"ci_build_artifacts_metadata.gz"
))
build
.
update_columns
(
artifacts_file:
'ci_build_artifacts.zip'
,
artifacts_metadata:
'ci_build_artifacts_metadata.gz'
)
end
context
'when local storage is used'
do
let
(
:store
)
{
local
}
...
...
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