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
c12d9e8f
Commit
c12d9e8f
authored
Jul 08, 2020
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove upload registry query builder
Part of our effort to treat registry tables as the SSOT for uploads.
parent
50dbb5ad
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
4 additions
and
79 deletions
+4
-79
ee/app/services/geo/files_expire_service.rb
ee/app/services/geo/files_expire_service.rb
+3
-8
ee/lib/gitlab/geo/fdw/upload_registry_query_builder.rb
ee/lib/gitlab/geo/fdw/upload_registry_query_builder.rb
+0
-50
ee/spec/lib/gitlab/geo/fdw/upload_registry_query_builder_spec.rb
.../lib/gitlab/geo/fdw/upload_registry_query_builder_spec.rb
+0
-19
ee/spec/services/geo/files_expire_service_spec.rb
ee/spec/services/geo/files_expire_service_spec.rb
+1
-2
No files found.
ee/app/services/geo/files_expire_service.rb
View file @
c12d9e8f
...
...
@@ -25,11 +25,10 @@ module Geo
def
execute
return
unless
Gitlab
::
Geo
.
secondary?
uploads
=
Geo
::
Fdw
::
Upload
.
for_model
(
project
)
uploads
=
Upload
.
for_model
(
project
)
log_info
(
"Expiring replicated attachments after project rename"
,
count:
uploads
.
count
)
schedule_file_removal
(
uploads
)
mark_for_resync!
end
# Project's base directory for attachments storage
...
...
@@ -51,18 +50,14 @@ module Geo
log_info
(
"Scheduled to remove file"
,
file_path:
file_path
)
end
Geo
::
UploadRegistry
.
where
(
file_id:
upload
.
id
).
delete_all
end
Geo
::
FileRemovalWorker
.
bulk_perform_async
(
paths_to_remove
)
# rubocop:disable Scalability/BulkPerformWithContext
end
# rubocop: enable CodeReuse/ActiveRecord
def
mark_for_resync!
Gitlab
::
Geo
::
Fdw
::
UploadRegistryQueryBuilder
.
new
.
for_model
(
project
)
.
delete_all
end
# This is called by LogHelpers to build json log with context info
#
# @see ::Gitlab::Geo::LogHelpers
...
...
ee/lib/gitlab/geo/fdw/upload_registry_query_builder.rb
deleted
100644 → 0
View file @
50dbb5ad
# frozen_string_literal: true
# Builder class to create composable queries using FDW to
# retrieve file registries.
#
# Basic usage:
#
# Gitlab::Geo::Fdw::UploadRegistryQueryBuilder.new.for_model(project)
#
module
Gitlab
module
Geo
class
Fdw
class
UploadRegistryQueryBuilder
<
BaseQueryBuilder
# rubocop:disable CodeReuse/ActiveRecord
def
for_model
(
model
)
reflect
(
query
.
joins
(
fdw_inner_join_uploads
)
.
where
(
fdw_table
[
:model_id
].
eq
(
model
.
id
)
.
and
(
fdw_table
[
:model_type
].
eq
(
model
.
class
.
name
))
)
)
end
# rubocop:enable CodeReuse/ActiveRecord
private
def
base
::
Geo
::
UploadRegistry
.
select
(
registry_table
[
Arel
.
star
])
end
def
registry_table
::
Geo
::
UploadRegistry
.
arel_table
end
def
fdw_table
::
Geo
::
Fdw
::
Upload
.
arel_table
end
def
fdw_inner_join_uploads
registry_table
.
join
(
fdw_table
,
Arel
::
Nodes
::
InnerJoin
)
.
on
(
registry_table
[
:file_id
].
eq
(
fdw_table
[
:id
]))
.
join_sources
end
end
end
end
end
ee/spec/lib/gitlab/geo/fdw/upload_registry_query_builder_spec.rb
deleted
100644 → 0
View file @
50dbb5ad
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Gitlab
::
Geo
::
Fdw
::
UploadRegistryQueryBuilder
,
:geo
,
:geo_fdw
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:upload_1
)
{
create
(
:upload
,
:issuable_upload
,
model:
project
)
}
let
(
:upload_2
)
{
create
(
:upload
,
:issuable_upload
,
model:
project
)
}
let
(
:upload_3
)
{
create
(
:upload
,
:issuable_upload
)
}
let!
(
:registry_1
)
{
create
(
:geo_upload_registry
,
file_id:
upload_1
.
id
)
}
let!
(
:registry_2
)
{
create
(
:geo_upload_registry
,
:attachment
,
file_id:
upload_2
.
id
)
}
let!
(
:registry_3
)
{
create
(
:geo_upload_registry
,
file_id:
upload_3
.
id
)
}
describe
'#for_model'
do
it
'returns registries for uploads that belong to the model'
do
expect
(
subject
.
for_model
(
project
)).
to
match_ids
(
registry_1
,
registry_2
)
end
end
end
ee/spec/services/geo/files_expire_service_spec.rb
View file @
c12d9e8f
...
...
@@ -2,7 +2,7 @@
require
'spec_helper'
RSpec
.
describe
Geo
::
FilesExpireService
,
:geo
,
:geo_fdw
do
RSpec
.
describe
Geo
::
FilesExpireService
,
:geo
do
let
(
:project
)
{
create
(
:project
,
:legacy_storage
)
}
let!
(
:old_full_path
)
{
project
.
full_path
}
...
...
@@ -43,7 +43,6 @@ RSpec.describe Geo::FilesExpireService, :geo, :geo_fdw do
context
'when not in Geo secondary node'
do
it
'no-op execute action'
do
expect
(
subject
).
not_to
receive
(
:schedule_file_removal
)
expect
(
subject
).
not_to
receive
(
:mark_for_resync!
)
subject
.
execute
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