Skip to content
Snippets Groups Projects
Verified Commit 4ea4ad84 authored by Martin Weise's avatar Martin Weise
Browse files

Improved debugging and updated default credentials

parent d36eceda
No related branches found
No related tags found
4 merge requests!231CI: Remove build for log-service,!228Better error message handling in the frontend,!223Release of version 1.4.0,!218Replacing minIO with SeaweedFS
...@@ -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="minioadmin" ENV S3_ACCESS_KEY_ID="seaweedfsadmin"
ENV S3_SECRET_ACCESS_KEY="minioadmin" ENV S3_SECRET_ACCESS_KEY="seaweedfsadmin"
EXPOSE 3305 EXPOSE 3305
......
...@@ -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 MinioClient from clients.s3_client import S3Client
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 = MinioClient() s3_client = S3Client()
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 = MinioClient() s3_client = S3Client()
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
...@@ -6,14 +6,14 @@ import sys ...@@ -6,14 +6,14 @@ import sys
from botocore.exceptions import ClientError from botocore.exceptions import ClientError
class MinioClient: class S3Client:
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', 'minioadmin') aws_access_key_id = os.getenv('S3_ACCESS_KEY_ID', 'seaweedfsadmin')
aws_secret_access_key = os.getenv('S3_SECRET_ACCESS_KEY', 'minioadmin') aws_secret_access_key = os.getenv('S3_SECRET_ACCESS_KEY', 'seaweedfsadmin')
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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment