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
15802cc4
Commit
15802cc4
authored
Jul 05, 2020
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: Geo file downloads can block Sidekiq threads
It sets a timeout for downloads of Geo files
parent
f007fc33
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
3 deletions
+36
-3
ee/changelogs/unreleased/221239-geo-file-downloads-can-block-sidekiq-threads.yml
...d/221239-geo-file-downloads-can-block-sidekiq-threads.yml
+5
-0
ee/lib/gitlab/geo/replication/base_transfer.rb
ee/lib/gitlab/geo/replication/base_transfer.rb
+8
-3
ee/spec/lib/gitlab/geo/replication/base_transfer_spec.rb
ee/spec/lib/gitlab/geo/replication/base_transfer_spec.rb
+23
-0
No files found.
ee/changelogs/unreleased/221239-geo-file-downloads-can-block-sidekiq-threads.yml
0 → 100644
View file @
15802cc4
---
title
:
'
Fix:
Geo
file
downloads
can
block
Sidekiq
threads'
merge_request
:
author
:
type
:
fixed
ee/lib/gitlab/geo/replication/base_transfer.rb
View file @
15802cc4
...
@@ -8,7 +8,12 @@ module Gitlab
...
@@ -8,7 +8,12 @@ module Gitlab
attr_reader
:file_type
,
:file_id
,
:filename
,
:expected_checksum
,
:request_data
,
:resource
attr_reader
:file_type
,
:file_id
,
:filename
,
:expected_checksum
,
:request_data
,
:resource
TEMP_PREFIX
=
'tmp_'
.
freeze
TEMP_PREFIX
=
'tmp_'
DOWNLOAD_TIMEOUT
=
{
connect:
60
,
write:
60
,
read:
60
}.
freeze
def
initialize
(
resource
:,
file_type
:,
file_id
:,
request_data
:,
expected_checksum:
nil
,
filename:
nil
)
def
initialize
(
resource
:,
file_type
:,
file_id
:,
request_data
:,
expected_checksum:
nil
,
filename:
nil
)
@resource
=
resource
@resource
=
resource
...
@@ -128,7 +133,7 @@ module Gitlab
...
@@ -128,7 +133,7 @@ module Gitlab
begin
begin
# Make the request
# Make the request
response
=
::
HTTP
.
get
(
url
,
headers:
req_headers
)
response
=
::
HTTP
.
timeout
(
DOWNLOAD_TIMEOUT
.
dup
).
get
(
url
,
headers:
req_headers
)
# Check for failures
# Check for failures
unless
response
.
status
.
success?
unless
response
.
status
.
success?
...
@@ -183,7 +188,7 @@ module Gitlab
...
@@ -183,7 +188,7 @@ module Gitlab
begin
begin
# Make the request
# Make the request
response
=
::
HTTP
.
follow
.
get
(
url
,
headers:
req_headers
)
response
=
::
HTTP
.
timeout
(
DOWNLOAD_TIMEOUT
.
dup
).
follow
.
get
(
url
,
headers:
req_headers
)
# Check for failures
# Check for failures
unless
response
.
status
.
success?
unless
response
.
status
.
success?
...
...
ee/spec/lib/gitlab/geo/replication/base_transfer_spec.rb
View file @
15802cc4
...
@@ -23,6 +23,29 @@ RSpec.describe Gitlab::Geo::Replication::BaseTransfer do
...
@@ -23,6 +23,29 @@ RSpec.describe Gitlab::Geo::Replication::BaseTransfer do
end
end
end
end
describe
'timeout'
do
subject
do
described_class
.
new
(
file_type: :avatar
,
file_id:
1
,
filename:
Tempfile
.
new
,
expected_checksum:
nil
,
request_data:
nil
,
resource:
nil
)
end
before
do
stub_current_geo_node
(
secondary_node
)
end
it
'sets a timeout when downbloads to local storage'
do
expect
(
::
HTTP
).
to
receive
(
:timeout
)
subject
.
download_from_primary
end
it
'sets a timeout when streaming to object storage'
do
expect
(
::
HTTP
).
to
receive
(
:timeout
)
subject
.
stream_from_primary_to_object_storage
end
end
describe
'#can_transfer?'
do
describe
'#can_transfer?'
do
subject
do
subject
do
described_class
.
new
(
file_type: :avatar
,
file_id:
1
,
filename:
Tempfile
.
new
,
described_class
.
new
(
file_type: :avatar
,
file_id:
1
,
filename:
Tempfile
.
new
,
...
...
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