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
ced802df
Commit
ced802df
authored
Sep 23, 2021
by
Valery Sizov
Committed by
Gabriel Mazetto
Sep 23, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Geo: Use relative path for delete events in SSF
parent
4c93874c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
6 deletions
+38
-6
ee/app/models/concerns/geo/blob_replicator_strategy.rb
ee/app/models/concerns/geo/blob_replicator_strategy.rb
+10
-2
ee/spec/support/shared_examples/models/concerns/blob_replicator_strategy_shared_examples.rb
...dels/concerns/blob_replicator_strategy_shared_examples.rb
+28
-4
No files found.
ee/app/models/concerns/geo/blob_replicator_strategy.rb
View file @
ced802df
...
...
@@ -66,10 +66,18 @@ module Geo
::
Geo
::
FileRegistryRemovalService
.
new
(
replicable_name
,
model_record_id
,
event_data
[
:blob_path
]
removed_blob_path
(
event_data
[
:uploader_class
],
event_data
[
:blob_path
])
).
execute
end
def
removed_blob_path
(
uploader_class
,
path
)
return
unless
path
.
present?
# Backward compatibility check. Remove in 15.x
return
path
if
uploader_class
.
nil?
File
.
join
(
uploader_class
.
constantize
.
root
,
path
)
end
# Returns a checksum of the file
#
# @return [String] SHA256 hash of the carrierwave file
...
...
@@ -97,7 +105,7 @@ module Geo
end
def
deleted_params
{
model_record_id:
model_record
.
id
,
blob_path:
blob
_path
}
{
model_record_id:
model_record
.
id
,
uploader_class:
carrierwave_uploader
.
class
.
to_s
,
blob_path:
carrierwave_uploader
.
relative
_path
}
end
# Return whether it's capable of generating a checksum of itself
...
...
ee/spec/support/shared_examples/models/concerns/blob_replicator_strategy_shared_examples.rb
View file @
ced802df
...
...
@@ -74,7 +74,14 @@ RSpec.shared_examples 'a blob replicator' do
end
.
to
change
{
::
Geo
::
Event
.
count
}.
by
(
1
)
expect
(
::
Geo
::
Event
.
last
.
attributes
).
to
include
(
"replicable_name"
=>
replicator
.
replicable_name
,
"event_name"
=>
"deleted"
,
"payload"
=>
{
"model_record_id"
=>
replicator
.
model_record
.
id
,
"blob_path"
=>
replicator
.
blob_path
})
"replicable_name"
=>
replicator
.
replicable_name
,
"event_name"
=>
"deleted"
,
"payload"
=>
{
"model_record_id"
=>
replicator
.
model_record
.
id
,
"uploader_class"
=>
replicator
.
carrierwave_uploader
.
class
.
to_s
,
"blob_path"
=>
replicator
.
carrierwave_uploader
.
relative_path
.
to_s
}
)
end
context
'when replication feature flag is disabled'
do
...
...
@@ -120,8 +127,9 @@ RSpec.shared_examples 'a blob replicator' do
end
let!
(
:model_record_id
)
{
replicator
.
model_record_id
}
let!
(
:blob_path
)
{
replicator
.
blob_path
}
let!
(
:deleted_params
)
{
{
model_record_id:
model_record_id
,
blob_path:
blob_path
}
}
let!
(
:blob_path
)
{
replicator
.
carrierwave_uploader
.
relative_path
.
to_s
}
let!
(
:uploader_class
)
{
replicator
.
carrierwave_uploader
.
class
.
to_s
}
let!
(
:deleted_params
)
{
{
model_record_id:
model_record_id
,
uploader_class:
uploader_class
,
blob_path:
blob_path
}
}
context
'when model_record was deleted from the DB and the replicator only has its ID'
do
before
do
...
...
@@ -138,12 +146,28 @@ RSpec.shared_examples 'a blob replicator' do
it
'invokes Geo::FileRegistryRemovalService'
do
service
=
double
(
:service
)
secondary_blob_path
=
File
.
join
(
uploader_class
.
constantize
.
root
,
blob_path
)
expect
(
service
).
to
receive
(
:execute
)
expect
(
::
Geo
::
FileRegistryRemovalService
)
.
to
receive
(
:new
).
with
(
secondary_side_replicator
.
replicable_name
,
model_record_id
,
blob_path
).
and_return
(
service
)
.
to
receive
(
:new
).
with
(
secondary_side_replicator
.
replicable_name
,
model_record_id
,
secondary_
blob_path
).
and_return
(
service
)
secondary_side_replicator
.
consume
(
:deleted
,
**
deleted_params
)
end
context
'backward compatibility'
do
let!
(
:deprecated_deleted_params
)
{
{
model_record_id:
model_record_id
,
blob_path:
blob_path
}
}
it
'invokes Geo::FileRegistryRemovalService when delete event is in deprecated format'
do
service
=
double
(
:service
)
expect
(
service
).
to
receive
(
:execute
)
expect
(
::
Geo
::
FileRegistryRemovalService
)
.
to
receive
(
:new
).
with
(
secondary_side_replicator
.
replicable_name
,
model_record_id
,
blob_path
).
and_return
(
service
)
secondary_side_replicator
.
consume
(
:deleted
,
**
deprecated_deleted_params
)
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