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
7ed85256
Commit
7ed85256
authored
Mar 24, 2022
by
Matthias Käppler
Committed by
Jacob Vosmaer
Mar 24, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clarify local storage vs temp storage in WH uploads
parent
e6a0f5b9
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
14 deletions
+20
-14
workhorse/internal/upload/artifacts_upload_test.go
workhorse/internal/upload/artifacts_upload_test.go
+1
-1
workhorse/internal/upload/destination/destination.go
workhorse/internal/upload/destination/destination.go
+13
-8
workhorse/internal/upload/destination/upload_opts.go
workhorse/internal/upload/destination/upload_opts.go
+2
-2
workhorse/internal/upload/destination/upload_opts_test.go
workhorse/internal/upload/destination/upload_opts_test.go
+2
-2
workhorse/tools.go
workhorse/tools.go
+2
-1
No files found.
workhorse/internal/upload/artifacts_upload_test.go
View file @
7ed85256
...
...
@@ -66,7 +66,7 @@ func testArtifactsUploadServer(t *testing.T, authResponse *api.Response, bodyPro
if
r
.
Method
!=
"POST"
{
t
.
Fatal
(
"Expected POST request"
)
}
if
opts
.
IsLocal
()
{
if
opts
.
IsLocal
TempFile
()
{
if
r
.
FormValue
(
"file.path"
)
==
""
{
t
.
Fatal
(
"Expected file to be present"
)
return
...
...
workhorse/internal/upload/destination/destination.go
View file @
7ed85256
...
...
@@ -128,9 +128,14 @@ func Upload(ctx context.Context, reader io.Reader, size int64, opts *UploadOpts)
var
uploadDestination
consumer
var
err
error
switch
{
case
opts
.
IsLocal
()
:
clientMode
=
"local"
// This case means Workhorse is acting as an upload proxy for Rails and buffers files
// to disk in a temporary location, see:
// https://docs.gitlab.com/ee/development/uploads/background.html#moving-disk-buffering-to-workhorse
case
opts
.
IsLocalTempFile
()
:
clientMode
=
"local_tempfile"
uploadDestination
,
err
=
fh
.
newLocalFile
(
ctx
,
opts
)
// All cases below mean we are doing a direct upload to remote i.e. object storage, see:
// https://docs.gitlab.com/ee/development/uploads/background.html#moving-to-object-storage-and-direct-uploads
case
opts
.
UseWorkhorseClientEnabled
()
&&
opts
.
ObjectStorageConfig
.
IsGoCloud
()
:
clientMode
=
fmt
.
Sprintf
(
"go_cloud:%s"
,
opts
.
ObjectStorageConfig
.
Provider
)
p
:=
&
objectstore
.
GoCloudObjectParams
{
...
...
@@ -141,14 +146,14 @@ func Upload(ctx context.Context, reader io.Reader, size int64, opts *UploadOpts)
}
uploadDestination
,
err
=
objectstore
.
NewGoCloudObject
(
p
)
case
opts
.
UseWorkhorseClientEnabled
()
&&
opts
.
ObjectStorageConfig
.
IsAWS
()
&&
opts
.
ObjectStorageConfig
.
IsValid
()
:
clientMode
=
"s3"
clientMode
=
"s3
_client
"
uploadDestination
,
err
=
objectstore
.
NewS3Object
(
opts
.
RemoteTempObjectID
,
opts
.
ObjectStorageConfig
.
S3Credentials
,
opts
.
ObjectStorageConfig
.
S3Config
,
)
case
opts
.
IsMultipart
()
:
clientMode
=
"multipart"
clientMode
=
"
s3_
multipart"
uploadDestination
,
err
=
objectstore
.
NewMultipart
(
opts
.
PresignedParts
,
opts
.
PresignedCompleteMultipart
,
...
...
@@ -158,7 +163,7 @@ func Upload(ctx context.Context, reader io.Reader, size int64, opts *UploadOpts)
opts
.
PartSize
,
)
default
:
clientMode
=
"
http
"
clientMode
=
"
presigned_put
"
uploadDestination
,
err
=
objectstore
.
NewObject
(
opts
.
PresignedPut
,
opts
.
PresignedDelete
,
...
...
@@ -195,15 +200,15 @@ func Upload(ctx context.Context, reader io.Reader, size int64, opts *UploadOpts)
logger
:=
log
.
WithContextFields
(
ctx
,
log
.
Fields
{
"copied_bytes"
:
fh
.
Size
,
"is_local"
:
opts
.
IsLocal
(),
"is_local"
:
opts
.
IsLocal
TempFile
(),
"is_multipart"
:
opts
.
IsMultipart
(),
"is_remote"
:
!
opts
.
IsLocal
(),
"is_remote"
:
!
opts
.
IsLocal
TempFile
(),
"remote_id"
:
opts
.
RemoteID
,
"temp_file_prefix"
:
opts
.
TempFilePrefix
,
"client_mode"
:
clientMode
,
})
if
opts
.
IsLocal
()
{
if
opts
.
IsLocal
TempFile
()
{
logger
=
logger
.
WithField
(
"local_temp_path"
,
opts
.
LocalTempPath
)
}
else
{
logger
=
logger
.
WithField
(
"remote_temp_object"
,
opts
.
RemoteTempObjectID
)
...
...
workhorse/internal/upload/destination/upload_opts.go
View file @
7ed85256
...
...
@@ -70,8 +70,8 @@ func (s *UploadOpts) UseWorkhorseClientEnabled() bool {
return
s
.
UseWorkhorseClient
&&
s
.
ObjectStorageConfig
.
IsValid
()
&&
s
.
RemoteTempObjectID
!=
""
}
// IsLocal
checks if the options require the writing of the
file on disk
func
(
s
*
UploadOpts
)
IsLocal
()
bool
{
// IsLocal
TempFile checks if the options require the writing of a temporary
file on disk
func
(
s
*
UploadOpts
)
IsLocal
TempFile
()
bool
{
return
s
.
LocalTempPath
!=
""
}
...
...
workhorse/internal/upload/destination/upload_opts_test.go
View file @
7ed85256
...
...
@@ -49,7 +49,7 @@ func TestUploadOptsLocalAndRemote(t *testing.T) {
PartSize
:
test
.
partSize
,
}
require
.
Equal
(
t
,
test
.
isLocal
,
opts
.
IsLocal
(),
"IsLocal
() mismatch"
)
require
.
Equal
(
t
,
test
.
isLocal
,
opts
.
IsLocal
TempFile
(),
"IsLocalTempFile
() mismatch"
)
require
.
Equal
(
t
,
test
.
isMultipart
,
opts
.
IsMultipart
(),
"IsMultipart() mismatch"
)
})
}
...
...
@@ -336,7 +336,7 @@ func TestGoCloudConfig(t *testing.T) {
require
.
Equal
(
t
,
apiResponse
.
RemoteObject
.
ObjectStorage
.
GoCloudConfig
,
opts
.
ObjectStorageConfig
.
GoCloudConfig
)
require
.
True
(
t
,
opts
.
UseWorkhorseClientEnabled
())
require
.
Equal
(
t
,
test
.
valid
,
opts
.
ObjectStorageConfig
.
IsValid
())
require
.
False
(
t
,
opts
.
IsLocal
())
require
.
False
(
t
,
opts
.
IsLocal
TempFile
())
})
}
}
workhorse/tools.go
View file @
7ed85256
//+build tools
//go:build tools
// +build tools
package
main
...
...
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