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
fbfb7138
Commit
fbfb7138
authored
Jun 21, 2018
by
Micaël Bergeron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
polish the error handling when object storage is unavailable
parent
a3c4ffa3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
10 deletions
+17
-10
app/workers/pseudonymizer_worker.rb
app/workers/pseudonymizer_worker.rb
+3
-1
lib/pseudonymizer/uploader.rb
lib/pseudonymizer/uploader.rb
+12
-1
lib/tasks/gitlab/db.rake
lib/tasks/gitlab/db.rake
+2
-0
spec/lib/pseudonymizer/pager_spec.rb
spec/lib/pseudonymizer/pager_spec.rb
+0
-8
No files found.
app/workers/pseudonymizer_worker.rb
View file @
fbfb7138
...
...
@@ -4,7 +4,7 @@ class PseudonymizerWorker
def
perform
abort
"The pseudonymizer is not available with this license."
unless
License
.
feature_available?
(
:pseudonymizer
)
return
unless
Gitlab
::
CurrentSettings
.
pseudonymizer_enabled?
abort
"The pseudonymizer is disabled."
unless
Gitlab
::
CurrentSettings
.
pseudonymizer_enabled?
options
=
Pseudonymizer
::
Options
.
new
(
config:
YAML
.
load_file
(
Gitlab
.
config
.
pseudonymizer
.
manifest
),
...
...
@@ -14,6 +14,8 @@ class PseudonymizerWorker
dumper
=
Pseudonymizer
::
Dumper
.
new
(
options
)
uploader
=
Pseudonymizer
::
Uploader
.
new
(
options
,
progress_output:
File
.
open
(
File
::
NULL
,
"w"
))
abort
"The pseudonymizer object storage must be configured."
unless
uploader
.
available?
begin
dumper
.
tables_to_csv
uploader
.
upload
...
...
lib/pseudonymizer/uploader.rb
View file @
fbfb7138
module
Pseudonymizer
ObjectStorageUnavailableError
=
Class
.
new
(
StandardError
)
class
Uploader
include
Gitlab
::
Utils
::
StrongMemoize
...
...
@@ -22,12 +24,20 @@ module Pseudonymizer
@connection_params
=
self
.
class
.
object_store_credentials
end
def
available?
!
connect_to_remote_directory
.
nil?
rescue
ObjectStorageUnavailableError
false
end
def
upload
progress_output
.
puts
"Uploading output files to remote storage
#{
remote_directory
}
:"
file_list
.
each
do
|
file
|
upload_file
(
file
,
remote_directory
)
end
rescue
ObjectStorageUnavailableError
abort
"Cannot upload files, make sure the `pseudonimizer.upload.connection` is set properly"
.
color
(
:red
)
end
def
cleanup
...
...
@@ -62,7 +72,8 @@ module Pseudonymizer
def
connect_to_remote_directory
if
@connection_params
.
blank?
abort
"Cannot upload files, make sure the `pseudonimizer.upload.connection` is set properly"
.
color
(
:red
)
raise
ObjectStorageUnavailableError
end
connection
=
::
Fog
::
Storage
.
new
(
@connection_params
)
...
...
lib/tasks/gitlab/db.rake
View file @
fbfb7138
...
...
@@ -83,6 +83,8 @@ namespace :gitlab do
dumper
=
Pseudonymizer
::
Dumper
.
new
(
options
)
uploader
=
Pseudonymizer
::
Uploader
.
new
(
options
)
abort
"There is an error in the pseudonymizer object store configuration."
unless
uploader
.
available?
begin
dumper
.
tables_to_csv
uploader
.
upload
...
...
spec/lib/pseudonymizer/pager_spec.rb
View file @
fbfb7138
require
'spec_helper'
describe
Pseudonymizer
::
Pager
do
class
Counter
@count
=
0
def
increment
(
*
args
)
self
.
count
+=
1
end
end
let
(
:page_size
)
{
1
}
let!
(
:projects
)
{
create_list
(
:project
,
10
)
}
subject
{
described_class
.
new
(
"projects"
,
whitelisted_columns
)
}
...
...
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