Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
DBRepo
Manage
Activity
Members
Labels
Plan
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FAIR Data Austria DB Repository
DBRepo
Commits
4ea4ad84
Verified
Commit
4ea4ad84
authored
1 year ago
by
Martin Weise
Browse files
Options
Downloads
Patches
Plain Diff
Improved debugging and updated default credentials
parent
d36eceda
No related branches found
No related tags found
4 merge requests
!231
CI: Remove build for log-service
,
!228
Better error message handling in the frontend
,
!223
Release of version 1.4.0
,
!218
Replacing minIO with SeaweedFS
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
dbrepo-data-db/sidecar/Dockerfile
+2
-2
2 additions, 2 deletions
dbrepo-data-db/sidecar/Dockerfile
dbrepo-data-db/sidecar/app.py
+5
-5
5 additions, 5 deletions
dbrepo-data-db/sidecar/app.py
dbrepo-data-db/sidecar/clients/s3_client.py
+12
-13
12 additions, 13 deletions
dbrepo-data-db/sidecar/clients/s3_client.py
with
19 additions
and
20 deletions
dbrepo-data-db/sidecar/Dockerfile
+
2
−
2
View file @
4ea4ad84
...
@@ -19,8 +19,8 @@ COPY --chown=1001 ./ds-yml ./ds-yml
...
@@ -19,8 +19,8 @@ COPY --chown=1001 ./ds-yml ./ds-yml
COPY
--chown=1001 ./app.py ./app.py
COPY
--chown=1001 ./app.py ./app.py
ENV
S3_STORAGE_ENDPOINT="http://storage-service:9000"
ENV
S3_STORAGE_ENDPOINT="http://storage-service:9000"
ENV
S3_ACCESS_KEY_ID="
minio
admin"
ENV
S3_ACCESS_KEY_ID="
seaweedfs
admin"
ENV
S3_SECRET_ACCESS_KEY="
minio
admin"
ENV
S3_SECRET_ACCESS_KEY="
seaweedfs
admin"
EXPOSE
3305
EXPOSE
3305
...
...
This diff is collapsed.
Click to expand it.
dbrepo-data-db/sidecar/app.py
+
5
−
5
View file @
4ea4ad84
...
@@ -5,7 +5,7 @@ import logging
...
@@ -5,7 +5,7 @@ import logging
from
flasgger
import
LazyJSONEncoder
,
Swagger
from
flasgger
import
LazyJSONEncoder
,
Swagger
from
flask
import
Flask
,
request
,
Response
from
flask
import
Flask
,
request
,
Response
from
flasgger.utils
import
swag_from
from
flasgger.utils
import
swag_from
from
clients.
minio
_client
import
Minio
Client
from
clients.
s3
_client
import
S3
Client
from
prometheus_flask_exporter
import
PrometheusMetrics
from
prometheus_flask_exporter
import
PrometheusMetrics
logging
.
basicConfig
(
level
=
logging
.
DEBUG
)
logging
.
basicConfig
(
level
=
logging
.
DEBUG
)
...
@@ -106,8 +106,8 @@ def health():
...
@@ -106,8 +106,8 @@ def health():
@swag_from
(
"
ds-yml/import.yml
"
)
@swag_from
(
"
ds-yml/import.yml
"
)
def
import_csv
(
filename
):
def
import_csv
(
filename
):
logging
.
debug
(
'
endpoint import csv, filename=%s, body=%s
'
,
filename
,
request
)
logging
.
debug
(
'
endpoint import csv, filename=%s, body=%s
'
,
filename
,
request
)
minio
_client
=
Minio
Client
()
s3
_client
=
S3
Client
()
response
=
minio
_client
.
download_file
(
filename
)
response
=
s3
_client
.
download_file
(
filename
)
if
response
is
False
:
if
response
is
False
:
return
Response
(),
400
return
Response
(),
400
return
Response
(
json
.
dumps
(
response
)),
202
return
Response
(
json
.
dumps
(
response
)),
202
...
@@ -117,8 +117,8 @@ def import_csv(filename):
...
@@ -117,8 +117,8 @@ def import_csv(filename):
@swag_from
(
"
ds-yml/export.yml
"
)
@swag_from
(
"
ds-yml/export.yml
"
)
def
import_csv
(
filename
):
def
import_csv
(
filename
):
logging
.
debug
(
'
endpoint export csv, filename=%s, body=%s
'
,
filename
,
request
)
logging
.
debug
(
'
endpoint export csv, filename=%s, body=%s
'
,
filename
,
request
)
minio
_client
=
Minio
Client
()
s3
_client
=
S3
Client
()
response
=
minio
_client
.
upload_file
(
filename
)
response
=
s3
_client
.
upload_file
(
filename
)
if
response
is
False
:
if
response
is
False
:
return
Response
(),
400
return
Response
(),
400
return
Response
(),
202
return
Response
(),
202
This diff is collapsed.
Click to expand it.
dbrepo-data-db/sidecar/clients/
minio
_client.py
→
dbrepo-data-db/sidecar/clients/
s3
_client.py
+
12
−
13
View file @
4ea4ad84
...
@@ -6,14 +6,14 @@ import sys
...
@@ -6,14 +6,14 @@ import sys
from
botocore.exceptions
import
ClientError
from
botocore.exceptions
import
ClientError
class
Minio
Client
:
class
S3
Client
:
def
__init__
(
self
):
def
__init__
(
self
):
endpoint_url
=
os
.
getenv
(
'
S3_STORAGE_ENDPOINT
'
,
'
http://localhost:9000
'
)
endpoint_url
=
os
.
getenv
(
'
S3_STORAGE_ENDPOINT
'
,
'
http://localhost:9000
'
)
aws_access_key_id
=
os
.
getenv
(
'
S3_ACCESS_KEY_ID
'
,
'
minio
admin
'
)
aws_access_key_id
=
os
.
getenv
(
'
S3_ACCESS_KEY_ID
'
,
'
seaweedfs
admin
'
)
aws_secret_access_key
=
os
.
getenv
(
'
S3_SECRET_ACCESS_KEY
'
,
'
minio
admin
'
)
aws_secret_access_key
=
os
.
getenv
(
'
S3_SECRET_ACCESS_KEY
'
,
'
seaweedfs
admin
'
)
logging
.
info
(
"
retrieve file from S3, endpoint_url=%s, aws_access_key_id=%s, aws_secret_access_key=(hidden)
"
,
logging
.
info
(
endpoint_url
,
aws_access_key_id
)
f
"
retrieve file from S3, endpoint_url=
{
endpoint_url
}
, aws_access_key_id
=
{
aws_access_key_id
}
, aws_secret_access_key=(hidden)
"
)
self
.
client
=
boto3
.
client
(
service_name
=
'
s3
'
,
endpoint_url
=
endpoint_url
,
aws_access_key_id
=
aws_access_key_id
,
self
.
client
=
boto3
.
client
(
service_name
=
'
s3
'
,
endpoint_url
=
endpoint_url
,
aws_access_key_id
=
aws_access_key_id
,
aws_secret_access_key
=
aws_secret_access_key
)
aws_secret_access_key
=
aws_secret_access_key
)
self
.
bucket_exists_or_exit
(
"
dbrepo-upload
"
)
self
.
bucket_exists_or_exit
(
"
dbrepo-upload
"
)
...
@@ -29,7 +29,7 @@ class MinioClient:
...
@@ -29,7 +29,7 @@ class MinioClient:
filepath
=
os
.
path
.
join
(
"
/tmp/
"
,
filename
)
filepath
=
os
.
path
.
join
(
"
/tmp/
"
,
filename
)
try
:
try
:
self
.
client
.
upload_file
(
filepath
,
"
dbrepo-download
"
,
filename
)
self
.
client
.
upload_file
(
filepath
,
"
dbrepo-download
"
,
filename
)
logging
.
info
(
"
Uploaded .csv
%s with key %s
"
,
filepath
,
filename
)
logging
.
info
(
f
"
Uploaded .csv
{
filepath
}
with key
{
filename
}
into bucket dbrepo-download
"
)
return
True
return
True
except
ClientError
as
e
:
except
ClientError
as
e
:
logging
.
error
(
e
)
logging
.
error
(
e
)
...
@@ -46,7 +46,7 @@ class MinioClient:
...
@@ -46,7 +46,7 @@ class MinioClient:
filepath
=
os
.
path
.
join
(
"
/tmp/
"
,
filename
)
filepath
=
os
.
path
.
join
(
"
/tmp/
"
,
filename
)
try
:
try
:
self
.
client
.
download_file
(
"
dbrepo-upload
"
,
filename
,
filepath
)
self
.
client
.
download_file
(
"
dbrepo-upload
"
,
filename
,
filepath
)
logging
.
info
(
"
Downloaded .csv with key
%s into %s
"
,
filename
,
filepath
)
logging
.
info
(
f
"
Downloaded .csv with key
{
filename
}
into
{
filepath
}
from bucket dbrepo-upload
"
)
return
True
return
True
except
ClientError
as
e
:
except
ClientError
as
e
:
logging
.
error
(
e
)
logging
.
error
(
e
)
...
@@ -58,10 +58,10 @@ class MinioClient:
...
@@ -58,10 +58,10 @@ class MinioClient:
logging
.
debug
(
f
"
file with name
{
filename
}
exists in bucket with name
{
bucket
}
"
)
logging
.
debug
(
f
"
file with name
{
filename
}
exists in bucket with name
{
bucket
}
"
)
except
ClientError
as
e
:
except
ClientError
as
e
:
if
e
.
response
[
"
Error
"
][
"
Code
"
]
==
"
404
"
:
if
e
.
response
[
"
Error
"
][
"
Code
"
]
==
"
404
"
:
logging
.
error
(
"
Failed to find key
%s
in bucket
%s
"
,
filename
,
bucket
)
logging
.
error
(
f
"
Failed to find key
{
filename
}
in bucket
{
bucket
}
"
)
else
:
else
:
logging
.
error
(
"
Unexpected error when finding key %s in bucket %s: %s
"
,
filename
,
bucket
,
logging
.
error
(
e
.
response
[
"
Error
"
][
"
Code
"
]
)
f
"
Unexpected error when finding key
{
filename
}
in bucket
{
bucket
}
:
{
e
.
response
[
'
Error
'
][
'
Code
'
]
}
"
)
raise
e
raise
e
def
bucket_exists_or_exit
(
self
,
bucket
):
def
bucket_exists_or_exit
(
self
,
bucket
):
...
@@ -70,8 +70,7 @@ class MinioClient:
...
@@ -70,8 +70,7 @@ class MinioClient:
logging
.
debug
(
f
"
bucket
{
bucket
}
exists.
"
)
logging
.
debug
(
f
"
bucket
{
bucket
}
exists.
"
)
except
ClientError
as
e
:
except
ClientError
as
e
:
if
e
.
response
[
"
Error
"
][
"
Code
"
]
==
"
404
"
:
if
e
.
response
[
"
Error
"
][
"
Code
"
]
==
"
404
"
:
logging
.
error
(
"
Failed to find bucket
%s
"
,
bucket
)
logging
.
error
(
f
"
Failed to find bucket
{
bucket
}
"
)
else
:
else
:
logging
.
error
(
"
Unexpected error when finding bucket %s: %s
"
,
bucket
,
logging
.
error
(
f
"
Unexpected error when finding bucket
{
bucket
}
:
{
e
.
response
[
'
Error
'
][
'
Code
'
]
}
"
)
e
.
response
[
"
Error
"
][
"
Code
"
])
sys
.
exit
(
1
)
sys
.
exit
(
1
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment