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
8fa9b5ed
Commit
8fa9b5ed
authored
Sep 11, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Geo - Ignore S3-backed LFS objects on secondary nodes
parent
54621036
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
17 deletions
+24
-17
app/models/geo_node.rb
app/models/geo_node.rb
+8
-5
spec/workers/geo/file_download_dispatch_worker_spec.rb
spec/workers/geo/file_download_dispatch_worker_spec.rb
+16
-12
No files found.
app/models/geo_node.rb
View file @
8fa9b5ed
...
...
@@ -114,11 +114,14 @@ class GeoNode < ActiveRecord::Base
end
def
lfs_objects
relation
=
if
restricted_project_ids
LfsObject
.
joins
(
:projects
).
where
(
projects:
{
id:
restricted_project_ids
})
else
LfsObject
.
all
end
relation
.
with_files_stored_locally
end
def
projects
...
...
spec/workers/geo/file_download_dispatch_worker_spec.rb
View file @
8fa9b5ed
...
...
@@ -6,10 +6,9 @@ describe Geo::FileDownloadDispatchWorker do
before
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:secondary?
).
and_return
(
true
)
allow_any_instance_of
(
Gitlab
::
ExclusiveLease
)
.
to
receive
(
:try_obtain
).
and_return
(
true
)
allow_any_instance_of
(
Gitlab
::
ExclusiveLease
)
.
to
receive
(
:renew
).
and_return
(
true
)
allow_any_instance_of
(
Gitlab
::
ExclusiveLease
).
to
receive
(
:try_obtain
).
and_return
(
true
)
allow_any_instance_of
(
Gitlab
::
ExclusiveLease
).
to
receive
(
:renew
).
and_return
(
true
)
allow_any_instance_of
(
described_class
).
to
receive
(
:over_time?
).
and_return
(
false
)
WebMock
.
stub_request
(
:get
,
/primary-geo-node/
).
to_return
(
status:
200
,
body:
""
,
headers:
{})
end
...
...
@@ -37,14 +36,22 @@ describe Geo::FileDownloadDispatchWorker do
subject
.
perform
end
it
'executes GeoFileDownloadWorker for each LFS object'
do
create_list
(
:lfs_object
,
2
,
:with_file
)
context
'with LFS objects'
do
let!
(
:lfs_object_local_store
)
{
create
(
:lfs_object
,
:with_file
)
}
let!
(
:lfs_object_remote_store
)
{
create
(
:lfs_object
,
:with_file
)
}
allow_any_instance_of
(
described_class
).
to
receive
(
:over_time?
).
and_return
(
false
)
expect
(
GeoFileDownloadWorker
).
to
receive
(
:perform_async
).
twice
.
and_call_original
before
do
stub_lfs_object_storage
lfs_object_remote_store
.
file
.
migrate!
(
LfsObjectUploader
::
REMOTE_STORE
)
end
it
'filters S3-backed files'
do
expect
(
GeoFileDownloadWorker
).
to
receive
(
:perform_async
).
with
(
:lfs
,
lfs_object_local_store
.
id
)
expect
(
GeoFileDownloadWorker
).
not_to
receive
(
:perform_async
).
with
(
:lfs
,
lfs_object_remote_store
.
id
)
subject
.
perform
end
end
# Test the case where we have:
#
...
...
@@ -60,8 +67,6 @@ describe Geo::FileDownloadDispatchWorker do
create_list
(
:note
,
2
,
:with_attachment
)
create
(
:appearance
,
logo:
avatar
,
header_logo:
avatar
)
allow_any_instance_of
(
described_class
).
to
receive
(
:over_time?
).
and_return
(
false
)
expect
(
GeoFileDownloadWorker
).
to
receive
(
:perform_async
).
exactly
(
8
).
times
.
and_call_original
# For 8 downloads, we expect three database reloads:
# 1. Load the first batch of 5.
...
...
@@ -82,7 +87,6 @@ describe Geo::FileDownloadDispatchWorker do
before
do
allow
(
ProjectCacheWorker
).
to
receive
(
:perform_async
).
and_return
(
true
)
allow_any_instance_of
(
described_class
).
to
receive
(
:over_time?
).
and_return
(
false
)
secondary
.
update_attribute
(
:namespaces
,
[
synced_group
])
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