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
44f37504
Commit
44f37504
authored
Mar 09, 2018
by
Micaël Bergeron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backport ee-40781-os-to-ce
parent
e1f076ec
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
147 additions
and
60 deletions
+147
-60
app/models/project.rb
app/models/project.rb
+2
-1
app/models/upload.rb
app/models/upload.rb
+2
-0
app/uploaders/lfs_object_uploader.rb
app/uploaders/lfs_object_uploader.rb
+0
-5
config/gitlab.yml.example
config/gitlab.yml.example
+12
-14
config/sidekiq_queues.yml
config/sidekiq_queues.yml
+0
-1
db/migrate/20170601163708_add_artifacts_store_to_ci_build.rb
db/migrate/20170601163708_add_artifacts_store_to_ci_build.rb
+3
-10
ee/spec/requests/api/jobs_spec.rb
ee/spec/requests/api/jobs_spec.rb
+72
-0
lib/gitlab/ci/trace/http_io.rb
lib/gitlab/ci/trace/http_io.rb
+4
-0
spec/controllers/concerns/send_file_upload_spec.rb
spec/controllers/concerns/send_file_upload_spec.rb
+5
-3
spec/features/projects/import_export/test_project_export.tar.gz
...eatures/projects/import_export/test_project_export.tar.gz
+0
-0
spec/lib/gitlab/ci/trace/http_io_spec.rb
spec/lib/gitlab/ci/trace/http_io_spec.rb
+6
-20
spec/requests/api/jobs_spec.rb
spec/requests/api/jobs_spec.rb
+41
-6
No files found.
app/models/project.rb
View file @
44f37504
...
@@ -188,6 +188,8 @@ class Project < ActiveRecord::Base
...
@@ -188,6 +188,8 @@ class Project < ActiveRecord::Base
has_many
:todos
has_many
:todos
has_many
:notification_settings
,
as: :source
,
dependent: :delete_all
# rubocop:disable Cop/ActiveRecordDependent
has_many
:notification_settings
,
as: :source
,
dependent: :delete_all
# rubocop:disable Cop/ActiveRecordDependent
has_many
:internal_ids
has_one
:import_data
,
class_name:
'ProjectImportData'
,
inverse_of: :project
,
autosave:
true
has_one
:import_data
,
class_name:
'ProjectImportData'
,
inverse_of: :project
,
autosave:
true
has_one
:project_feature
,
inverse_of: :project
has_one
:project_feature
,
inverse_of: :project
has_one
:statistics
,
class_name:
'ProjectStatistics'
has_one
:statistics
,
class_name:
'ProjectStatistics'
...
@@ -290,7 +292,6 @@ class Project < ActiveRecord::Base
...
@@ -290,7 +292,6 @@ class Project < ActiveRecord::Base
scope
:non_archived
,
->
{
where
(
archived:
false
)
}
scope
:non_archived
,
->
{
where
(
archived:
false
)
}
scope
:for_milestones
,
->
(
ids
)
{
joins
(
:milestones
).
where
(
'milestones.id'
=>
ids
).
distinct
}
scope
:for_milestones
,
->
(
ids
)
{
joins
(
:milestones
).
where
(
'milestones.id'
=>
ids
).
distinct
}
scope
:with_push
,
->
{
joins
(
:events
).
where
(
'events.action = ?'
,
Event
::
PUSHED
)
}
scope
:with_push
,
->
{
joins
(
:events
).
where
(
'events.action = ?'
,
Event
::
PUSHED
)
}
scope
:with_project_feature
,
->
{
joins
(
'LEFT JOIN project_features ON projects.id = project_features.project_id'
)
}
scope
:with_project_feature
,
->
{
joins
(
'LEFT JOIN project_features ON projects.id = project_features.project_id'
)
}
scope
:with_statistics
,
->
{
includes
(
:statistics
)
}
scope
:with_statistics
,
->
{
includes
(
:statistics
)
}
scope
:with_shared_runners
,
->
{
where
(
shared_runners_enabled:
true
)
}
scope
:with_shared_runners
,
->
{
where
(
shared_runners_enabled:
true
)
}
...
...
app/models/upload.rb
View file @
44f37504
class
Upload
<
ActiveRecord
::
Base
class
Upload
<
ActiveRecord
::
Base
prepend
EE
::
Upload
# Upper limit for foreground checksum processing
# Upper limit for foreground checksum processing
CHECKSUM_THRESHOLD
=
100
.
megabytes
CHECKSUM_THRESHOLD
=
100
.
megabytes
...
...
app/uploaders/lfs_object_uploader.rb
View file @
44f37504
...
@@ -2,11 +2,6 @@ class LfsObjectUploader < GitlabUploader
...
@@ -2,11 +2,6 @@ class LfsObjectUploader < GitlabUploader
extend
Workhorse
::
UploadPath
extend
Workhorse
::
UploadPath
include
ObjectStorage
::
Concern
include
ObjectStorage
::
Concern
# LfsObject are in `tmp/upload` instead of `tmp/uploads`
def
self
.
workhorse_upload_path
File
.
join
(
root
,
'tmp/upload'
)
end
storage_options
Gitlab
.
config
.
lfs
storage_options
Gitlab
.
config
.
lfs
def
filename
def
filename
...
...
config/gitlab.yml.example
View file @
44f37504
...
@@ -182,19 +182,18 @@ production: &base
...
@@ -182,19 +182,18 @@ production: &base
# storage_path: public/
# storage_path: public/
# base_dir: uploads/-/system
# base_dir: uploads/-/system
object_store:
object_store:
enabled: true
enabled: false
remote_directory: uploads # Bucket name
# remote_directory: uploads # Bucket name
# background_upload: false # Temporary option to limit automatic upload (Default: true)
# background_upload: false # Temporary option to limit automatic upload (Default: true)
# proxy_download: false # Passthrough all downloads via GitLab instead of using Redirects to Object Storage
# proxy_download: false # Passthrough all downloads via GitLab instead of using Redirects to Object Storage
connection:
# connection:
provider: AWS
# provider: AWS
aws_access_key_id: AWS_ACCESS_KEY_ID
# aws_access_key_id: AWS_ACCESS_KEY_ID
aws_secret_access_key: AWS_SECRET_ACCESS_KEY
# aws_secret_access_key: AWS_SECRET_ACCESS_KEY
region: eu-central-1
# region: eu-central-1
# Use the following options to configure an AWS compatible host
# host: 'localhost' # default: s3.amazonaws.com
# host: 'localhost' # default: s3.amazonaws.com
# endpoint: 'http://127.0.0.1:9000' # default: nil
# endpoint: 'http://127.0.0.1:9000' # default: nil
# path_style: true # Use 'host/bucket_name/object' instead of 'bucket_name.host/object'
# path_style: true # Use 'host/bucket_name/object' instead of 'bucket_name.host/object'
## GitLab Pages
## GitLab Pages
pages:
pages:
...
@@ -719,7 +718,6 @@ test:
...
@@ -719,7 +718,6 @@ test:
region: eu-central-1
region: eu-central-1
uploads:
uploads:
storage_path: tmp/tests/public
storage_path: tmp/tests/public
enabled: true
object_store:
object_store:
enabled: false
enabled: false
connection:
connection:
...
...
config/sidekiq_queues.yml
View file @
44f37504
...
@@ -64,7 +64,6 @@
...
@@ -64,7 +64,6 @@
- [update_user_activity, 1]
- [update_user_activity, 1]
- [propagate_service_template, 1]
- [propagate_service_template, 1]
- [background_migration, 1]
- [background_migration, 1]
- [object_storage_upload, 1]
- [gcp_cluster, 1]
- [gcp_cluster, 1]
- [project_migrate_hashed_storage, 1]
- [project_migrate_hashed_storage, 1]
- [storage_migrator, 1]
- [storage_migrator, 1]
...
...
db/migrate/20170601163708_add_artifacts_store_to_ci_build.rb
View file @
44f37504
...
@@ -3,15 +3,8 @@ class AddArtifactsStoreToCiBuild < ActiveRecord::Migration
...
@@ -3,15 +3,8 @@ class AddArtifactsStoreToCiBuild < ActiveRecord::Migration
DOWNTIME
=
false
DOWNTIME
=
false
disable_ddl_transaction!
def
change
add_column
(
:ci_builds
,
:artifacts_file_store
,
:integer
)
def
up
add_column
(
:ci_builds
,
:artifacts_metadata_store
,
:integer
)
add_column_with_default
(
:ci_builds
,
:artifacts_file_store
,
:integer
,
default:
1
)
add_column_with_default
(
:ci_builds
,
:artifacts_metadata_store
,
:integer
,
default:
1
)
end
def
down
remove_column
(
:ci_builds
,
:artifacts_file_store
)
remove_column
(
:ci_builds
,
:artifacts_metadata_store
)
end
end
end
end
ee/spec/requests/api/jobs_spec.rb
0 → 100644
View file @
44f37504
require
'spec_helper'
describe
API
::
Jobs
do
set
(
:project
)
do
create
(
:project
,
:repository
,
public_builds:
false
)
end
set
(
:pipeline
)
do
create
(
:ci_empty_pipeline
,
project:
project
,
sha:
project
.
commit
.
id
,
ref:
project
.
default_branch
)
end
let!
(
:job
)
{
create
(
:ci_build
,
:success
,
pipeline:
pipeline
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:api_user
)
{
user
}
let
(
:reporter
)
{
create
(
:project_member
,
:reporter
,
project:
project
).
user
}
let
(
:cross_project_pipeline_enabled
)
{
true
}
before
do
stub_licensed_features
(
cross_project_pipelines:
cross_project_pipeline_enabled
)
project
.
add_developer
(
user
)
end
describe
'GET /projects/:id/jobs/:job_id/artifacts'
do
shared_examples
'downloads artifact'
do
let
(
:download_headers
)
do
{
'Content-Transfer-Encoding'
=>
'binary'
,
'Content-Disposition'
=>
'attachment; filename=ci_build_artifacts.zip'
}
end
it
'returns specific job artifacts'
do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
.
headers
).
to
include
(
download_headers
)
expect
(
response
.
body
).
to
match_file
(
job
.
artifacts_file
.
file
.
file
)
end
end
context
'authorized by job_token'
do
let
(
:job
)
{
create
(
:ci_build
,
:artifacts
,
pipeline:
pipeline
,
user:
api_user
)
}
before
do
get
api
(
"/projects/
#{
project
.
id
}
/jobs/
#{
job
.
id
}
/artifacts"
),
job_token:
job
.
token
end
context
'user is developer'
do
let
(
:api_user
)
{
user
}
it_behaves_like
'downloads artifact'
end
context
'when anonymous user is accessing private artifacts'
do
let
(
:api_user
)
{
nil
}
it
'hides artifacts and rejects request'
do
expect
(
project
).
to
be_private
expect
(
response
).
to
have_gitlab_http_status
(
404
)
end
end
context
'feature is disabled for EES'
do
let
(
:api_user
)
{
user
}
let
(
:cross_project_pipeline_enabled
)
{
false
}
it
'disallows access to the artifacts'
do
expect
(
response
).
to
have_gitlab_http_status
(
404
)
end
end
end
end
end
lib/gitlab/ci/trace/http_io.rb
View file @
44f37504
...
@@ -37,6 +37,10 @@ module Gitlab
...
@@ -37,6 +37,10 @@ module Gitlab
end
end
def
path
def
path
nil
end
def
url
@uri
.
to_s
@uri
.
to_s
end
end
...
...
spec/controllers/concerns/send_file_upload_spec.rb
View file @
44f37504
...
@@ -64,10 +64,12 @@ describe SendFileUpload do
...
@@ -64,10 +64,12 @@ describe SendFileUpload do
end
end
it
'sends a file'
do
it
'sends a file'
do
subject
headers
=
double
expect
(
headers
).
to
receive
(
:store
).
with
(
Gitlab
::
Workhorse
::
SEND_DATA_HEADER
,
/^send-url:/
)
expect
(
controller
).
to
receive
(
:headers
)
{
headers
}
expect
(
controller
).
to
receive
(
:head
).
with
(
:ok
)
is_expected
.
to
start_with
(
Gitlab
::
Workhorse
::
SEND_DATA_HEADER
)
subject
is_expected
.
to
end_with
(
/^send-url:/
)
end
end
end
end
...
...
spec/features/projects/import_export/test_project_export.tar.gz
View file @
44f37504
No preview for this file type
spec/lib/gitlab/ci/trace/http_io_spec.rb
View file @
44f37504
...
@@ -7,26 +7,6 @@ describe Gitlab::Ci::Trace::HttpIO do
...
@@ -7,26 +7,6 @@ describe Gitlab::Ci::Trace::HttpIO do
let
(
:url
)
{
remote_trace_url
}
let
(
:url
)
{
remote_trace_url
}
let
(
:size
)
{
remote_trace_size
}
let
(
:size
)
{
remote_trace_size
}
describe
'Interchangeability between IO and HttpIO'
do
EXCEPT_METHODS
=
%i[read_nonblock raw raw! cooked cooked! getch echo= echo?
winsize winsize= iflush oflush ioflush beep goto cursor cursor= pressed?
getpass write_nonblock stat pathconf wait_readable wait_writable getbyte <<
wait lines bytes chars codepoints getc readpartial set_encoding printf print
putc puts readlines gets each each_byte each_char each_codepoint to_io reopen
syswrite to_i fileno sysread fdatasync fsync sync= sync lineno= lineno readchar
ungetbyte readbyte ungetc nonblock= nread rewind pos= eof close_on_exec?
close_on_exec= closed? close_read close_write isatty tty? binmode? sysseek
advise ioctl fcntl pid external_encoding internal_encoding autoclose? autoclose=
posix_fileno nonblock? ready? noecho nonblock]
.
freeze
it
'HttpIO covers core interfaces in IO'
do
expected_interfaces
=
::
IO
.
instance_methods
(
false
)
expected_interfaces
-=
EXCEPT_METHODS
expect
(
expected_interfaces
-
described_class
.
instance_methods
).
to
be_empty
end
end
describe
'#close'
do
describe
'#close'
do
subject
{
http_io
.
close
}
subject
{
http_io
.
close
}
...
@@ -48,6 +28,12 @@ describe Gitlab::Ci::Trace::HttpIO do
...
@@ -48,6 +28,12 @@ describe Gitlab::Ci::Trace::HttpIO do
describe
'#path'
do
describe
'#path'
do
subject
{
http_io
.
path
}
subject
{
http_io
.
path
}
it
{
is_expected
.
to
be_nil
}
end
describe
'#url'
do
subject
{
http_io
.
url
}
it
{
is_expected
.
to
eq
(
url
)
}
it
{
is_expected
.
to
eq
(
url
)
}
end
end
...
...
spec/requests/api/jobs_spec.rb
View file @
44f37504
...
@@ -21,6 +21,7 @@ describe API::Jobs do
...
@@ -21,6 +21,7 @@ describe API::Jobs do
let
(
:guest
)
{
create
(
:project_member
,
:guest
,
project:
project
).
user
}
let
(
:guest
)
{
create
(
:project_member
,
:guest
,
project:
project
).
user
}
before
do
before
do
stub_licensed_features
(
cross_project_pipelines:
true
)
project
.
add_developer
(
user
)
project
.
add_developer
(
user
)
end
end
...
@@ -316,11 +317,6 @@ describe API::Jobs do
...
@@ -316,11 +317,6 @@ describe API::Jobs do
end
end
end
end
before
do
stub_artifacts_object_storage
get
api
(
"/projects/
#{
project
.
id
}
/jobs/
#{
job
.
id
}
/artifacts"
,
api_user
)
end
context
'normal authentication'
do
context
'normal authentication'
do
context
'job with artifacts'
do
context
'job with artifacts'
do
context
'when artifacts are stored locally'
do
context
'when artifacts are stored locally'
do
...
@@ -344,8 +340,10 @@ describe API::Jobs do
...
@@ -344,8 +340,10 @@ describe API::Jobs do
end
end
context
'when artifacts are stored remotely'
do
context
'when artifacts are stored remotely'
do
let
(
:proxy_download
)
{
false
}
before
do
before
do
stub_artifacts_object_storage
stub_artifacts_object_storage
(
proxy_download:
proxy_download
)
end
end
let
(
:job
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let
(
:job
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
...
@@ -357,6 +355,20 @@ describe API::Jobs do
...
@@ -357,6 +355,20 @@ describe API::Jobs do
get
api
(
"/projects/
#{
project
.
id
}
/jobs/
#{
job
.
id
}
/artifacts"
,
api_user
)
get
api
(
"/projects/
#{
project
.
id
}
/jobs/
#{
job
.
id
}
/artifacts"
,
api_user
)
end
end
context
'when proxy download is enabled'
do
let
(
:proxy_download
)
{
true
}
it
'responds with the workhorse send-url'
do
expect
(
response
.
headers
[
Gitlab
::
Workhorse
::
SEND_DATA_HEADER
]).
to
start_with
(
"send-url:"
)
end
end
context
'when proxy download is disabled'
do
it
'returns location redirect'
do
expect
(
response
).
to
have_gitlab_http_status
(
302
)
end
end
context
'authorized user'
do
context
'authorized user'
do
it
'returns the file remote URL'
do
it
'returns the file remote URL'
do
expect
(
response
).
to
redirect_to
(
artifact
.
file
.
url
)
expect
(
response
).
to
redirect_to
(
artifact
.
file
.
url
)
...
@@ -495,6 +507,29 @@ describe API::Jobs do
...
@@ -495,6 +507,29 @@ describe API::Jobs do
it_behaves_like
'a valid file'
it_behaves_like
'a valid file'
end
end
context
'when using job_token to authenticate'
do
before
do
pipeline
.
reload
pipeline
.
update
(
ref:
'master'
,
sha:
project
.
commit
(
'master'
).
sha
)
get
api
(
"/projects/
#{
project
.
id
}
/jobs/artifacts/master/download"
),
job:
job
.
name
,
job_token:
job
.
token
end
context
'when user is reporter'
do
it_behaves_like
'a valid file'
end
context
'when user is admin, but not member'
do
let
(
:api_user
)
{
create
(
:admin
)
}
let
(
:job
)
{
create
(
:ci_build
,
:artifacts
,
pipeline:
pipeline
,
user:
api_user
)
}
it
'does not allow to see that artfiact is present'
do
expect
(
response
).
to
have_gitlab_http_status
(
404
)
end
end
end
end
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